aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/LTOBackendArtifacts.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LTOBackendArtifacts.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LTOBackendArtifacts.java
index 32931bc719..9d900a01a0 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LTOBackendArtifacts.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LTOBackendArtifacts.java
@@ -155,10 +155,14 @@ public final class LTOBackendArtifacts {
Variables buildVariables = buildVariablesBuilder.build();
List<String> execArgs = new ArrayList<>();
execArgs.addAll(featureConfiguration.getCommandLine("lto-backend", buildVariables));
+ execArgs.addAll(commandLine);
+ // If this is a PIC compile (set based on the CppConfiguration), the PIC
+ // option should be added after the rest of the command line so that it
+ // cannot be overridden. This is consistent with the ordering in the
+ // CppCompileAction's compiler options.
if (usePic) {
execArgs.add("-fPIC");
}
- execArgs.addAll(commandLine);
builder.addExecutableArguments(execArgs);
ruleContext.registerAction(builder.build(ruleContext));