diff options
author | 2015-10-06 15:34:20 +0000 | |
---|---|---|
committer | 2015-10-07 07:09:45 +0000 | |
commit | ad1114fa3bda235d9badeb907a07273a665dc99d (patch) | |
tree | 4234cb232c9caa475ff2239ab922e1eedb520297 /src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java | |
parent | 4def9d03408cf461d3eec452170ed5990ed6fdf4 (diff) |
Collect .o files compiled from C(++), and skip the rest for the LTO backend step.
This should make ThinLTO work with .o files that are not generated by
compiling C++ in a cc_library()
--
MOS_MIGRATED_REVID=104764111
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java index e3875be2c1..21e4146c63 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkerInputs.java @@ -16,6 +16,7 @@ package com.google.devtools.build.lib.rules.cpp; import com.google.common.base.Function; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.collect.CollectionUtils; @@ -113,6 +114,8 @@ public abstract class LinkerInputs { * Returns whether the library is a solib symlink. */ boolean isSolibSymlink(); + + Iterable<Artifact> getLTOBitcodeFiles(); } /** @@ -146,6 +149,11 @@ public abstract class LinkerInputs { } @Override + public Iterable<Artifact> getLTOBitcodeFiles() { + return ImmutableList.<Artifact>of(); + } + + @Override public boolean isFake() { return false; } @@ -195,10 +203,16 @@ public abstract class LinkerInputs { private static class CompoundLibraryToLink implements LibraryToLink { private final Artifact libraryArtifact; private final Iterable<Artifact> objectFiles; + private final Iterable<Artifact> ltoBitcodeFiles; - private CompoundLibraryToLink(Artifact libraryArtifact, Iterable<Artifact> objectFiles) { + private CompoundLibraryToLink( + Artifact libraryArtifact, + Iterable<Artifact> objectFiles, + Iterable<Artifact> ltoBitcodeFiles) { this.libraryArtifact = Preconditions.checkNotNull(libraryArtifact); this.objectFiles = objectFiles == null ? null : CollectionUtils.makeImmutable(objectFiles); + this.ltoBitcodeFiles = + (ltoBitcodeFiles == null) ? null : CollectionUtils.makeImmutable(ltoBitcodeFiles); } @Override @@ -233,6 +247,11 @@ public abstract class LinkerInputs { } @Override + public Iterable<Artifact> getLTOBitcodeFiles() { + return ltoBitcodeFiles; + } + + @Override public boolean equals(Object that) { if (this == that) { return true; @@ -318,14 +337,15 @@ public abstract class LinkerInputs { // Preconditions.checkArgument( // !(artifact.getGeneratingAction() instanceof CppLinkAction) || // !Link.ARCHIVE_LIBRARY_FILETYPES.contains(artifact.getFileType())); - return new CompoundLibraryToLink(artifact, null); + return new CompoundLibraryToLink(artifact, null, null); } /** * Creates a library to link with the specified object files. */ - public static LibraryToLink newInputLibrary(Artifact library, Iterable<Artifact> objectFiles) { - return new CompoundLibraryToLink(library, objectFiles); + public static LibraryToLink newInputLibrary( + Artifact library, Iterable<Artifact> objectFiles, Iterable<Artifact> ltoBitcodeFiles) { + return new CompoundLibraryToLink(library, objectFiles, ltoBitcodeFiles); } private static final Function<LibraryToLink, Artifact> LIBRARY_TO_NON_SOLIB = |