https://github.com/sarnex updated https://github.com/llvm/llvm-project/pull/211351
>From 51f1ab32b82f12b8fedfe3d37973eb96df8e3e83 Mon Sep 17 00:00:00 2001 From: Nick Sarnie <[email protected]> Date: Wed, 22 Jul 2026 11:54:06 -0700 Subject: [PATCH 1/2] [clang][Driver][SYCL] Fix SYCLInstallationDetector for compiler installs outside sysroot Signed-off-by: Nick Sarnie <[email protected]> --- clang/lib/Driver/ToolChains/SYCL.cpp | 7 ++----- clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index d41b5c06da53f..7208a8cac9436 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -21,7 +21,6 @@ SYCLInstallationDetector::SYCLInstallationDetector( : D(D) { // When -fsycl is active, locate the SYCL runtime library and record its // directory in SYCLRTLibPath for use by the linker. - StringRef SysRoot = D.SysRoot; SmallString<128> DriverDir(D.Dir); if (HostTriple.isWindowsMSVCEnvironment() || @@ -30,8 +29,7 @@ SYCLInstallationDetector::SYCLInstallationDetector( // NOTE: Only checks for LLVMSYCL.lib existence (release variant). // Debug vs release library selection happens at link time based on CRT // flags. - if (DriverDir.starts_with(SysRoot) && - Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { + if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { SmallString<128> LibDir(DriverDir); llvm::sys::path::append(LibDir, "..", "lib"); @@ -52,8 +50,7 @@ SYCLInstallationDetector::SYCLInstallationDetector( SmallString<128> FlatLibPath(DriverDir); llvm::sys::path::append(FlatLibPath, "..", "lib", "libLLVMSYCL.so"); - if (DriverDir.starts_with(SysRoot) && - Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { + if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in lib/<triple>/ if (D.getVFS().exists(LibPath)) llvm::sys::path::append(DriverDir, "..", "lib", HostTriple.str()); diff --git a/clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp b/clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp new file mode 100644 index 0000000000000..a0edbaa425510 --- /dev/null +++ b/clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp @@ -0,0 +1,11 @@ +// REQUIRES: system-linux && symlinks + +// Verify we still generate a path to libLLVMSYCL.so even with sysroot set. + +// RUN: rm -rf %t && mkdir -p %t/bin %t/lib +// RUN: touch %t/lib/libLLVMSYCL.so +// RUN: ln -s %clang %t/bin/clang +// RUN: %t/bin/clang -### -no-canonical-prefixes --target=x86_64-unknown-linux-gnu -fsycl --sysroot=/nonexistent-prefix %s 2>&1 \ +// RUN: | FileCheck %s + +// CHECK: "{{.*}}/bin/../lib/libLLVMSYCL.so" >From b9804bb149b1311431d7d3ebcb104322aa25be62 Mon Sep 17 00:00:00 2001 From: Nick Sarnie <[email protected]> Date: Fri, 24 Jul 2026 09:05:50 -0700 Subject: [PATCH 2/2] add test for per-target-runtime-dir layout Signed-off-by: Nick Sarnie <[email protected]> --- clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp b/clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp index a0edbaa425510..87ed4ba1f9ff7 100644 --- a/clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp +++ b/clang/test/Driver/sycl-rtlib-sysroot-mismatch.cpp @@ -6,6 +6,13 @@ // RUN: touch %t/lib/libLLVMSYCL.so // RUN: ln -s %clang %t/bin/clang // RUN: %t/bin/clang -### -no-canonical-prefixes --target=x86_64-unknown-linux-gnu -fsycl --sysroot=/nonexistent-prefix %s 2>&1 \ -// RUN: | FileCheck %s +// RUN: | FileCheck -check-prefix=CHECK-FLAT %s -// CHECK: "{{.*}}/bin/../lib/libLLVMSYCL.so" +// RUN: rm -rf %t && mkdir -p %t/bin %t/lib/x86_64-unknown-linux-gnu +// RUN: touch %t/lib/x86_64-unknown-linux-gnu/libLLVMSYCL.so +// RUN: ln -s %clang %t/bin/clang +// RUN: %t/bin/clang -### -no-canonical-prefixes --target=x86_64-unknown-linux-gnu -fsycl --sysroot=/nonexistent-prefix %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-PER-TARGET %s + +// CHECK-FLAT: "{{.*}}/bin/../lib/libLLVMSYCL.so" +// CHECK-PER-TARGET: "{{.*}}/bin/../lib/x86_64-unknown-linux-gnu/libLLVMSYCL.so" _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
