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

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 26 18:05:07 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";
----------------
tahonermann wrote:

We'll want `HostTriple` set to match the host triple when compiling for a device as is done for CUDA and OpenMP above. Can we set that here? I think doing so might require some other minor updates. For example, to add SYCL to the comment for the `AuxTriple` declaration, to add checks for SYCL like the ones for CUDA in `CompilerInstance::createTarget()` and `Clang::ConstructJob()`, and possibly some other locations based on a quick audit of `AuxTriple` and `HostTriple`.

If you would prefer we do this in a separate PR, that would be perfectly fine.

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


More information about the cfe-commits mailing list