================
@@ -534,11 +534,36 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles,
const ArgList &Args,
Triple.isAMDGPU() ? CmdArgs.push_back(Args.MakeArgString("-mcpu=" + Arch))
: CmdArgs.push_back(Args.MakeArgString("-march=" +
Arch));
+ bool NonLTO = Args.hasArg(OPT_no_lto) && !Triple.isSPIRV();
+
+ auto AddBackendOption = [&](StringRef Arg) {
+ CmdArgs.append({"-mllvm", Args.MakeArgString(Arg)});
+ };
+
// Forward all of the `--offload-opt` and `-mllvm` options to the device.
- for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
+ for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm)) {
+ if (NonLTO && Arg->getOption().matches(OPT_mllvm))
+ AddBackendOption(Arg->getValue());
CmdArgs.append(
{"-Xlinker",
Args.MakeArgString("--plugin-opt=" + StringRef(Arg->getValue()))});
+ }
+
+ // In the non-LTO path, this Clang invocation performs device-link codegen.
+ // Mirror explicit device-linker -mllvm options so they reach that backend
+ // invocation as they do in the LTO path.
+ if (NonLTO) {
----------------
jhuber6 wrote:
Why can't we forward these in the standard LLD way? The Linker wrapper should
accept `-plugin-opt=mllvm=whatever` I think.
https://github.com/llvm/llvm-project/pull/206591
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits