aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
diff options
context:
space:
mode:
authorGravatar hlopko <hlopko@google.com>2018-03-05 06:10:32 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-05 06:11:59 -0800
commitc0e4387c1d35ab589a5456f0d5e1fd1696596714 (patch)
treeb44198c69a31ec7e661d695c18821192acc40699 /src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
parent6144f2ae0852d030e1cc489b04d80b6256e5fba1 (diff)
Add experimental_drop_fully_static_linking_mode
When this option is set to true, then bazel will not scan linkopts for -static and will therefore never set linking mode to fully_static. This option will be used to flip the switch once the world is migrated away from fully static linking mode. RELNOTES: C++: Introduced --experimental_drop_fully_static_linking_mode Fully static linking mode will be removed soon. This option allows you to test if your build will be passing. Strategy for migrating away from fully static linking mode is to define a crosstool feature named `fully_static_link`, enable it from the target (by adding `features = [ "fully_static_link" ]`), and make sure the target is build with `linkstatic = 1`. Buildozer command that will do just that is: buildozer 'remove linkopts -static' 'set linkstatic 1' 'add features fully_static_link' //foo:bar PiperOrigin-RevId: 187856775
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
index 0aa8e4de93..0ca8887dd7 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
@@ -969,7 +969,10 @@ public class CppHelper {
public static void maybeAddStaticLinkMarkerProvider(RuleConfiguredTargetBuilder builder,
RuleContext ruleContext) {
boolean staticallyLinked = false;
- if (ruleContext.getFragment(CppConfiguration.class).hasStaticLinkOption()) {
+ CppConfiguration cppConfiguration = ruleContext.getFragment(CppConfiguration.class);
+ if (ruleContext.getFeatures().contains("fully_static_link")) {
+ staticallyLinked = true;
+ } else if (cppConfiguration.hasStaticLinkOption()) {
staticallyLinked = true;
} else if (ruleContext.attributes().has("linkopts", Type.STRING_LIST)
&& ruleContext.attributes().get("linkopts", Type.STRING_LIST).contains("-static")) {