diff options
author | Googler <noreply@google.com> | 2016-02-02 19:43:04 +0000 |
---|---|---|
committer | David Chen <dzc@google.com> | 2016-02-03 03:04:08 +0000 |
commit | 81921f15284327796d6d5f4e61fef489ac5236a1 (patch) | |
tree | 92caaa5732aca1ac0ef619535a70716dbafbd808 /src/main/java/com | |
parent | bfaf947fc530f47a69fcbf457b8d52b04cb22df3 (diff) |
Include .dwp file in the runfiles for cc_test when building with Fission.
--
MOS_MIGRATED_REVID=113660258
Diffstat (limited to 'src/main/java/com')
3 files changed, 28 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java index ff5feff2bc..350bdd50fb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java @@ -277,6 +277,14 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { Artifact explicitDwpFile = dwpFile; if (!cppConfiguration.useFission()) { explicitDwpFile = null; + } else { + // For cc_test rules, include the dwp in the runfiles if Fission is enabled and the test was + // built statically. + if (TargetUtils.isTestRule(ruleContext.getRule()) + && linkStaticness == LinkStaticness.FULLY_STATIC + && cppConfiguration.shouldBuildTestDwp()) { + filesToBuild = NestedSetBuilder.fromNestedSet(filesToBuild).add(dwpFile).build(); + } } // TODO(bazel-team): Do we need to put original shared libraries (along with 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 bab6cf54ca..bfc08276b3 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 @@ -1539,6 +1539,14 @@ public class CppConfiguration extends BuildConfiguration.Fragment { } /** + * Returns true if Fission is enabled for this build and the user requested automatic building + * of .dwp files for C++ test targets. + */ + public boolean shouldBuildTestDwp() { + return useFission() && cppOptions.buildTestDwp; + } + + /** * Returns true if all C++ compilations should produce position-independent code, links should * produce position-independent executables, and dependencies with equivalent pre-built pic and * nopic versions should apply the pic versions. Returns false if default settings should be @@ -1799,6 +1807,11 @@ public class CppConfiguration extends BuildConfiguration.Fragment { "Fission is not supported by this crosstool. Please use a supporting " + "crosstool to enable fission")); } + if (cppOptions.buildTestDwp && !useFission()) { + reporter.handle(Event.warn("Test dwp file requested, but Fission is not enabled. To " + + "generate a dwp for the test executable, use '--fission=yes' with a toolchain " + + "that supports Fission and build statically.")); + } } @Override 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 a1015979e7..6af0a7f662 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 @@ -211,6 +211,13 @@ public class CppOptions extends FragmentOptions { + " to enable all modes and 'no' to disable all modes.") public List<CompilationMode> fissionModes; + @Option(name = "build_test_dwp", + defaultValue = "false", + category = "semantics", + help = "If enabled, when building C++ tests statically and with fission the .dwp file " + + " for the test binary will be automatically built as well.") + public boolean buildTestDwp; + @Option(name = "dynamic_mode", defaultValue = "default", converter = DynamicModeConverter.class, |