[clang] [llvm] [clang] Check validity of SYCL device target (PR #172366)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 6 09:05:09 PDT 2026


================
@@ -5111,6 +5111,10 @@ bool CompilerInvocation::CreateFromArgsImpl(
   if (LangOpts.OpenMPIsTargetDevice)
     Res.getTargetOpts().HostTriple = Res.getFrontendOpts().AuxTriple;
 
+  // Set the default triple for SYCL device compilation.
+  if (LangOpts.SYCLIsDevice && !Args.hasArg(options::OPT_triple))
+    Res.getTargetOpts().Triple = "spirv64-unknown-unknown";
----------------
elizabethandrews wrote:

The unintended behavior exposed by this PR is not due to `HostTriple` being set incorrectly.  It is due to offloading toolchain being constructed unexpectedly. I pasted the code where this is done in a different thread. 

It looks like `HostTriple` is used only to set type properties. I made the suggested modifications and added a test to verify it works as expected now. 

https://github.com/llvm/llvm-project/pull/172366


More information about the cfe-commits mailing list