aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-10-11 17:19:49 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-10-11 18:12:02 +0200
commit1b99386e19fb07175a49f048dfd7cf33ed476f1b (patch)
treed8ffda7547157a0847cb63c60c195ff6eab30b57 /src/main/java/com/google/devtools/build/lib/rules
parent3d0ade5e635a1e5a21babff29ff7f9c0b07cebdf (diff)
Check the implicit requirement of fdo_instrument and lipo_context.
The semantics of implicit requirements will soon change to adding the requirements in-place in the command line, so they will be slightly more likely to get overwritten. Explicitely check that the requirement is set, and warn appropriately if the user is sending mixed signals. RELNOTES: None. PiperOrigin-RevId: 171824297
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java53
1 files changed, 39 insertions, 14 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 d8c606aca8..5a6dec8dda 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
@@ -1531,16 +1531,27 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
warn |= opt.getOptions().contains("-g");
}
if (warn) {
- reporter.handle(Event.warn("Stripping enabled, but '--copt=-g' (or --per_file_copt=...@-g) "
- + "specified. Debug information will be generated and then stripped away. This is "
- + "probably not what you want! Use '-c dbg' for debug mode, or use '--strip=never' "
- + "to disable stripping"));
+ reporter.handle(
+ Event.warn(
+ "Stripping enabled, but '--copt=-g' (or --per_file_copt=...@-g) specified. "
+ + "Debug information will be generated and then stripped away. This is "
+ + "probably not what you want! Use '-c dbg' for debug mode, or use "
+ + "'--strip=never' to disable stripping"));
}
}
- if (cppOptions.getFdoInstrument() != null && cppOptions.getFdoOptimize() != null) {
- reporter.handle(Event.error("Cannot instrument and optimize for FDO at the same time. "
- + "Remove one of the '--fdo_instrument' and '--fdo_optimize' options"));
+ if (cppOptions.getFdoInstrument() != null) {
+ if (cppOptions.getFdoOptimize() != null) {
+ reporter.handle(
+ Event.error(
+ "Cannot instrument and optimize for FDO at the same time. "
+ + "Remove one of the '--fdo_instrument' and '--fdo_optimize' options"));
+ }
+ if (!cppOptions.coptList.contains("-Wno-error")) {
+ // This is effectively impossible. --fdo_instrument adds this value, and only invocation
+ // policy could remove it.
+ reporter.handle(Event.error("Cannot instrument FDO without --copt including -Wno-error."));
+ }
}
if (cppOptions.getLipoMode() != LipoMode.OFF
@@ -1552,21 +1563,33 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
+ "automatically fall back to thinlto."));
}
if (cppOptions.lipoContextForBuild != null) {
+ if (!cppOptions.linkoptList.contains("-Wl,--warn-unresolved-symbols")) {
+ // This is effectively impossible. --lipo_context adds these values, and only invocation
+ // policy could remove them.
+ reporter.handle(
+ Event.error(
+ "The --lipo_context option cannot be used without -Wl,--warn-unresolved-symbols "
+ + "included as a linkoption"));
+ }
if (isLLVMCompiler()) {
reporter.handle(
Event.warn("LIPO options are not applicable with a LLVM compiler and will be "
+ "converted to ThinLTO"));
} else if (cppOptions.getLipoMode() != LipoMode.BINARY
|| cppOptions.getFdoOptimize() == null) {
- reporter.handle(Event.warn("The --lipo_context option can only be used together with "
- + "--fdo_optimize=<profile zip> and --lipo=binary. LIPO context will be ignored."));
+ reporter.handle(
+ Event.warn(
+ "The --lipo_context option can only be used together with --fdo_optimize="
+ + "<profile zip> and --lipo=binary. LIPO context will be ignored."));
}
} else {
if (!isLLVMCompiler()
&& cppOptions.getLipoMode() == LipoMode.BINARY
&& cppOptions.getFdoOptimize() != null) {
- reporter.handle(Event.error("The --lipo_context option must be specified when using "
- + "--fdo_optimize=<profile zip> and --lipo=binary"));
+ reporter.handle(
+ Event.error(
+ "The --lipo_context option must be specified when using "
+ + "--fdo_optimize=<profile zip> and --lipo=binary"));
}
}
if (cppOptions.getLipoMode() == LipoMode.BINARY && compilationMode != CompilationMode.OPT) {
@@ -1581,9 +1604,11 @@ public class CppConfiguration extends BuildConfiguration.Fragment {
+ "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."));
+ 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."));
}
// This is an assertion check vs. user error because users can't trigger this state.