================
@@ -184,6 +184,23 @@ void SPIRV::Linker::ConstructJob(Compilation &C, const
JobAction &JA,
// Use of --sycl-link will call the clang-sycl-linker instead of
// the default linker (spirv-link).
Linker = ToolChain.GetProgramPath("clang-sycl-linker");
+
+ // clang-sycl-linker needs the device target triple and architecture to
+ // finalize a device image.
+ bool HasTriple = false, HasArch = false;
+ for (const Arg *A :
+ Args.filtered(options::OPT_Xlinker, options::OPT_Wl_COMMA,
+ options::OPT_Zlinker_input))
+ for (StringRef Val : A->getValues()) {
+ HasTriple |= Val.starts_with("-triple") || Val.starts_with("--triple");
+ HasArch |= Val.starts_with("-arch") || Val.starts_with("--arch");
+ }
+ if (!HasTriple)
+ CmdArgs.push_back(
+ Args.MakeArgString("-triple=" + ToolChain.getTripleString()));
+ StringRef Arch = Args.getLastArgValue(options::OPT_march_EQ);
+ if (!HasArch && !Arch.empty())
+ CmdArgs.push_back(Args.MakeArgString("-arch=" + Arch));
----------------
bader wrote:
Wouldn't it be simpler to push default values before line 164?
I suppose linker triple/arch options will override the default values in this
case.
https://github.com/llvm/llvm-project/pull/217492
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits