[clang] [llvm] [Clang][SYCL][CUDA] Add --[no-]offload-embed-virtual-arch (PR #242407)

Michael Toguchi via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 3 16:48:14 PST 2026


================
@@ -9794,9 +9794,21 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA,
     // Add one "code=" per Intel GPU requested for this IGCA target.
     // llvm-offload-binary joins them, so the image gets
     // "code=xe-mtl-h,xe-mtl-u".
-    for (StringRef Device : C.getIGCADevices(TC, Arch.ArchName))
+    ArrayRef<StringRef> Devices = C.getIGCADevices(TC, Arch.ArchName);
+    for (StringRef Device : Devices)
       Parts.emplace_back("code=" + Device.str());
 
+    // Ask to drop the virtual architecture code only for device code that is
+    // compiled ahead of time, and keep it if the user also gave the IGCA
+    // target itself in --offload-arch. The option is read last, so clang
+    // reports it as unused where it can't do anything.
+    bool DropVirtualArch =
+        !Devices.empty() && !C.isRequestedIGCATarget(TC, Arch.ArchName) &&
+        !TCArgs.hasFlag(options::OPT_offload_embed_virtual_arch,
+                        options::OPT_no_offload_embed_virtual_arch, true);
----------------
mdtoguchi wrote:

This condition is anchored off of `ArchName` which is expected to be the IGCA target.  If a user is using something like `--offload-arch=xe-bmg-g21 -Xarch_xe-bmg-21 --no-offload-embed-virtual-arch` would that be captured?

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


More information about the cfe-commits mailing list