aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-12-01 16:49:02 +0000
committerGravatar Irina Iancu <elenairina@google.com>2016-12-02 07:41:22 +0000
commit65d66a3afa09abdf5d66e14d3c4a82a08c7a05e0 (patch)
treeccc3e5c9115166c24434fdb66280a6c220d0b962
parent14e35546302a48d1074bc2456ef4d63c27c9d3a1 (diff)
Add --ltoindexopt to pass options to LTO indexing step
This makes it much easier to pass options just to the LTO indexing. Previously these had to be passed via --linkopt, but that also passed the options to the final native link, which causes issues since most useful ThinLTO indexing options are plugin options and gold gives an error when these are passed to native links not involving a plugin. -- MOS_MIGRATED_REVID=140735846
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java1
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java9
3 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
index 5a43a716c2..91ef450c2c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java
@@ -319,6 +319,7 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
private final ImmutableList<String> testOnlyLinkFlags;
private final ImmutableList<String> linkOptions;
+ private final ImmutableList<String> ltoindexOptions;
private final ImmutableList<String> objcopyOptions;
private final ImmutableList<String> ldOptions;
@@ -587,6 +588,10 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
}
this.linkOptions = linkoptsBuilder.build();
+ ImmutableList.Builder<String> ltoindexoptsBuilder = ImmutableList.builder();
+ ltoindexoptsBuilder.addAll(cppOptions.ltoindexoptList);
+ this.ltoindexOptions = ltoindexoptsBuilder.build();
+
ImmutableList.Builder<String> coptsBuilder = ImmutableList.<String>builder()
.addAll(toolchain.getCompilerFlagList())
.addAll(cFlags.get(compilationMode))
@@ -1456,6 +1461,11 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
return linkOptions;
}
+ /** Returns the set of command-line LTO indexing options. */
+ public ImmutableList<String> getLTOIndexOptions() {
+ return ltoindexOptions;
+ }
+
/**
* Returns the immutable list of linker options for fully statically linked
* outputs. Does not include command-line options passed via --linkopt or
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 ed09f52223..4b32f11dd0 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
@@ -646,6 +646,7 @@ public class CppLinkActionBuilder {
} else {
List<String> opts = new ArrayList<>(linkopts);
opts.addAll(featureConfiguration.getCommandLine("lto-indexing", buildVariables));
+ opts.addAll(cppConfiguration.getLTOIndexOptions());
linkCommandLineBuilder.setLinkopts(ImmutableList.copyOf(opts));
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
index becf653502..0a1f16b089 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java
@@ -316,6 +316,15 @@ public class CppOptions extends FragmentOptions {
public List<String> linkoptList;
@Option(
+ name = "ltoindexopt",
+ defaultValue = "",
+ category = "flags",
+ allowMultiple = true,
+ help = "Additional option to pass to the LTO indexing step (under --features=thin_lto)."
+ )
+ public List<String> ltoindexoptList;
+
+ @Option(
name = "stripopt",
allowMultiple = true,
defaultValue = "",