aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-03-22 09:17:41 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-22 09:19:26 -0700
commit26603dd2e089f69cd6c9020b69a0d166b3fb0450 (patch)
tree802f7eac13800fcd7a799079bea57118ee05a80d /src/main/java/com
parent4519e61513b15cfde53e760987de52b60072c2da (diff)
Ensure -fPIC set on shared non-LTO backends as needed
Set the usePicForLtoBackend bit on the link action builder when we create static link actions. Before https://github.com/bazelbuild/bazel/commit/8c5e290dfab3cab378a9ca107ecdd6267403cd4b this wasn't required for static library link actions, as the LTO backend actions weren't created until the dependent binary's link action, which set this flag for the binary static link. However, with that change, we now create shared non-LTO backend actions early, when creating the library link action, for use later when we create the binary link action. So that flag needs to be set properly on the static library link action to get the -fPIC flag set as needed on the shared non-LTO backends. RELNOTES: None PiperOrigin-RevId: 190074918
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java
index a94035361f..f633949994 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java
@@ -782,6 +782,7 @@ public final class CcLinkingHelper {
.addObjectFiles(ccOutputs.getObjectFiles(usePicForBinaries))
.addNonCodeInputs(nonCodeLinkerInputs)
.addLtoBitcodeFiles(ccOutputs.getLtoBitcodeFiles())
+ .setUsePicForLtoBackendActions(usePicForBinaries)
.setLinkType(linkType)
.setLinkStaticness(LinkStaticness.FULLY_STATIC)
.addActionInputs(linkActionInputs)
@@ -810,6 +811,7 @@ public final class CcLinkingHelper {
newLinkActionBuilder(picArtifact)
.addObjectFiles(ccOutputs.getObjectFiles(/* usePic= */ true))
.addLtoBitcodeFiles(ccOutputs.getLtoBitcodeFiles())
+ .setUsePicForLtoBackendActions(true)
.setLinkType(picLinkType)
.setLinkStaticness(LinkStaticness.FULLY_STATIC)
.addActionInputs(linkActionInputs)