aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
diff options
context:
space:
mode:
authorGravatar hlopko <hlopko@google.com>2018-07-19 11:34:51 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-19 11:36:29 -0700
commitcfa35f3750d1ae37935bdf402a0cee306672795b (patch)
tree06037f6f8eef8edeeb6d63841dfa70415b8e23d1 /src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
parent866fda697b21a6aa129cd7513ec7638bc2ddd43d (diff)
Move --linkopt flags into user_link_flags
Previous behavior was to put flags coming from Bazel option --linkopt into legacy_link_flags. They should be in user_link_flags instead (together with flags coming from linkopts rule attribute). This cl introduces --experimental_linkopts_in_user_link_flags option that flips the behavior. There is another incompatible change. Previously cc_common.create_link_variables() included flags from --linkopt, with the flag flipped it doesn't anymore. I believe --linkopt flags shouldn't be there by default because: * We don't tie the API with the specifics of C++ rules/options, enabling theoretical use with other languages (objc) * Users are free to use ctx.fragments.cpp to access C++ options and add them explicitly (https://github.com/bazelbuild/bazel/issues/5602) * New behavior maintains the symmetry with --copt and user_compile_flags RELNOTES: None. PiperOrigin-RevId: 205274272
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
index 56bca06241..8a99e731a3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
@@ -926,6 +926,16 @@ public class CppLinkActionBuilder {
CcToolchainVariables variables;
try {
+ ImmutableList<String> userLinkFlags;
+ if (cppConfiguration.enableLinkoptsInUserLinkFlags()) {
+ userLinkFlags =
+ ImmutableList.<String>builder()
+ .addAll(linkopts)
+ .addAll(toolchain.getLinkOptions())
+ .build();
+ } else {
+ userLinkFlags = ImmutableList.copyOf(linkopts);
+ }
variables =
LinkBuildVariables.setupVariables(
getLinkType().linkerOrArchiver().equals(LinkerOrArchiver.LINKER),
@@ -941,7 +951,7 @@ public class CppLinkActionBuilder {
featureConfiguration,
useTestOnlyFlags,
isLtoIndexing,
- ImmutableList.copyOf(linkopts),
+ userLinkFlags,
toolchain.getInterfaceSoBuilder().getExecPathString(),
interfaceOutput != null ? interfaceOutput.getExecPathString() : null,
ltoOutputRootPrefix,