Skip to content

Commit

Permalink
Check the implicit requirement of fdo_instrument and lipo_context.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cvcal authored and hlopko committed Oct 11, 2017
1 parent 3d0ade5 commit 1b99386
Showing 1 changed file with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1531,16 +1531,27 @@ public void reportInvalidOptions(EventHandler reporter, BuildOptions buildOption
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
Expand All @@ -1552,21 +1563,33 @@ && isLLVMCompiler()
+ "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) {
Expand All @@ -1581,9 +1604,11 @@ && isLLVMCompiler()
+ "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.
Expand Down

0 comments on commit 1b99386

Please sign in to comment.