diff options
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 | 42 |
1 files changed, 29 insertions, 13 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 a71c384a0f..ad811e0f3c 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 @@ -36,9 +36,11 @@ public abstract class LinkerInputs { public static class SimpleLinkerInput implements LinkerInput { private final Artifact artifact; private final ArtifactCategory category; + private final boolean disableWholeArchive; @AutoCodec.Instantiator - public SimpleLinkerInput(Artifact artifact, ArtifactCategory category) { + public SimpleLinkerInput( + Artifact artifact, ArtifactCategory category, boolean disableWholeArchive) { String basename = artifact.getFilename(); switch (category) { case STATIC_LIBRARY: @@ -61,6 +63,7 @@ public abstract class LinkerInputs { } this.artifact = Preconditions.checkNotNull(artifact); this.category = category; + this.disableWholeArchive = disableWholeArchive; } @Override @@ -121,6 +124,11 @@ public abstract class LinkerInputs { public boolean isMustKeepDebug() { return false; } + + @Override + public boolean disableWholeArchive() { + return disableWholeArchive; + } } /** @@ -130,7 +138,7 @@ public abstract class LinkerInputs { @ThreadSafety.Immutable private static class FakeLinkerInput extends SimpleLinkerInput { private FakeLinkerInput(Artifact artifact) { - super(artifact, ArtifactCategory.OBJECT_FILE); + super(artifact, ArtifactCategory.OBJECT_FILE, /* disableWholeArchive= */ false); Preconditions.checkState(Link.OBJECT_FILETYPES.matches(artifact.getFilename())); } @@ -264,6 +272,11 @@ public abstract class LinkerInputs { public boolean isMustKeepDebug() { return false; } + + @Override + public boolean disableWholeArchive() { + return false; + } } /** This class represents a library that may contain object files. */ @@ -411,28 +424,31 @@ public abstract class LinkerInputs { public boolean isMustKeepDebug() { return this.mustKeepDebug; } + + @Override + public boolean disableWholeArchive() { + return false; + } } ////////////////////////////////////////////////////////////////////////////////////// // Public factory constructors: ////////////////////////////////////////////////////////////////////////////////////// - /** - * Creates linker input objects for non-library files. - */ - public static Iterable<LinkerInput> simpleLinkerInputs(Iterable<Artifact> input, - final ArtifactCategory category) { - return Iterables.transform(input, artifact -> simpleLinkerInput(artifact, category)); + /** Creates linker input objects for non-library files. */ + public static Iterable<LinkerInput> simpleLinkerInputs( + Iterable<Artifact> input, final ArtifactCategory category, boolean disableWholeArchive) { + return Iterables.transform( + input, artifact -> simpleLinkerInput(artifact, category, disableWholeArchive)); } - /** - * Creates a linker input for which we do not know what objects files it consists of. - */ - public static LinkerInput simpleLinkerInput(Artifact artifact, ArtifactCategory category) { + /** Creates a linker input for which we do not know what objects files it consists of. */ + public static LinkerInput simpleLinkerInput( + Artifact artifact, ArtifactCategory category, boolean disableWholeArchive) { // This precondition check was in place and *most* of the tests passed with them; the only // exception is when you mention a generated .a file in the srcs of a cc_* rule. // Preconditions.checkArgument(!ARCHIVE_LIBRARY_FILETYPES.contains(artifact.getFileType())); - return new SimpleLinkerInput(artifact, category); + return new SimpleLinkerInput(artifact, category, disableWholeArchive); } /** |