Skip to content

[SYCL][CUDA] clang-offload-bundler matches five-part sycl-nvptx64-nvidia-cuda-sm_XX bundle IDs to every architecture #23767

Closed

Description

@Sunrisepeak

Summary

clang-offload-bundler treats the five-part bundle IDs that the driver writes for SYCL on NVIDIA GPUs (sycl-nvptx64-nvidia-cuda-sm_89, sycl-nvptx64-nvidia-cuda-sm_90) as compatible with every NVPTX request. Unbundling for one architecture therefore returns another architecture's device code (object) or the device code of every architecture (archive).

Version

  • DPC++ 7.1.0 (Nightly 2026-09-01), clang version 22.1.0 (https://github.com/intel/llvm 880399f47228ac92f403e3b2b865cf1d6f0b1382)
  • CUDA 12.9.86 (--cuda-path), Linux x86_64

Reproduction

// k.cpp
#include <sycl/sycl.hpp>
SYCL_EXTERNAL int add_seven(int v) { return v + 7; }
clang++ -fsycl -fsycl-targets=nvidia_gpu_sm_89,nvidia_gpu_sm_90 --cuda-path=$CUDA -c k.cpp -o k.o
clang-offload-bundler --list --type=o --input=k.o
#   sycl-nvptx64-nvidia-cuda-sm_89
#   sycl-nvptx64-nvidia-cuda-sm_90
#   host-x86_64-unknown-linux-gnu

# Object: the sm_90 request returns the sm_89 device code.
clang-offload-bundler --unbundle --type=o --targets=sycl-nvptx64-nvidia-cuda-sm_89 --input=k.o --output=obj-sm_89.bc
clang-offload-bundler --unbundle --type=o --targets=sycl-nvptx64-nvidia-cuda-sm_90 --input=k.o --output=obj-sm_90.bc
sha256sum obj-sm_89.bc obj-sm_90.bc     # identical

# Archive: each request returns the members of both architectures.
llvm-ar rcs libk.a k.o
clang-offload-bundler --unbundle --type=a --targets=sycl-nvptx64-nvidia-cuda-sm_89 \
    --input=libk.a --output=out-sm_89.a --allow-missing-bundles
llvm-ar t out-sm_89.a
#   k-sycl-nvptx64-nvidia-cuda-sm_89k.o
#   k-sycl-nvptx64-nvidia-cuda-sm_90k.o

Expected

Each request returns the one bundle of its architecture: obj-sm_90.bc is the sm_90 device code, and out-sm_89.a holds only the sm_89 member. The archive members extracted for both requests are byte-identical to the device code of their own architecture, so the content is correct and only the selection is wrong.

Control

The same host and device bytes re-bundled under six-part IDs with an explicit environment (sycl-nvptx64-nvidia-cuda-unknown-sm_89, ...-unknown-sm_90) unbundle correctly: the object request for each architecture returns that architecture's bytes, and each archive request returns one member.

Analysis

In clang/lib/Driver/OffloadBundler.cpp at this revision, an offload target ID's fifth component is taken as the triple's environment and the target ID (the GPU architecture) only from a sixth component. For sycl-nvptx64-nvidia-cuda-sm_89, sm_89 becomes the environment, the target ID is empty, and the compatibility check accepts any NVPTX bundle for any request. The driver writes exactly these five-part IDs, so every multi-architecture SYCL object and static library is affected.

Impact

A static library compiled for several NVIDIA architectures links the device code of every architecture into each device image (duplicate definitions such as add_seven), and an object's device code for one architecture can be taken for another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions