aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-05-06 22:53:22 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-05-09 07:10:20 +0000
commite87336f6d97d0b37d1e58be51a716fc20dcc747d (patch)
treeb49a4cf3c5304cf1aab8c7e3c8ec6284ac21d892 /src
parent74558fcc8953dec64c2ba5920c8f7a7e3ada36ab (diff)
Support alwayslink cc_library dependencies in objc binaries.
RELNOTES: Support alwayslink cc_library dependencies in objc binaries. -- MOS_MIGRATED_REVID=121717739
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
index 395a2beaa2..27dc24bdb9 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CompilationSupport.java
@@ -15,6 +15,7 @@
package com.google.devtools.build.lib.rules.objc;
import static com.google.devtools.build.lib.packages.ImplicitOutputsFunction.fromTemplates;
+import static com.google.devtools.build.lib.rules.cpp.Link.LINK_LIBRARY_FILETYPES;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.DEFINE;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FORCE_LOAD_LIBRARY;
import static com.google.devtools.build.lib.rules.objc.ObjcProvider.FRAMEWORK_DIR;
@@ -173,6 +174,17 @@ public final class CompilationSupport {
};
/**
+ * Selects cc libraries that have alwayslink=1.
+ */
+ private static final Predicate<Artifact> ALWAYS_LINKED_CC_LIBRARY =
+ new Predicate<Artifact>() {
+ @Override
+ public boolean apply(Artifact input) {
+ return LINK_LIBRARY_FILETYPES.matches(input.getFilename());
+ }
+ };
+
+ /**
* Defines a library that contains the transitive closure of dependencies.
*/
public static final SafeImplicitOutputsFunction FULLY_LINKED_LIB =
@@ -1071,9 +1083,13 @@ public final class CompilationSupport {
.addExecPaths(ccLibraries);
}
+ Iterable<Artifact> ccLibrariesToForceLoad =
+ Iterables.filter(ccLibraries, ALWAYS_LINKED_CC_LIBRARY);
+
commandLine
.addExecPath("-o", linkedBinary)
.addBeforeEach("-force_load", Artifact.toExecPaths(objcProvider.get(FORCE_LOAD_LIBRARY)))
+ .addBeforeEach("-force_load", Artifact.toExecPaths(ccLibrariesToForceLoad))
.add(extraLinkArgs)
.add(objcProvider.get(ObjcProvider.LINKOPT));