Skip to content

[SYCL][test] Add --no-offloadlib and fno-sycl-instrument-device-code to spir/spirv target RUN lines in clang-linker-wrapper test#22049

Merged
uditagarwal97 merged 2 commits into
intel:syclfrom
srividya-sundaram:fix-clw-test
May 28, 2026
Merged

Conversation

@srividya-sundaram
Copy link
Copy Markdown
Contributor

@srividya-sundaram srividya-sundaram commented May 19, 2026

After PR #21672, SYCL device libraries are linked at compile time when using --offload-new-driver with SPIR/SPIRV targets. The compile RUN lines in clang-linker-wrapper.cpp that use SPIR-based targets now require the device libraries to be resolvable on disk.

In environments where the device libraries are not installed alongside the compiler (e.g. MSan self builds), these RUN lines fail with "cannot find expected SYCL device library" errors.

Fix by adding --sysroot=%S/Inputs/SYCL to the affected compile RUN lines so the stub .bc files in the test inputs directory are used for path resolution. This is sufficient since these are driver tests that check command line arguments, not actual compilation output.

@srividya-sundaram
Copy link
Copy Markdown
Contributor Author

Test failures in pre-commit testing are unrelated to this PR.

@srividya-sundaram srividya-sundaram marked this pull request as ready for review May 19, 2026 18:44
@srividya-sundaram srividya-sundaram requested a review from a team as a code owner May 19, 2026 18:44
@mdtoguchi
Copy link
Copy Markdown
Contributor

Can you update to head? My previous PR that updated this test added the REQUIRES: libdevice to the top of the file. With these --sysroot changes, the libdevice requirement shouldn't be needed anymore.

@mdtoguchi
Copy link
Copy Markdown
Contributor

mdtoguchi commented May 19, 2026

Can you update to head? My previous PR that updated this test added the REQUIRES: libdevice to the top of the file. With these --sysroot changes, the libdevice requirement shouldn't be needed anymore.

Nevermind - this won't work. Due to the stub .bc files being empty, the linking from within the device compilation step will fail:
.---command stderr------------
| fatal error: cannot open file '/localdisk2/mtoguchi/github/llvm/clang/test/Driver/Inputs/SYCL/lib/libsycl-crt.bc': file too small to contain bitcode header
| 1 error generated.
`-----------------------------
error: command failed with exit status: 1

@srividya-sundaram
Copy link
Copy Markdown
Contributor Author

Can you update to head? My previous PR that updated this test added the REQUIRES: libdevice to the top of the file. With these --sysroot changes, the libdevice requirement shouldn't be needed anymore.

Nevermind - this won't work. Due to the stub .bc files being empty, the linking from within the device compilation step will fail: .---command stderr------------ | fatal error: cannot open file '/localdisk2/mtoguchi/github/llvm/clang/test/Driver/Inputs/SYCL/lib/libsycl-crt.bc': file too small to contain bitcode header | 1 error generated. `----------------------------- error: command failed with exit status: 1

@mdtoguchi Are there any other changes needed for this PR?

@mdtoguchi
Copy link
Copy Markdown
Contributor

Can you update to head? My previous PR that updated this test added the REQUIRES: libdevice to the top of the file. With these --sysroot changes, the libdevice requirement shouldn't be needed anymore.

Nevermind - this won't work. Due to the stub .bc files being empty, the linking from within the device compilation step will fail: .---command stderr------------ | fatal error: cannot open file '/localdisk2/mtoguchi/github/llvm/clang/test/Driver/Inputs/SYCL/lib/libsycl-crt.bc': file too small to contain bitcode header | 1 error generated. `----------------------------- error: command failed with exit status: 1

@mdtoguchi Are there any other changes needed for this PR?

No - this can be abandoned.

@jinge90
Copy link
Copy Markdown
Contributor

jinge90 commented May 21, 2026

Hi, @mdtoguchi and @srividya-sundaram
A suggestion to solve "'/localdisk2/mtoguchi/github/llvm/clang/test/Driver/Inputs/SYCL/lib/libsycl-crt.bc': file too small to contain bitcode header | 1 error generated. `----------------------------- error: command failed with exit status: 1":
Use --no-offloadlib in cflags instead of "--sysroot=XXX". Some tests will build and generate binary, compiler will try to parse devicelib modules if '--no-offloadlib' is not added. By adding "--no-offloadlib", devicelibs will not be invovled, so this error will be gone.

Thanks very much.

@jinge90
Copy link
Copy Markdown
Contributor

jinge90 commented May 21, 2026

Hi, @mdtoguchi and @srividya-sundaram A suggestion to solve "'/localdisk2/mtoguchi/github/llvm/clang/test/Driver/Inputs/SYCL/lib/libsycl-crt.bc': file too small to contain bitcode header | 1 error generated. `----------------------------- error: command failed with exit status: 1": Use --no-offloadlib in cflags instead of "--sysroot=XXX". Some tests will build and generate binary, compiler will try to parse devicelib modules if '--no-offloadlib' is not added. By adding "--no-offloadlib", devicelibs will not be invovled, so this error will be gone.

Thanks very much.

I missed itt libraries, it is not controlled by '--no-offloadlib', we need '--no-offloadlib -fno-sycl-instrument-device-code' to get rid of all dependencies on libdevice files.

Signed-off-by: jinge90 <ge.jin@intel.com>
@jinge90
Copy link
Copy Markdown
Contributor

jinge90 commented May 25, 2026

Hi, @mdtoguchi and @srividya-sundaram
I updated this PR to get rid of all devicelib files, could you help review it?
Thanks very much.

@jinge90 jinge90 changed the title [SYCL][test] Add --sysroot=%S/Inputs/SYCL to spir/spirv target RUN lines in clang-linker-wrapper test [SYCL][test] Add --no-offloadlib and fno-sycl-instrument-device-code to spir/spirv target RUN lines in clang-linker-wrapper test May 28, 2026
@jinge90
Copy link
Copy Markdown
Contributor

jinge90 commented May 28, 2026

Hi, @intel/llvm-gatekeepers
Could you help merge?
Thanks very much.

@jinge90 jinge90 requested a review from a team May 28, 2026 02:11
@uditagarwal97 uditagarwal97 merged commit 3bdbef6 into intel:sycl May 28, 2026
46 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants