Add getExec method for CppOptions.
Part of work on execution transitions,
@@ -938,6 +938,44 @@ public class CppOptions extends FragmentOptions {
return host;
}
+ @Override
+ public FragmentOptions getExec() {
+ CppOptions exec = (CppOptions) super.getExec();
+
+ // The crosstool options are partially copied from the target configuration.
+ if (hostCrosstoolTop != null) {
+ exec.crosstoolTop = hostCrosstoolTop;
+ exec.cppCompiler = hostCppCompiler;
+ }
+
+ // hostLibcTop doesn't default to the target's libcTop.
+ // Only an explicit command-line option will change it.
+ // The default is whatever the host's crosstool (which might have been specified
+ // by --host_crosstool_top, or --crosstool_top as a fallback) says it should be.
+ exec.libcTopLabel = hostLibcTopLabel;
+ // TODO(b/129045294): Remove once toolchain-transitions are implemented.
+ exec.targetLibcTopLabel = libcTopLabel;
+
+ // -g0 is the default, but allowMultiple options cannot have default values so we just pass
+ // -g0 first and let the user options override it.
+ ImmutableList.Builder<String> coptListBuilder = ImmutableList.builder();
+ ImmutableList.Builder<String> cxxoptListBuilder = ImmutableList.builder();
+ // Don't add -g0 if the host platform is Windows.
+ // Note that host platform is not necessarily the platform bazel is running on (foundry)
+ if (OS.getCurrent() != OS.WINDOWS) {
+ coptListBuilder.add("-g0");
+ cxxoptListBuilder.add("-g0");
+ }
+ exec.coptList = coptListBuilder.addAll(hostCoptList).build();
+ exec.cxxoptList = cxxoptListBuilder.addAll(hostCxxoptList).build();
+ exec.conlyoptList = ImmutableList.copyOf(hostConlyoptList);
+ exec.linkoptList = ImmutableList.copyOf(hostLinkoptList);
+
+ exec.stripBinaries = StripMode.ALWAYS;
+
+ return exec;
+ }
+
/**
* Returns true if targets under this configuration should apply FDO.
*/
