diff options
author | 2017-05-22 18:29:02 +0200 | |
---|---|---|
committer | 2017-05-23 12:45:43 +0200 | |
commit | f1c23532d1f05b731f28d2c474ec146e2332606e (patch) | |
tree | d68691fc9a2756ceaa2605053a2ed2d37445a16f /src/main/java/com/google/devtools | |
parent | e2edf2e141a09c025a958d580c7cac7b57c70d83 (diff) |
Fix ordering of -fPIC for PIC compiles in the LTOBackendAction
For compiles that the CppConfiguration flags as needing PIC, the -fPIC
option needs to be added after the other compile options so that it cannot
be overridden (e.g. with a --copt). This is consistent with the way the
CppCompileAction compile options are ordered.
RELNOTES: None.
PiperOrigin-RevId: 156746218
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/LTOBackendArtifacts.java | 6 |
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)); |