From e6cb66328152658e989a07b6083a7afbee22ab59 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 23 Mar 2026 18:02:57 +0100 Subject: [PATCH 01/48] [SYCL] Rename clang binaries to dpclang This patch renames `clang`, `clang++`, `clang-c++`, `clang-cc`, `clang-cpp`, `clang-g++`, `clang-gcc`, `clang-cl` to the same names with a prefix `dp` to make sure the SYCL compiler package can be co-existed with the official clang package for various Linux distributions. --- clang/lib/Driver/Driver.cpp | 10 +- clang/lib/Driver/ToolChain.cpp | 18 +- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- clang/test/Analysis/scan-build/cxx-name.test | 2 +- clang/test/ClangScanDeps/implicit-target.c | 4 +- .../prebuilt-modules-in-stable-dirs.c | 4 +- .../DebugInfo/Generic/codeview-buildinfo.c | 2 +- clang/test/Driver/config-file3.c | 184 +++++++++--------- clang/test/Driver/ftime-trace.cpp | 2 +- clang/test/Driver/target-override.c | 12 +- .../utils/update_cc_test_checks/lit.local.cfg | 2 +- clang/tools/driver/CMakeLists.txt | 4 +- clang/unittests/Driver/ToolChainTest.cpp | 36 ++-- llvm/utils/lit/lit/llvm/config.py | 18 +- llvm/utils/update_cc_test_checks.py | 4 +- sycl/cmake/modules/AddSYCLExecutable.cmake | 4 +- sycl/test-e2e/CMakeLists.txt | 2 +- sycl/test/include_deps/deps_known.sh | 2 +- 18 files changed, 157 insertions(+), 155 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index db6842cf16d7e..578f00082f5ef 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -10466,17 +10466,17 @@ Driver::getOptionVisibilityMask(bool UseDriverMode) const { const char *Driver::getExecutableForDriverMode(DriverMode Mode) { switch (Mode) { case GCCMode: - return "clang"; + return "dpclang"; case GXXMode: - return "clang++"; + return "dpclang++"; case CPPMode: - return "clang-cpp"; + return "dpclang-cpp"; case CLMode: - return "clang-cl"; + return "dpclang-cl"; case FlangMode: return "flang"; case DXCMode: - return "clang-dxc"; + return "dpclang-dxc"; } llvm_unreachable("Unhandled Mode"); diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 6171d1dd34e40..fc6ff14a9a606 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -429,14 +429,14 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) { // program name in order. If there is a match, the frontend type is updated as // necessary by applying the ModeFlag. static const DriverSuffix DriverSuffixes[] = { - {"clang", nullptr}, - {"clang++", "--driver-mode=g++"}, - {"clang-c++", "--driver-mode=g++"}, - {"clang-cc", nullptr}, - {"clang-cpp", "--driver-mode=cpp"}, - {"clang-g++", "--driver-mode=g++"}, - {"clang-gcc", nullptr}, - {"clang-cl", "--driver-mode=cl"}, + {"dpclang", nullptr}, + {"dpclang++", "--driver-mode=g++"}, + {"dpclang-c++", "--driver-mode=g++"}, + {"dpclang-cc", nullptr}, + {"dpclang-cpp", "--driver-mode=cpp"}, + {"dpclang-g++", "--driver-mode=g++"}, + {"dpclang-gcc", nullptr}, + {"dpclang-cl", "--driver-mode=cl"}, {"cc", nullptr}, {"cpp", "--driver-mode=cpp"}, {"cl", "--driver-mode=cl"}, @@ -445,7 +445,7 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) { // For backwards compatibility, we create a symlink for `flang` called // `flang-new`. This will be removed in the future. {"flang-new", "--driver-mode=flang"}, - {"clang-dxc", "--driver-mode=dxc"}, + {"dpclang-dxc", "--driver-mode=dxc"}, }; for (const auto &DS : DriverSuffixes) { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index b58197e07a507..ab3db6c044cd1 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -10324,7 +10324,7 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA, TCArgs.MakeArgString(Twine("-mcmodel=") + A->getValue())); SmallString<128> ClangPath(C.getDriver().Dir); - llvm::sys::path::append(ClangPath, "clang"); + llvm::sys::path::append(ClangPath, "dpclang"); const char *Clang = C.getArgs().MakeArgString(ClangPath); auto PostWrapCompileCmd = std::make_unique(JA, *this, ResponseFileSupport::None(), diff --git a/clang/test/Analysis/scan-build/cxx-name.test b/clang/test/Analysis/scan-build/cxx-name.test index b602cb5c5231c..528ff25a15984 100644 --- a/clang/test/Analysis/scan-build/cxx-name.test +++ b/clang/test/Analysis/scan-build/cxx-name.test @@ -4,4 +4,4 @@ Check that scan-build sets the CLANG_CXX environment variable (meant to be consumed by ccc-analyzer) to an appropriate pathname for the clang++ executable, derived from the pathname of the clang executable: -CHECK: CLANG_CXX=/clang++{{(\.exe)?}}/ +CHECK: CLANG_CXX=/dpclang++{{(\.exe)?}}/ diff --git a/clang/test/ClangScanDeps/implicit-target.c b/clang/test/ClangScanDeps/implicit-target.c index cf757f937331a..c4165302cf55d 100644 --- a/clang/test/ClangScanDeps/implicit-target.c +++ b/clang/test/ClangScanDeps/implicit-target.c @@ -12,7 +12,7 @@ // RUN: clang-scan-deps -format experimental-full -compilation-database %t/cdb.json | FileCheck %s -// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-clang %t/source.c -o %t/source.o | FileCheck %s +// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-dpclang %t/source.c -o %t/source.o | FileCheck %s // CHECK: "-triple", // CHECK-NEXT: "x86_64-w64-windows-gnu", @@ -22,7 +22,7 @@ [ { "directory": "DIR" - "command": "x86_64-w64-mingw32-clang -c DIR/source.c -o DIR/source.o" + "command": "x86_64-w64-mingw32-dpclang -c DIR/source.c -o DIR/source.o" "file": "DIR/source.c" }, ] diff --git a/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c b/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c index 39b2863d966c3..32e1bcaa541ed 100644 --- a/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c +++ b/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c @@ -43,7 +43,7 @@ [ { "directory": "DIR", - "command": "clang -x c-header -c DIR/prebuild.h -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -o DIR/prebuild.pch", + "command": "dpclang -x c-header -c DIR/prebuild.h -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -o DIR/prebuild.pch", "file": "DIR/prebuild.h" } ] @@ -52,7 +52,7 @@ [ { "directory": "DIR", - "command": "clang -c DIR/client.c -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -include-pch DIR/prebuild.pch", + "command": "dpclang -c DIR/client.c -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -include-pch DIR/prebuild.pch", "file": "DIR/client.c" } ] diff --git a/clang/test/DebugInfo/Generic/codeview-buildinfo.c b/clang/test/DebugInfo/Generic/codeview-buildinfo.c index ee6f772944d84..a97fc98e76424 100644 --- a/clang/test/DebugInfo/Generic/codeview-buildinfo.c +++ b/clang/test/DebugInfo/Generic/codeview-buildinfo.c @@ -19,7 +19,7 @@ int main(void) { return 42; } // CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[PWDVAL:.+]] // CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[FILEPATHVAL:.+[\\/]codeview-buildinfo.c]] // CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: -// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[TOOLVAL:.+[\\/][clang|llvm].*]] +// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[TOOLVAL:.+[\\/][dpclang|clang|llvm].*]] // CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: "-cc1 // CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}] // CHECK-NEXT: 0x[[PWD]]: `[[PWDVAL]]` diff --git a/clang/test/Driver/config-file3.c b/clang/test/Driver/config-file3.c index c9b26763794b0..2a3a0ed3032dd 100644 --- a/clang/test/Driver/config-file3.c +++ b/clang/test/Driver/config-file3.c @@ -20,209 +20,209 @@ //--- Config files are searched for in binary directory as well. // // RUN: mkdir %t/testbin -// RUN: ln -s %clang %t/testbin/clang +// RUN: ln -s %clang %t/testbin/dpclang // RUN: echo "-Werror" > %t/testbin/aaa.cfg -// RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config=aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN +// RUN: %t/testbin/dpclang --config-system-dir= --config-user-dir= --config=aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN // // CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg // CHECK-BIN: -Werror -//--- Invocation x86_64-unknown-linux-gnu-clang-g++ tries x86_64-unknown-linux-gnu-clang++.cfg first. +//--- Invocation x86_64-unknown-linux-gnu-dpclang-g++ tries x86_64-unknown-linux-gnu-dpclang++.cfg first. // // RUN: mkdir %t/testdmode -// RUN: ln -s %clang %t/testdmode/cheribsd-riscv64-hybrid-clang++ -// RUN: ln -s %clang %t/testdmode/qqq-clang-g++ -// RUN: ln -s %clang %t/testdmode/x86_64-clang -// RUN: ln -s %clang %t/testdmode/i386-unknown-linux-gnu-clang-g++ -// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang -// RUN: touch %t/testdmode/cheribsd-riscv64-hybrid-clang++.cfg +// RUN: ln -s %clang %t/testdmode/cheribsd-riscv64-hybrid-dpclang++ +// RUN: ln -s %clang %t/testdmode/qqq-dpclang-g++ +// RUN: ln -s %clang %t/testdmode/x86_64-dpclang +// RUN: ln -s %clang %t/testdmode/i386-unknown-linux-gnu-dpclang-g++ +// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ +// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-dpclang +// RUN: touch %t/testdmode/cheribsd-riscv64-hybrid-dpclang++.cfg // RUN: touch %t/testdmode/cheribsd-riscv64-hybrid.cfg -// RUN: touch %t/testdmode/qqq-clang-g++.cfg +// RUN: touch %t/testdmode/qqq-dpclang-g++.cfg // RUN: touch %t/testdmode/qqq.cfg -// RUN: touch %t/testdmode/x86_64-clang.cfg +// RUN: touch %t/testdmode/x86_64-dpclang.cfg // RUN: touch %t/testdmode/x86_64.cfg -// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg -// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg -// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-clang.cfg +// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg +// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++.cfg +// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-dpclang.cfg // RUN: touch %t/testdmode/x86_64-unknown-linux-gnu.cfg -// RUN: touch %t/testdmode/i386-unknown-linux-gnu-clang++.cfg -// RUN: touch %t/testdmode/i386-unknown-linux-gnu-clang-g++.cfg -// RUN: touch %t/testdmode/i386-unknown-linux-gnu-clang.cfg +// RUN: touch %t/testdmode/i386-unknown-linux-gnu-dpclang++.cfg +// RUN: touch %t/testdmode/i386-unknown-linux-gnu-dpclang-g++.cfg +// RUN: touch %t/testdmode/i386-unknown-linux-gnu-dpclang.cfg // RUN: touch %t/testdmode/i386-unknown-linux-gnu.cfg -// RUN: touch %t/testdmode/clang++.cfg -// RUN: touch %t/testdmode/clang-g++.cfg -// RUN: touch %t/testdmode/clang.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: touch %t/testdmode/dpclang++.cfg +// RUN: touch %t/testdmode/dpclang-g++.cfg +// RUN: touch %t/testdmode/dpclang.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' // -// FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg +// FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg //--- -m32 overrides triple. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' // -// FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg +// FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-dpclang++.cfg //--- --target= also works for overriding triple. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --target=i386-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' //--- With --target= + -m64, -m64 takes precedence. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --target=i386-unknown-linux-gnu -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- i386 prefix also works for 32-bit. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' //--- i386 prefix + -m64 also works for 64-bit. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-clang-g++ -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-dpclang-g++ -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- File specified by --config= is loaded after the one inferred from the executable. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT --implicit-check-not 'Configuration file:' // -// EXPLICIT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg +// EXPLICIT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg // EXPLICIT-NEXT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg //--- --no-default-config --config= loads only specified file. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT-ONLY --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT-ONLY --implicit-check-not 'Configuration file:' // // EXPLICIT-ONLY: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg //--- --no-default-config disables default filenames. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG // // NO-CONFIG-NOT: Configuration file: //--- --driver-mode= is respected. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' // -// FULL1-GCC: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg +// FULL1-GCC: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang.cfg -//--- "clang" driver symlink should yield the "*-clang" configuration file. +//--- "dpclang" driver symlink should yield the "*-dpclang" configuration file. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' -//--- "clang" + --driver-mode= should yield "*-clang++". +//--- "dpclang" + --driver-mode= should yield "*-dpclang++". // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang --driver-mode=g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang --driver-mode=g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- Clang started via name prefix that is not valid is forcing that prefix instead of target triple. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ --implicit-check-not 'Configuration file:' // -// QQQ: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg +// QQQ: Configuration file: {{.*}}/testdmode/qqq-dpclang-g++.cfg //--- Explicit --target= overrides the triple even with non-standard name prefix. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-clang-g++ --target=x86_64-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-dpclang-g++ --target=x86_64-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- "x86_64" prefix does not form a valid triple either. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-clang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-dpclang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64 --implicit-check-not 'Configuration file:' // -// X86_64: Configuration file: {{.*}}/testdmode/x86_64-clang.cfg +// X86_64: Configuration file: {{.*}}/testdmode/x86_64-dpclang.cfg //--- Try cheribsd prefix using misordered triple components. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-clang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-dpclang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD --implicit-check-not 'Configuration file:' // -// CHERIBSD: Configuration file: {{.*}}/testdmode/cheribsd-riscv64-hybrid-clang++.cfg +// CHERIBSD: Configuration file: {{.*}}/testdmode/cheribsd-riscv64-hybrid-dpclang++.cfg -//--- Test fallback to x86_64-unknown-linux-gnu-clang-g++.cfg. +//--- Test fallback to x86_64-unknown-linux-gnu-dpclang-g++.cfg. // -// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg -// RUN: rm %t/testdmode/i386-unknown-linux-gnu-clang++.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2 --implicit-check-not 'Configuration file:' +// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg +// RUN: rm %t/testdmode/i386-unknown-linux-gnu-dpclang++.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2 --implicit-check-not 'Configuration file:' // -// FULL2: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg +// FULL2: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang-g++.cfg //--- FULL2 + -m32. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2-I386 --implicit-check-not 'Configuration file:' // -// FULL2-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang-g++.cfg +// FULL2-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-dpclang-g++.cfg -//--- Test fallback to x86_64-unknown-linux-gnu-clang.cfg + clang++.cfg. +//--- Test fallback to x86_64-unknown-linux-gnu-dpclang.cfg + dpclang++.cfg. // -// RUN: rm %t/testdmode/cheribsd-riscv64-hybrid-clang++.cfg -// RUN: rm %t/testdmode/qqq-clang-g++.cfg -// RUN: rm %t/testdmode/x86_64-clang.cfg -// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg -// RUN: rm %t/testdmode/i386-unknown-linux-gnu-clang-g++.cfg -// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-clang.cfg -// RUN: rm %t/testdmode/i386-unknown-linux-gnu-clang.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3 --implicit-check-not 'Configuration file:' +// RUN: rm %t/testdmode/cheribsd-riscv64-hybrid-dpclang++.cfg +// RUN: rm %t/testdmode/qqq-dpclang-g++.cfg +// RUN: rm %t/testdmode/x86_64-dpclang.cfg +// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++.cfg +// RUN: rm %t/testdmode/i386-unknown-linux-gnu-dpclang-g++.cfg +// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-dpclang.cfg +// RUN: rm %t/testdmode/i386-unknown-linux-gnu-dpclang.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3 --implicit-check-not 'Configuration file:' // -// FULL3: Configuration file: {{.*}}/testdmode/clang++.cfg +// FULL3: Configuration file: {{.*}}/testdmode/dpclang++.cfg // FULL3: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg //--- FULL3 + -m32. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-I386 --implicit-check-not 'Configuration file:' // -// FULL3-I386: Configuration file: {{.*}}/testdmode/clang++.cfg +// FULL3-I386: Configuration file: {{.*}}/testdmode/dpclang++.cfg // FULL3-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu.cfg //--- FULL3 + --driver-mode=. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-GCC --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-GCC --implicit-check-not 'Configuration file:' // -// FULL3-GCC: Configuration file: {{.*}}/testdmode/clang.cfg +// FULL3-GCC: Configuration file: {{.*}}/testdmode/dpclang.cfg // FULL3-GCC: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg //--- QQQ fallback. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ-FALLBACK --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ-FALLBACK --implicit-check-not 'Configuration file:' // -// QQQ-FALLBACK: Configuration file: {{.*}}/testdmode/clang++.cfg +// QQQ-FALLBACK: Configuration file: {{.*}}/testdmode/dpclang++.cfg // QQQ-FALLBACK: Configuration file: {{.*}}/testdmode/qqq.cfg //--- "x86_64" falback. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-clang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64-FALLBACK --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-dpclang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64-FALLBACK --implicit-check-not 'Configuration file:' // -// X86_64-FALLBACK: Configuration file: {{.*}}/testdmode/clang.cfg +// X86_64-FALLBACK: Configuration file: {{.*}}/testdmode/dpclang.cfg // X86_64-FALLBACK: Configuration file: {{.*}}/testdmode/x86_64.cfg //--- cheribsd fallback. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-clang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD-FALLBACK --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-dpclang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD-FALLBACK --implicit-check-not 'Configuration file:' // -// CHERIBSD-FALLBACK: Configuration file: {{.*}}/testdmode/clang++.cfg +// CHERIBSD-FALLBACK: Configuration file: {{.*}}/testdmode/dpclang++.cfg // CHERIBSD-FALLBACK: Configuration file: {{.*}}/testdmode/cheribsd-riscv64-hybrid.cfg -//--- Test fallback to x86_64-unknown-linux-gnu.cfg + clang-g++.cfg. +//--- Test fallback to x86_64-unknown-linux-gnu.cfg + dpclang-g++.cfg. // -// RUN: rm %t/testdmode/clang++.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL4 --implicit-check-not 'Configuration file:' +// RUN: rm %t/testdmode/dpclang++.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL4 --implicit-check-not 'Configuration file:' // -// FULL4: Configuration file: {{.*}}/testdmode/clang-g++.cfg +// FULL4: Configuration file: {{.*}}/testdmode/dpclang-g++.cfg // FULL4: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg -//--- Test fallback to clang-g++.cfg if x86_64-unknown-linux-gnu-clang.cfg does not exist. +//--- Test fallback to dpclang-g++.cfg if x86_64-unknown-linux-gnu-dpclang.cfg does not exist. // // RUN: rm %t/testdmode/x86_64-unknown-linux-gnu.cfg // RUN: rm %t/testdmode/i386-unknown-linux-gnu.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5 --implicit-check-not 'Configuration file:' // -// FULL5: Configuration file: {{.*}}/testdmode/clang-g++.cfg +// FULL5: Configuration file: {{.*}}/testdmode/dpclang-g++.cfg //--- FULL5 + -m32. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5-I386 --implicit-check-not 'Configuration file:' // -// FULL5-I386: Configuration file: {{.*}}/testdmode/clang-g++.cfg +// FULL5-I386: Configuration file: {{.*}}/testdmode/dpclang-g++.cfg //--- Test that incorrect driver mode config file is not used. // -// RUN: rm %t/testdmode/clang-g++.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG +// RUN: rm %t/testdmode/dpclang-g++.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG //--- Tilde expansion in user configuration file directory // @@ -231,23 +231,23 @@ //--- Fallback to stripping OS versions // -// RUN: touch %t/testdmode/x86_64-apple-darwin23.6.0-clang.cfg -// RUN: touch %t/testdmode/x86_64-apple-darwin23-clang.cfg -// RUN: touch %t/testdmode/x86_64-apple-darwin-clang.cfg +// RUN: touch %t/testdmode/x86_64-apple-darwin23.6.0-dpclang.cfg +// RUN: touch %t/testdmode/x86_64-apple-darwin23-dpclang.cfg +// RUN: touch %t/testdmode/x86_64-apple-darwin-dpclang.cfg // RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang -target x86_64-apple-darwin23.6.0 --config-system-dir=%t/testdmode --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix DARWIN --implicit-check-not 'Configuration file:' // -// DARWIN: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23.6.0-clang.cfg +// DARWIN: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23.6.0-dpclang.cfg //--- DARWIN + no full version // -// RUN: rm %t/testdmode/x86_64-apple-darwin23.6.0-clang.cfg +// RUN: rm %t/testdmode/x86_64-apple-darwin23.6.0-dpclang.cfg // RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang -target x86_64-apple-darwin23.6.0 --config-system-dir=%t/testdmode --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix DARWIN-MAJOR --implicit-check-not 'Configuration file:' // -// DARWIN-MAJOR: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23-clang.cfg +// DARWIN-MAJOR: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23-dpclang.cfg //--- DARWIN + no version // -// RUN: rm %t/testdmode/x86_64-apple-darwin23-clang.cfg +// RUN: rm %t/testdmode/x86_64-apple-darwin23-dpclang.cfg // RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang -target x86_64-apple-darwin23.6.0 --config-system-dir=%t/testdmode --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix DARWIN-VERSIONLESS --implicit-check-not 'Configuration file:' // -// DARWIN-VERSIONLESS: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin-clang.cfg +// DARWIN-VERSIONLESS: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin-dpclang.cfg diff --git a/clang/test/Driver/ftime-trace.cpp b/clang/test/Driver/ftime-trace.cpp index 60c5885704b58..d26fcb38f22f6 100644 --- a/clang/test/Driver/ftime-trace.cpp +++ b/clang/test/Driver/ftime-trace.cpp @@ -27,7 +27,7 @@ // CHECK-NEXT: "pid": // CHECK-NEXT: "tid": // CHECK-NEXT: "ts": -// CHECK: "name": "{{clang|llvm}}{{.*}}" +// CHECK: "name": "{{dpclang|clang|llvm}}{{.*}}" // CHECK: "name": "process_name" // CHECK: "name": "thread_name" diff --git a/clang/test/Driver/target-override.c b/clang/test/Driver/target-override.c index 5bd88e10e8576..ecc395cc0c6f1 100644 --- a/clang/test/Driver/target-override.c +++ b/clang/test/Driver/target-override.c @@ -1,19 +1,19 @@ // REQUIRES: x86-registered-target, symlinks // RUN: rm -rf %t && mkdir %t -// RUN: ln -s %clang %t/i386-clang -// RUN: ln -s %clang %t/x86_64-pc-freebsd13.1-clang +// RUN: ln -s %clang %t/i386-dpclang +// RUN: ln -s %clang %t/x86_64-pc-freebsd13.1-dpclang -// Check if invocation of "foo-clang" adds option "-target foo". +// Check if invocation of "foo-dpclang" adds option "-target foo". // -// RUN: %t/i386-clang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG1 %s +// RUN: %t/i386-dpclang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG1 %s // CHECK-TG1: Target: i386 // Check if invocation of "foo-clang --target=bar" overrides option "-target foo". // -// RUN: %t/i386-clang -c --target=x86_64 -### %s 2>&1 | FileCheck -check-prefix CHECK-TG2 %s +// RUN: %t/i386-dpclang -c --target=x86_64 -### %s 2>&1 | FileCheck -check-prefix CHECK-TG2 %s // CHECK-TG2: Target: x86_64 /// Check if invocation of "arch-vendor-osX.Y-clang" adds option "-target arch-vendor-osX.Y". -// RUN: %t/x86_64-pc-freebsd13.1-clang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG3 %s +// RUN: %t/x86_64-pc-freebsd13.1-dpclang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG3 %s // CHECK-TG3: Target: x86_64-pc-freebsd13.1 diff --git a/clang/test/utils/update_cc_test_checks/lit.local.cfg b/clang/test/utils/update_cc_test_checks/lit.local.cfg index d7cc78d8f67fe..75bc24297b710 100644 --- a/clang/test/utils/update_cc_test_checks/lit.local.cfg +++ b/clang/test/utils/update_cc_test_checks/lit.local.cfg @@ -22,7 +22,7 @@ else: config.test_format = lit.formats.ShTest(execute_external=False) config.suffixes = [".test"] - clang_path = os.path.join(config.clang_tools_dir, "clang") + clang_path = os.path.join(config.clang_tools_dir, "dpclang") extra_args = "--clang " + shell_quote(clang_path) opt_path = os.path.join(config.llvm_tools_dir, "opt") extra_args += " --opt " + shell_quote(opt_path) diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index d3bd17785e26d..ec92fc5c0eed9 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -55,6 +55,8 @@ add_clang_tool(clang GENERATE_DRIVER ) +set_target_properties(clang PROPERTIES OUTPUT_NAME dpclang) + setup_host_tool(clang CLANG clang_exe clang_target) clang_target_link_libraries(clang @@ -82,7 +84,7 @@ endif() add_dependencies(clang clang-resource-headers) if(NOT CLANG_LINKS_TO_CREATE) - set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) + set(CLANG_LINKS_TO_CREATE dpclang++ dpclang-cl dpclang-cpp) endif() if (CLANG_ENABLE_HLSL) diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp index 8f533790ec501..f24d240560a9d 100644 --- a/clang/unittests/Driver/ToolChainTest.cpp +++ b/clang/unittests/Driver/ToolChainTest.cpp @@ -446,47 +446,47 @@ TEST(ToolChainTest, GetTargetAndMode) { if (!llvm::TargetRegistry::lookupTarget(llvm::Triple("x86_64"), IgnoredError)) GTEST_SKIP(); - ParsedClangName Res = ToolChain::getTargetAndModeFromProgramName("clang"); + ParsedClangName Res = ToolChain::getTargetAndModeFromProgramName("dpclang"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "clang"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang"); EXPECT_TRUE(Res.DriverMode == nullptr); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("clang++"); + Res = ToolChain::getTargetAndModeFromProgramName("dpclang++"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("clang++6.0"); + Res = ToolChain::getTargetAndModeFromProgramName("dpclang++6.0"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("clang++-release"); + Res = ToolChain::getTargetAndModeFromProgramName("dpclang++-release"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("x86_64-clang++"); + Res = ToolChain::getTargetAndModeFromProgramName("x86_64-dpclang++"); EXPECT_TRUE(Res.TargetPrefix == "x86_64"); - EXPECT_TRUE(Res.ModeSuffix == "clang++"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_TRUE(Res.TargetIsValid); Res = ToolChain::getTargetAndModeFromProgramName( - "x86_64-linux-gnu-clang-c++"); + "x86_64-linux-gnu-dpclang-c++"); EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); - EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang-c++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_TRUE(Res.TargetIsValid); Res = ToolChain::getTargetAndModeFromProgramName( - "x86_64-linux-gnu-clang-c++-tot"); + "x86_64-linux-gnu-dpclang-c++-tot"); EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); - EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang-c++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_TRUE(Res.TargetIsValid); @@ -502,15 +502,15 @@ TEST(ToolChainTest, GetTargetAndMode) { EXPECT_TRUE(Res.DriverMode == nullptr); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("qqq-clang-cl"); + Res = ToolChain::getTargetAndModeFromProgramName("qqq-dpclang-cl"); EXPECT_TRUE(Res.TargetPrefix == "qqq"); - EXPECT_TRUE(Res.ModeSuffix == "clang-cl"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang-cl"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("clang-dxc"); + Res = ToolChain::getTargetAndModeFromProgramName("dpclang-dxc"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "clang-dxc"); + EXPECT_TRUE(Res.ModeSuffix == "dpclang-dxc"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=dxc"); EXPECT_FALSE(Res.TargetIsValid); } diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py index 8b794c6978890..38aef2fbf46dd 100644 --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -730,9 +730,9 @@ def use_clang( paths = self._get_clang_paths(additional_tool_dirs) - # Discover the 'clang' and 'clangcc' to use. + # Discover the 'dpclang' and 'clangcc' to use. self.config.clang = self.use_llvm_tool( - "clang", + "dpclang", search_env="CLANG", required=required, search_paths=paths, @@ -791,24 +791,24 @@ def use_clang( def prefer(this, to): return '''\"*** Do not use '%s' in tests, use '%s'. ***\"''' % (to, this) - self.config.substitutions.append((" clang ", prefer("%clang", "clang"))) + self.config.substitutions.append((" dpclang ", prefer("%clang", "dpclang"))) self.config.substitutions.append( - (r" clang\+\+ ", prefer("%clangxx", "clang++")) + (r" dpclang\+\+ ", prefer("%clangxx", "dpclang++")) ) self.config.substitutions.append( - (" clang-cc ", prefer("%clang_cc1", "clang-cc")) + (" dpclang-cc ", prefer("%clang_cc1", "dpclang-cc")) ) self.config.substitutions.append( - (" clang-cl ", prefer("%clang_cl", "clang-cl")) + (" dpclang-cl ", prefer("%clang_cl", "dpclang-cl")) ) self.config.substitutions.append( ( - " clang -cc1 -analyze ", - prefer("%clang_analyze_cc1", "clang -cc1 -analyze"), + " dpclang -cc1 -analyze ", + prefer("%clang_analyze_cc1", "dpclang -cc1 -analyze"), ) ) self.config.substitutions.append( - (" clang -cc1 ", prefer("%clang_cc1", "clang -cc1")) + (" dpclang -cc1 ", prefer("%clang_cc1", "dpclang -cc1")) ) self.config.substitutions.append( (" %clang-cc1 ", '''\"*** invalid substitution, use '%clang_cc1'. ***\"''') diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index 97b446d565973..ca3998c42dca2 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -159,9 +159,9 @@ def str_to_commandline(value): def infer_dependent_args(args): if not args.clang: if not args.llvm_bin: - args.clang = "clang" + args.clang = "dpclang" else: - args.clang = os.path.join(args.llvm_bin, "clang") + args.clang = os.path.join(args.llvm_bin, "dpclang") if not args.opt: if not args.llvm_bin: args.opt = "opt" diff --git a/sycl/cmake/modules/AddSYCLExecutable.cmake b/sycl/cmake/modules/AddSYCLExecutable.cmake index 3cb636771e848..1106f65d38d9d 100644 --- a/sycl/cmake/modules/AddSYCLExecutable.cmake +++ b/sycl/cmake/modules/AddSYCLExecutable.cmake @@ -5,9 +5,9 @@ macro(add_sycl_executable ARG_TARGET_NAME) "OPTIONS;SOURCES;LIBRARIES;DEPENDANTS" ${ARGN}) - set(CXX_COMPILER clang++) + set(CXX_COMPILER dpclang++) if(MSVC) - set(CXX_COMPILER clang-cl.exe) + set(CXX_COMPILER dpclang-cl.exe) set(LIB_POSTFIX ".lib") else() set(LIB_PREFIX "-l") diff --git a/sycl/test-e2e/CMakeLists.txt b/sycl/test-e2e/CMakeLists.txt index 26da635642124..b9ff2deb13457 100644 --- a/sycl/test-e2e/CMakeLists.txt +++ b/sycl/test-e2e/CMakeLists.txt @@ -41,7 +41,7 @@ if(SYCL_TEST_E2E_STANDALONE) set(SYCL_CXX_COMPILER ${CMAKE_CXX_COMPILER}) set(SYCL_E2E_CLANG_CXX_FLAGS ${CMAKE_CXX_FLAGS}) else() - set(SYCL_CXX_COMPILER "${LLVM_BINARY_DIR}/bin/clang++") + set(SYCL_CXX_COMPILER "${LLVM_BINARY_DIR}/bin/dpclang++") set(SYCL_E2E_CLANG_CXX_FLAGS "" CACHE STRING "Flags passed to clang++ when building SYCL end-to-end tests") endif() # Standalone. diff --git a/sycl/test/include_deps/deps_known.sh b/sycl/test/include_deps/deps_known.sh index e01b8f381ee37..326a39e9dd99c 100644 --- a/sycl/test/include_deps/deps_known.sh +++ b/sycl/test/include_deps/deps_known.sh @@ -11,7 +11,7 @@ function deps() { # However, sometimes first header is on the same line with # "null.o: /dev/null
", so add an explicit line break there. - clang++ -fsycl -fsycl-device-only -include "$HEADER" -c -x c++ /dev/null -o /dev/null -MD -MF - \ + dpclang++ -fsycl -fsycl-device-only -include "$HEADER" -c -x c++ /dev/null -o /dev/null -MD -MF - \ | sed 's@: /dev/null@: /dev/null\n@' \ | grep 'include/sycl\|/dev/null\|CL/\|ur_\|:' \ | grep -v 'stl_wrappers' \ From d8939da52f2f7c1c6f940c12548ab4fe06ad7e16 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 21:22:31 +0200 Subject: [PATCH 02/48] Revert "[SYCL] Rename clang binaries to dpclang" This reverts commit e6cb66328152658e989a07b6083a7afbee22ab59. --- clang/lib/Driver/Driver.cpp | 10 +- clang/lib/Driver/ToolChain.cpp | 18 +- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- clang/test/Analysis/scan-build/cxx-name.test | 2 +- clang/test/ClangScanDeps/implicit-target.c | 4 +- .../prebuilt-modules-in-stable-dirs.c | 4 +- .../DebugInfo/Generic/codeview-buildinfo.c | 2 +- clang/test/Driver/config-file3.c | 184 +++++++++--------- clang/test/Driver/ftime-trace.cpp | 2 +- clang/test/Driver/target-override.c | 12 +- .../utils/update_cc_test_checks/lit.local.cfg | 2 +- clang/tools/driver/CMakeLists.txt | 4 +- clang/unittests/Driver/ToolChainTest.cpp | 36 ++-- llvm/utils/lit/lit/llvm/config.py | 18 +- llvm/utils/update_cc_test_checks.py | 4 +- sycl/cmake/modules/AddSYCLExecutable.cmake | 4 +- sycl/test-e2e/CMakeLists.txt | 2 +- sycl/test/include_deps/deps_known.sh | 2 +- 18 files changed, 155 insertions(+), 157 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 578f00082f5ef..db6842cf16d7e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -10466,17 +10466,17 @@ Driver::getOptionVisibilityMask(bool UseDriverMode) const { const char *Driver::getExecutableForDriverMode(DriverMode Mode) { switch (Mode) { case GCCMode: - return "dpclang"; + return "clang"; case GXXMode: - return "dpclang++"; + return "clang++"; case CPPMode: - return "dpclang-cpp"; + return "clang-cpp"; case CLMode: - return "dpclang-cl"; + return "clang-cl"; case FlangMode: return "flang"; case DXCMode: - return "dpclang-dxc"; + return "clang-dxc"; } llvm_unreachable("Unhandled Mode"); diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index fc6ff14a9a606..6171d1dd34e40 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -429,14 +429,14 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) { // program name in order. If there is a match, the frontend type is updated as // necessary by applying the ModeFlag. static const DriverSuffix DriverSuffixes[] = { - {"dpclang", nullptr}, - {"dpclang++", "--driver-mode=g++"}, - {"dpclang-c++", "--driver-mode=g++"}, - {"dpclang-cc", nullptr}, - {"dpclang-cpp", "--driver-mode=cpp"}, - {"dpclang-g++", "--driver-mode=g++"}, - {"dpclang-gcc", nullptr}, - {"dpclang-cl", "--driver-mode=cl"}, + {"clang", nullptr}, + {"clang++", "--driver-mode=g++"}, + {"clang-c++", "--driver-mode=g++"}, + {"clang-cc", nullptr}, + {"clang-cpp", "--driver-mode=cpp"}, + {"clang-g++", "--driver-mode=g++"}, + {"clang-gcc", nullptr}, + {"clang-cl", "--driver-mode=cl"}, {"cc", nullptr}, {"cpp", "--driver-mode=cpp"}, {"cl", "--driver-mode=cl"}, @@ -445,7 +445,7 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) { // For backwards compatibility, we create a symlink for `flang` called // `flang-new`. This will be removed in the future. {"flang-new", "--driver-mode=flang"}, - {"dpclang-dxc", "--driver-mode=dxc"}, + {"clang-dxc", "--driver-mode=dxc"}, }; for (const auto &DS : DriverSuffixes) { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index ab3db6c044cd1..b58197e07a507 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -10324,7 +10324,7 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA, TCArgs.MakeArgString(Twine("-mcmodel=") + A->getValue())); SmallString<128> ClangPath(C.getDriver().Dir); - llvm::sys::path::append(ClangPath, "dpclang"); + llvm::sys::path::append(ClangPath, "clang"); const char *Clang = C.getArgs().MakeArgString(ClangPath); auto PostWrapCompileCmd = std::make_unique(JA, *this, ResponseFileSupport::None(), diff --git a/clang/test/Analysis/scan-build/cxx-name.test b/clang/test/Analysis/scan-build/cxx-name.test index 528ff25a15984..b602cb5c5231c 100644 --- a/clang/test/Analysis/scan-build/cxx-name.test +++ b/clang/test/Analysis/scan-build/cxx-name.test @@ -4,4 +4,4 @@ Check that scan-build sets the CLANG_CXX environment variable (meant to be consumed by ccc-analyzer) to an appropriate pathname for the clang++ executable, derived from the pathname of the clang executable: -CHECK: CLANG_CXX=/dpclang++{{(\.exe)?}}/ +CHECK: CLANG_CXX=/clang++{{(\.exe)?}}/ diff --git a/clang/test/ClangScanDeps/implicit-target.c b/clang/test/ClangScanDeps/implicit-target.c index c4165302cf55d..cf757f937331a 100644 --- a/clang/test/ClangScanDeps/implicit-target.c +++ b/clang/test/ClangScanDeps/implicit-target.c @@ -12,7 +12,7 @@ // RUN: clang-scan-deps -format experimental-full -compilation-database %t/cdb.json | FileCheck %s -// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-dpclang %t/source.c -o %t/source.o | FileCheck %s +// RUN: clang-scan-deps -format experimental-full -- x86_64-w64-mingw32-clang %t/source.c -o %t/source.o | FileCheck %s // CHECK: "-triple", // CHECK-NEXT: "x86_64-w64-windows-gnu", @@ -22,7 +22,7 @@ [ { "directory": "DIR" - "command": "x86_64-w64-mingw32-dpclang -c DIR/source.c -o DIR/source.o" + "command": "x86_64-w64-mingw32-clang -c DIR/source.c -o DIR/source.o" "file": "DIR/source.c" }, ] diff --git a/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c b/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c index 32e1bcaa541ed..39b2863d966c3 100644 --- a/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c +++ b/clang/test/ClangScanDeps/prebuilt-modules-in-stable-dirs.c @@ -43,7 +43,7 @@ [ { "directory": "DIR", - "command": "dpclang -x c-header -c DIR/prebuild.h -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -o DIR/prebuild.pch", + "command": "clang -x c-header -c DIR/prebuild.h -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -o DIR/prebuild.pch", "file": "DIR/prebuild.h" } ] @@ -52,7 +52,7 @@ [ { "directory": "DIR", - "command": "dpclang -c DIR/client.c -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -include-pch DIR/prebuild.pch", + "command": "clang -c DIR/client.c -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -include-pch DIR/prebuild.pch", "file": "DIR/client.c" } ] diff --git a/clang/test/DebugInfo/Generic/codeview-buildinfo.c b/clang/test/DebugInfo/Generic/codeview-buildinfo.c index a97fc98e76424..ee6f772944d84 100644 --- a/clang/test/DebugInfo/Generic/codeview-buildinfo.c +++ b/clang/test/DebugInfo/Generic/codeview-buildinfo.c @@ -19,7 +19,7 @@ int main(void) { return 42; } // CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[PWDVAL:.+]] // CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[FILEPATHVAL:.+[\\/]codeview-buildinfo.c]] // CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: -// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[TOOLVAL:.+[\\/][dpclang|clang|llvm].*]] +// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: [[TOOLVAL:.+[\\/][clang|llvm].*]] // CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: "-cc1 // CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}] // CHECK-NEXT: 0x[[PWD]]: `[[PWDVAL]]` diff --git a/clang/test/Driver/config-file3.c b/clang/test/Driver/config-file3.c index 2a3a0ed3032dd..c9b26763794b0 100644 --- a/clang/test/Driver/config-file3.c +++ b/clang/test/Driver/config-file3.c @@ -20,209 +20,209 @@ //--- Config files are searched for in binary directory as well. // // RUN: mkdir %t/testbin -// RUN: ln -s %clang %t/testbin/dpclang +// RUN: ln -s %clang %t/testbin/clang // RUN: echo "-Werror" > %t/testbin/aaa.cfg -// RUN: %t/testbin/dpclang --config-system-dir= --config-user-dir= --config=aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN +// RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config=aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN // // CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg // CHECK-BIN: -Werror -//--- Invocation x86_64-unknown-linux-gnu-dpclang-g++ tries x86_64-unknown-linux-gnu-dpclang++.cfg first. +//--- Invocation x86_64-unknown-linux-gnu-clang-g++ tries x86_64-unknown-linux-gnu-clang++.cfg first. // // RUN: mkdir %t/testdmode -// RUN: ln -s %clang %t/testdmode/cheribsd-riscv64-hybrid-dpclang++ -// RUN: ln -s %clang %t/testdmode/qqq-dpclang-g++ -// RUN: ln -s %clang %t/testdmode/x86_64-dpclang -// RUN: ln -s %clang %t/testdmode/i386-unknown-linux-gnu-dpclang-g++ -// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-dpclang -// RUN: touch %t/testdmode/cheribsd-riscv64-hybrid-dpclang++.cfg +// RUN: ln -s %clang %t/testdmode/cheribsd-riscv64-hybrid-clang++ +// RUN: ln -s %clang %t/testdmode/qqq-clang-g++ +// RUN: ln -s %clang %t/testdmode/x86_64-clang +// RUN: ln -s %clang %t/testdmode/i386-unknown-linux-gnu-clang-g++ +// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ +// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang +// RUN: touch %t/testdmode/cheribsd-riscv64-hybrid-clang++.cfg // RUN: touch %t/testdmode/cheribsd-riscv64-hybrid.cfg -// RUN: touch %t/testdmode/qqq-dpclang-g++.cfg +// RUN: touch %t/testdmode/qqq-clang-g++.cfg // RUN: touch %t/testdmode/qqq.cfg -// RUN: touch %t/testdmode/x86_64-dpclang.cfg +// RUN: touch %t/testdmode/x86_64-clang.cfg // RUN: touch %t/testdmode/x86_64.cfg -// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg -// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++.cfg -// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-dpclang.cfg +// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg +// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg +// RUN: touch %t/testdmode/x86_64-unknown-linux-gnu-clang.cfg // RUN: touch %t/testdmode/x86_64-unknown-linux-gnu.cfg -// RUN: touch %t/testdmode/i386-unknown-linux-gnu-dpclang++.cfg -// RUN: touch %t/testdmode/i386-unknown-linux-gnu-dpclang-g++.cfg -// RUN: touch %t/testdmode/i386-unknown-linux-gnu-dpclang.cfg +// RUN: touch %t/testdmode/i386-unknown-linux-gnu-clang++.cfg +// RUN: touch %t/testdmode/i386-unknown-linux-gnu-clang-g++.cfg +// RUN: touch %t/testdmode/i386-unknown-linux-gnu-clang.cfg // RUN: touch %t/testdmode/i386-unknown-linux-gnu.cfg -// RUN: touch %t/testdmode/dpclang++.cfg -// RUN: touch %t/testdmode/dpclang-g++.cfg -// RUN: touch %t/testdmode/dpclang.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: touch %t/testdmode/clang++.cfg +// RUN: touch %t/testdmode/clang-g++.cfg +// RUN: touch %t/testdmode/clang.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' // -// FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg +// FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg //--- -m32 overrides triple. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' // -// FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-dpclang++.cfg +// FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg //--- --target= also works for overriding triple. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --target=i386-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' //--- With --target= + -m64, -m64 takes precedence. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --target=i386-unknown-linux-gnu -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- i386 prefix also works for 32-bit. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' //--- i386 prefix + -m64 also works for 64-bit. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-dpclang-g++ -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/i386-unknown-linux-gnu-clang-g++ -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- File specified by --config= is loaded after the one inferred from the executable. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT --implicit-check-not 'Configuration file:' // -// EXPLICIT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg +// EXPLICIT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg // EXPLICIT-NEXT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg //--- --no-default-config --config= loads only specified file. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT-ONLY --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config --config=i386-qqq.cfg -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix EXPLICIT-ONLY --implicit-check-not 'Configuration file:' // // EXPLICIT-ONLY: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg //--- --no-default-config disables default filenames. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --no-default-config -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG // // NO-CONFIG-NOT: Configuration file: //--- --driver-mode= is respected. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' // -// FULL1-GCC: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang.cfg +// FULL1-GCC: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg -//--- "dpclang" driver symlink should yield the "*-dpclang" configuration file. +//--- "clang" driver symlink should yield the "*-clang" configuration file. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-GCC --implicit-check-not 'Configuration file:' -//--- "dpclang" + --driver-mode= should yield "*-dpclang++". +//--- "clang" + --driver-mode= should yield "*-clang++". // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang --driver-mode=g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang --driver-mode=g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- Clang started via name prefix that is not valid is forcing that prefix instead of target triple. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ --implicit-check-not 'Configuration file:' // -// QQQ: Configuration file: {{.*}}/testdmode/qqq-dpclang-g++.cfg +// QQQ: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg //--- Explicit --target= overrides the triple even with non-standard name prefix. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-dpclang-g++ --target=x86_64-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-clang-g++ --target=x86_64-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- "x86_64" prefix does not form a valid triple either. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-dpclang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-clang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64 --implicit-check-not 'Configuration file:' // -// X86_64: Configuration file: {{.*}}/testdmode/x86_64-dpclang.cfg +// X86_64: Configuration file: {{.*}}/testdmode/x86_64-clang.cfg //--- Try cheribsd prefix using misordered triple components. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-dpclang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-clang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD --implicit-check-not 'Configuration file:' // -// CHERIBSD: Configuration file: {{.*}}/testdmode/cheribsd-riscv64-hybrid-dpclang++.cfg +// CHERIBSD: Configuration file: {{.*}}/testdmode/cheribsd-riscv64-hybrid-clang++.cfg -//--- Test fallback to x86_64-unknown-linux-gnu-dpclang-g++.cfg. +//--- Test fallback to x86_64-unknown-linux-gnu-clang-g++.cfg. // -// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-dpclang++.cfg -// RUN: rm %t/testdmode/i386-unknown-linux-gnu-dpclang++.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2 --implicit-check-not 'Configuration file:' +// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg +// RUN: rm %t/testdmode/i386-unknown-linux-gnu-clang++.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2 --implicit-check-not 'Configuration file:' // -// FULL2: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-dpclang-g++.cfg +// FULL2: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg //--- FULL2 + -m32. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL2-I386 --implicit-check-not 'Configuration file:' // -// FULL2-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-dpclang-g++.cfg +// FULL2-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang-g++.cfg -//--- Test fallback to x86_64-unknown-linux-gnu-dpclang.cfg + dpclang++.cfg. +//--- Test fallback to x86_64-unknown-linux-gnu-clang.cfg + clang++.cfg. // -// RUN: rm %t/testdmode/cheribsd-riscv64-hybrid-dpclang++.cfg -// RUN: rm %t/testdmode/qqq-dpclang-g++.cfg -// RUN: rm %t/testdmode/x86_64-dpclang.cfg -// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++.cfg -// RUN: rm %t/testdmode/i386-unknown-linux-gnu-dpclang-g++.cfg -// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-dpclang.cfg -// RUN: rm %t/testdmode/i386-unknown-linux-gnu-dpclang.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3 --implicit-check-not 'Configuration file:' +// RUN: rm %t/testdmode/cheribsd-riscv64-hybrid-clang++.cfg +// RUN: rm %t/testdmode/qqq-clang-g++.cfg +// RUN: rm %t/testdmode/x86_64-clang.cfg +// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg +// RUN: rm %t/testdmode/i386-unknown-linux-gnu-clang-g++.cfg +// RUN: rm %t/testdmode/x86_64-unknown-linux-gnu-clang.cfg +// RUN: rm %t/testdmode/i386-unknown-linux-gnu-clang.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3 --implicit-check-not 'Configuration file:' // -// FULL3: Configuration file: {{.*}}/testdmode/dpclang++.cfg +// FULL3: Configuration file: {{.*}}/testdmode/clang++.cfg // FULL3: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg //--- FULL3 + -m32. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-I386 --implicit-check-not 'Configuration file:' // -// FULL3-I386: Configuration file: {{.*}}/testdmode/dpclang++.cfg +// FULL3-I386: Configuration file: {{.*}}/testdmode/clang++.cfg // FULL3-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu.cfg //--- FULL3 + --driver-mode=. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-GCC --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --driver-mode=gcc --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL3-GCC --implicit-check-not 'Configuration file:' // -// FULL3-GCC: Configuration file: {{.*}}/testdmode/dpclang.cfg +// FULL3-GCC: Configuration file: {{.*}}/testdmode/clang.cfg // FULL3-GCC: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg //--- QQQ fallback. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ-FALLBACK --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix QQQ-FALLBACK --implicit-check-not 'Configuration file:' // -// QQQ-FALLBACK: Configuration file: {{.*}}/testdmode/dpclang++.cfg +// QQQ-FALLBACK: Configuration file: {{.*}}/testdmode/clang++.cfg // QQQ-FALLBACK: Configuration file: {{.*}}/testdmode/qqq.cfg //--- "x86_64" falback. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-dpclang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64-FALLBACK --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-clang --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix X86_64-FALLBACK --implicit-check-not 'Configuration file:' // -// X86_64-FALLBACK: Configuration file: {{.*}}/testdmode/dpclang.cfg +// X86_64-FALLBACK: Configuration file: {{.*}}/testdmode/clang.cfg // X86_64-FALLBACK: Configuration file: {{.*}}/testdmode/x86_64.cfg //--- cheribsd fallback. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-dpclang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD-FALLBACK --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/cheribsd-riscv64-hybrid-clang++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix CHERIBSD-FALLBACK --implicit-check-not 'Configuration file:' // -// CHERIBSD-FALLBACK: Configuration file: {{.*}}/testdmode/dpclang++.cfg +// CHERIBSD-FALLBACK: Configuration file: {{.*}}/testdmode/clang++.cfg // CHERIBSD-FALLBACK: Configuration file: {{.*}}/testdmode/cheribsd-riscv64-hybrid.cfg -//--- Test fallback to x86_64-unknown-linux-gnu.cfg + dpclang-g++.cfg. +//--- Test fallback to x86_64-unknown-linux-gnu.cfg + clang-g++.cfg. // -// RUN: rm %t/testdmode/dpclang++.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL4 --implicit-check-not 'Configuration file:' +// RUN: rm %t/testdmode/clang++.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL4 --implicit-check-not 'Configuration file:' // -// FULL4: Configuration file: {{.*}}/testdmode/dpclang-g++.cfg +// FULL4: Configuration file: {{.*}}/testdmode/clang-g++.cfg // FULL4: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg -//--- Test fallback to dpclang-g++.cfg if x86_64-unknown-linux-gnu-dpclang.cfg does not exist. +//--- Test fallback to clang-g++.cfg if x86_64-unknown-linux-gnu-clang.cfg does not exist. // // RUN: rm %t/testdmode/x86_64-unknown-linux-gnu.cfg // RUN: rm %t/testdmode/i386-unknown-linux-gnu.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5 --implicit-check-not 'Configuration file:' // -// FULL5: Configuration file: {{.*}}/testdmode/dpclang-g++.cfg +// FULL5: Configuration file: {{.*}}/testdmode/clang-g++.cfg //--- FULL5 + -m32. // -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL5-I386 --implicit-check-not 'Configuration file:' // -// FULL5-I386: Configuration file: {{.*}}/testdmode/dpclang-g++.cfg +// FULL5-I386: Configuration file: {{.*}}/testdmode/clang-g++.cfg //--- Test that incorrect driver mode config file is not used. // -// RUN: rm %t/testdmode/dpclang-g++.cfg -// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-dpclang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG +// RUN: rm %t/testdmode/clang-g++.cfg +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix NO-CONFIG //--- Tilde expansion in user configuration file directory // @@ -231,23 +231,23 @@ //--- Fallback to stripping OS versions // -// RUN: touch %t/testdmode/x86_64-apple-darwin23.6.0-dpclang.cfg -// RUN: touch %t/testdmode/x86_64-apple-darwin23-dpclang.cfg -// RUN: touch %t/testdmode/x86_64-apple-darwin-dpclang.cfg +// RUN: touch %t/testdmode/x86_64-apple-darwin23.6.0-clang.cfg +// RUN: touch %t/testdmode/x86_64-apple-darwin23-clang.cfg +// RUN: touch %t/testdmode/x86_64-apple-darwin-clang.cfg // RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang -target x86_64-apple-darwin23.6.0 --config-system-dir=%t/testdmode --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix DARWIN --implicit-check-not 'Configuration file:' // -// DARWIN: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23.6.0-dpclang.cfg +// DARWIN: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23.6.0-clang.cfg //--- DARWIN + no full version // -// RUN: rm %t/testdmode/x86_64-apple-darwin23.6.0-dpclang.cfg +// RUN: rm %t/testdmode/x86_64-apple-darwin23.6.0-clang.cfg // RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang -target x86_64-apple-darwin23.6.0 --config-system-dir=%t/testdmode --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix DARWIN-MAJOR --implicit-check-not 'Configuration file:' // -// DARWIN-MAJOR: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23-dpclang.cfg +// DARWIN-MAJOR: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin23-clang.cfg //--- DARWIN + no version // -// RUN: rm %t/testdmode/x86_64-apple-darwin23-dpclang.cfg +// RUN: rm %t/testdmode/x86_64-apple-darwin23-clang.cfg // RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang -target x86_64-apple-darwin23.6.0 --config-system-dir=%t/testdmode --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix DARWIN-VERSIONLESS --implicit-check-not 'Configuration file:' // -// DARWIN-VERSIONLESS: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin-dpclang.cfg +// DARWIN-VERSIONLESS: Configuration file: {{.*}}/testdmode/x86_64-apple-darwin-clang.cfg diff --git a/clang/test/Driver/ftime-trace.cpp b/clang/test/Driver/ftime-trace.cpp index d26fcb38f22f6..60c5885704b58 100644 --- a/clang/test/Driver/ftime-trace.cpp +++ b/clang/test/Driver/ftime-trace.cpp @@ -27,7 +27,7 @@ // CHECK-NEXT: "pid": // CHECK-NEXT: "tid": // CHECK-NEXT: "ts": -// CHECK: "name": "{{dpclang|clang|llvm}}{{.*}}" +// CHECK: "name": "{{clang|llvm}}{{.*}}" // CHECK: "name": "process_name" // CHECK: "name": "thread_name" diff --git a/clang/test/Driver/target-override.c b/clang/test/Driver/target-override.c index ecc395cc0c6f1..5bd88e10e8576 100644 --- a/clang/test/Driver/target-override.c +++ b/clang/test/Driver/target-override.c @@ -1,19 +1,19 @@ // REQUIRES: x86-registered-target, symlinks // RUN: rm -rf %t && mkdir %t -// RUN: ln -s %clang %t/i386-dpclang -// RUN: ln -s %clang %t/x86_64-pc-freebsd13.1-dpclang +// RUN: ln -s %clang %t/i386-clang +// RUN: ln -s %clang %t/x86_64-pc-freebsd13.1-clang -// Check if invocation of "foo-dpclang" adds option "-target foo". +// Check if invocation of "foo-clang" adds option "-target foo". // -// RUN: %t/i386-dpclang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG1 %s +// RUN: %t/i386-clang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG1 %s // CHECK-TG1: Target: i386 // Check if invocation of "foo-clang --target=bar" overrides option "-target foo". // -// RUN: %t/i386-dpclang -c --target=x86_64 -### %s 2>&1 | FileCheck -check-prefix CHECK-TG2 %s +// RUN: %t/i386-clang -c --target=x86_64 -### %s 2>&1 | FileCheck -check-prefix CHECK-TG2 %s // CHECK-TG2: Target: x86_64 /// Check if invocation of "arch-vendor-osX.Y-clang" adds option "-target arch-vendor-osX.Y". -// RUN: %t/x86_64-pc-freebsd13.1-dpclang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG3 %s +// RUN: %t/x86_64-pc-freebsd13.1-clang -c -### %s 2>&1 | FileCheck -check-prefix CHECK-TG3 %s // CHECK-TG3: Target: x86_64-pc-freebsd13.1 diff --git a/clang/test/utils/update_cc_test_checks/lit.local.cfg b/clang/test/utils/update_cc_test_checks/lit.local.cfg index 75bc24297b710..d7cc78d8f67fe 100644 --- a/clang/test/utils/update_cc_test_checks/lit.local.cfg +++ b/clang/test/utils/update_cc_test_checks/lit.local.cfg @@ -22,7 +22,7 @@ else: config.test_format = lit.formats.ShTest(execute_external=False) config.suffixes = [".test"] - clang_path = os.path.join(config.clang_tools_dir, "dpclang") + clang_path = os.path.join(config.clang_tools_dir, "clang") extra_args = "--clang " + shell_quote(clang_path) opt_path = os.path.join(config.llvm_tools_dir, "opt") extra_args += " --opt " + shell_quote(opt_path) diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index ec92fc5c0eed9..d3bd17785e26d 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -55,8 +55,6 @@ add_clang_tool(clang GENERATE_DRIVER ) -set_target_properties(clang PROPERTIES OUTPUT_NAME dpclang) - setup_host_tool(clang CLANG clang_exe clang_target) clang_target_link_libraries(clang @@ -84,7 +82,7 @@ endif() add_dependencies(clang clang-resource-headers) if(NOT CLANG_LINKS_TO_CREATE) - set(CLANG_LINKS_TO_CREATE dpclang++ dpclang-cl dpclang-cpp) + set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) endif() if (CLANG_ENABLE_HLSL) diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp index f24d240560a9d..8f533790ec501 100644 --- a/clang/unittests/Driver/ToolChainTest.cpp +++ b/clang/unittests/Driver/ToolChainTest.cpp @@ -446,47 +446,47 @@ TEST(ToolChainTest, GetTargetAndMode) { if (!llvm::TargetRegistry::lookupTarget(llvm::Triple("x86_64"), IgnoredError)) GTEST_SKIP(); - ParsedClangName Res = ToolChain::getTargetAndModeFromProgramName("dpclang"); + ParsedClangName Res = ToolChain::getTargetAndModeFromProgramName("clang"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "dpclang"); + EXPECT_TRUE(Res.ModeSuffix == "clang"); EXPECT_TRUE(Res.DriverMode == nullptr); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("dpclang++"); + Res = ToolChain::getTargetAndModeFromProgramName("clang++"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("dpclang++6.0"); + Res = ToolChain::getTargetAndModeFromProgramName("clang++6.0"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("dpclang++-release"); + Res = ToolChain::getTargetAndModeFromProgramName("clang++-release"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("x86_64-dpclang++"); + Res = ToolChain::getTargetAndModeFromProgramName("x86_64-clang++"); EXPECT_TRUE(Res.TargetPrefix == "x86_64"); - EXPECT_TRUE(Res.ModeSuffix == "dpclang++"); + EXPECT_TRUE(Res.ModeSuffix == "clang++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_TRUE(Res.TargetIsValid); Res = ToolChain::getTargetAndModeFromProgramName( - "x86_64-linux-gnu-dpclang-c++"); + "x86_64-linux-gnu-clang-c++"); EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); - EXPECT_TRUE(Res.ModeSuffix == "dpclang-c++"); + EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_TRUE(Res.TargetIsValid); Res = ToolChain::getTargetAndModeFromProgramName( - "x86_64-linux-gnu-dpclang-c++-tot"); + "x86_64-linux-gnu-clang-c++-tot"); EXPECT_TRUE(Res.TargetPrefix == "x86_64-linux-gnu"); - EXPECT_TRUE(Res.ModeSuffix == "dpclang-c++"); + EXPECT_TRUE(Res.ModeSuffix == "clang-c++"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=g++"); EXPECT_TRUE(Res.TargetIsValid); @@ -502,15 +502,15 @@ TEST(ToolChainTest, GetTargetAndMode) { EXPECT_TRUE(Res.DriverMode == nullptr); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("qqq-dpclang-cl"); + Res = ToolChain::getTargetAndModeFromProgramName("qqq-clang-cl"); EXPECT_TRUE(Res.TargetPrefix == "qqq"); - EXPECT_TRUE(Res.ModeSuffix == "dpclang-cl"); + EXPECT_TRUE(Res.ModeSuffix == "clang-cl"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl"); EXPECT_FALSE(Res.TargetIsValid); - Res = ToolChain::getTargetAndModeFromProgramName("dpclang-dxc"); + Res = ToolChain::getTargetAndModeFromProgramName("clang-dxc"); EXPECT_TRUE(Res.TargetPrefix.empty()); - EXPECT_TRUE(Res.ModeSuffix == "dpclang-dxc"); + EXPECT_TRUE(Res.ModeSuffix == "clang-dxc"); EXPECT_STREQ(Res.DriverMode, "--driver-mode=dxc"); EXPECT_FALSE(Res.TargetIsValid); } diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py index 38aef2fbf46dd..8b794c6978890 100644 --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -730,9 +730,9 @@ def use_clang( paths = self._get_clang_paths(additional_tool_dirs) - # Discover the 'dpclang' and 'clangcc' to use. + # Discover the 'clang' and 'clangcc' to use. self.config.clang = self.use_llvm_tool( - "dpclang", + "clang", search_env="CLANG", required=required, search_paths=paths, @@ -791,24 +791,24 @@ def use_clang( def prefer(this, to): return '''\"*** Do not use '%s' in tests, use '%s'. ***\"''' % (to, this) - self.config.substitutions.append((" dpclang ", prefer("%clang", "dpclang"))) + self.config.substitutions.append((" clang ", prefer("%clang", "clang"))) self.config.substitutions.append( - (r" dpclang\+\+ ", prefer("%clangxx", "dpclang++")) + (r" clang\+\+ ", prefer("%clangxx", "clang++")) ) self.config.substitutions.append( - (" dpclang-cc ", prefer("%clang_cc1", "dpclang-cc")) + (" clang-cc ", prefer("%clang_cc1", "clang-cc")) ) self.config.substitutions.append( - (" dpclang-cl ", prefer("%clang_cl", "dpclang-cl")) + (" clang-cl ", prefer("%clang_cl", "clang-cl")) ) self.config.substitutions.append( ( - " dpclang -cc1 -analyze ", - prefer("%clang_analyze_cc1", "dpclang -cc1 -analyze"), + " clang -cc1 -analyze ", + prefer("%clang_analyze_cc1", "clang -cc1 -analyze"), ) ) self.config.substitutions.append( - (" dpclang -cc1 ", prefer("%clang_cc1", "dpclang -cc1")) + (" clang -cc1 ", prefer("%clang_cc1", "clang -cc1")) ) self.config.substitutions.append( (" %clang-cc1 ", '''\"*** invalid substitution, use '%clang_cc1'. ***\"''') diff --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py index ca3998c42dca2..97b446d565973 100755 --- a/llvm/utils/update_cc_test_checks.py +++ b/llvm/utils/update_cc_test_checks.py @@ -159,9 +159,9 @@ def str_to_commandline(value): def infer_dependent_args(args): if not args.clang: if not args.llvm_bin: - args.clang = "dpclang" + args.clang = "clang" else: - args.clang = os.path.join(args.llvm_bin, "dpclang") + args.clang = os.path.join(args.llvm_bin, "clang") if not args.opt: if not args.llvm_bin: args.opt = "opt" diff --git a/sycl/cmake/modules/AddSYCLExecutable.cmake b/sycl/cmake/modules/AddSYCLExecutable.cmake index 1106f65d38d9d..3cb636771e848 100644 --- a/sycl/cmake/modules/AddSYCLExecutable.cmake +++ b/sycl/cmake/modules/AddSYCLExecutable.cmake @@ -5,9 +5,9 @@ macro(add_sycl_executable ARG_TARGET_NAME) "OPTIONS;SOURCES;LIBRARIES;DEPENDANTS" ${ARGN}) - set(CXX_COMPILER dpclang++) + set(CXX_COMPILER clang++) if(MSVC) - set(CXX_COMPILER dpclang-cl.exe) + set(CXX_COMPILER clang-cl.exe) set(LIB_POSTFIX ".lib") else() set(LIB_PREFIX "-l") diff --git a/sycl/test-e2e/CMakeLists.txt b/sycl/test-e2e/CMakeLists.txt index b9ff2deb13457..26da635642124 100644 --- a/sycl/test-e2e/CMakeLists.txt +++ b/sycl/test-e2e/CMakeLists.txt @@ -41,7 +41,7 @@ if(SYCL_TEST_E2E_STANDALONE) set(SYCL_CXX_COMPILER ${CMAKE_CXX_COMPILER}) set(SYCL_E2E_CLANG_CXX_FLAGS ${CMAKE_CXX_FLAGS}) else() - set(SYCL_CXX_COMPILER "${LLVM_BINARY_DIR}/bin/dpclang++") + set(SYCL_CXX_COMPILER "${LLVM_BINARY_DIR}/bin/clang++") set(SYCL_E2E_CLANG_CXX_FLAGS "" CACHE STRING "Flags passed to clang++ when building SYCL end-to-end tests") endif() # Standalone. diff --git a/sycl/test/include_deps/deps_known.sh b/sycl/test/include_deps/deps_known.sh index 326a39e9dd99c..e01b8f381ee37 100644 --- a/sycl/test/include_deps/deps_known.sh +++ b/sycl/test/include_deps/deps_known.sh @@ -11,7 +11,7 @@ function deps() { # However, sometimes first header is on the same line with # "null.o: /dev/null
", so add an explicit line break there. - dpclang++ -fsycl -fsycl-device-only -include "$HEADER" -c -x c++ /dev/null -o /dev/null -MD -MF - \ + clang++ -fsycl -fsycl-device-only -include "$HEADER" -c -x c++ /dev/null -o /dev/null -MD -MF - \ | sed 's@: /dev/null@: /dev/null\n@' \ | grep 'include/sycl\|/dev/null\|CL/\|ur_\|:' \ | grep -v 'stl_wrappers' \ From 6b896baf0655602e5a46e9da450e4289c6b07a6b Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 21:25:51 +0200 Subject: [PATCH 03/48] Apply CR comments --- clang/cmake/modules/AddClang.cmake | 4 +-- clang/tools/driver/CMakeLists.txt | 46 +++++++++++++++++++++++++ cmake/Modules/DPCPPVersion.cmake | 4 +++ libsycl/tools/sycl-ls/CMakeLists.txt | 2 +- llvm/CMakeLists.txt | 6 ++++ sycl/tools/sycl-ls/CMakeLists.txt | 2 +- sycl/tools/sycl-prof/CMakeLists.txt | 2 +- sycl/tools/sycl-sanitize/CMakeLists.txt | 2 +- sycl/tools/sycl-trace/CMakeLists.txt | 2 +- sycl/tools/syclbin-dump/CMakeLists.txt | 2 +- 10 files changed, 64 insertions(+), 8 deletions(-) diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index e2112d7c326e2..f7d1f6137b1b7 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -183,11 +183,11 @@ macro(add_clang_tool name) get_target_export_arg(${name} Clang export_to_clangtargets) install(TARGETS ${name} ${export_to_clangtargets} - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + RUNTIME DESTINATION "${DPCPP_INSTALL_INTERNAL_BINDIR}" COMPONENT ${name}) if (LLVM_ENABLE_PDB) - install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL) + install(FILES $ DESTINATION "${DPCPP_INSTALL_INTERNAL_BINDIR}" COMPONENT ${name} OPTIONAL) endif() if(NOT LLVM_ENABLE_IDE) diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index d3bd17785e26d..3ea4c4bc93b80 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -93,6 +93,52 @@ foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK}) add_clang_symlink(${link} clang) endforeach() +# Install public dpclang* symlinks in ${CMAKE_INSTALL_BINDIR}. +# These versioned names avoid conflicts with a system LLVM installation while +# the real binaries live in ${DPCPP_INSTALL_INTERNAL_BINDIR} alongside all companion +# tools so that the driver can find them via its own executable path. +if(CLANG_BUILD_TOOLS) + # Ensure ${CMAKE_INSTALL_BINDIR} exists — no real binaries install there + # anymore so it would otherwise never be created. + install(DIRECTORY DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT clang) + + foreach(path ${CMAKE_MODULE_PATH}) + if(EXISTS ${path}/LLVMInstallSymlink.cmake) + set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake) + break() + endif() + endforeach() + + if(LLVM_USE_SYMLINKS) + set(_dpclang_link_or_copy create_symlink) + else() + set(_dpclang_link_or_copy copy) + endif() + + # Compute the relative path from $bindir to clang++ inside the tools dir so + # the symlinks work regardless of the installation prefix. + set(_abs_bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") + set(_abs_toolsdir "${CMAKE_INSTALL_PREFIX}/${DPCPP_INSTALL_INTERNAL_BINDIR}") + file(RELATIVE_PATH _dpclang_clangpp "${_abs_bindir}" "${_abs_toolsdir}/clang++") + + # dpclang-MAJOR is the versioned public entry-point; it chains through clang++ + # (itself a symlink to the versioned clang binary) so realpath resolves to the + # tools directory where all companion tools reside. + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}\" \"${_dpclang_clangpp}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"dpclang\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + + foreach(_link dpclang++ dpclang-cl dpclang-cpp) + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"${_link}\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + endforeach() +endif() + # Configure plist creation for OS X. set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name") if (APPLE) diff --git a/cmake/Modules/DPCPPVersion.cmake b/cmake/Modules/DPCPPVersion.cmake index 7d0a7699929a1..e52c1068b4201 100644 --- a/cmake/Modules/DPCPPVersion.cmake +++ b/cmake/Modules/DPCPPVersion.cmake @@ -3,6 +3,10 @@ if(NOT DEFINED DPCPP_VERSION_MAJOR) set(DPCPP_VERSION_MAJOR 7) endif() + +# Install directory for all DPC++ compiler tools. Placing them under a +# versioned subdirectory avoids conflicts with a system LLVM installation. +set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") if(NOT DEFINED DPCPP_VERSION_MINOR) set(DPCPP_VERSION_MINOR 1) endif() diff --git a/libsycl/tools/sycl-ls/CMakeLists.txt b/libsycl/tools/sycl-ls/CMakeLists.txt index e34ba77c88c37..6d3d2026b4dbd 100644 --- a/libsycl/tools/sycl-ls/CMakeLists.txt +++ b/libsycl/tools/sycl-ls/CMakeLists.txt @@ -26,4 +26,4 @@ if (WIN32) target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900) endif() install(TARGETS sycl-ls - RUNTIME DESTINATION "bin" COMPONENT sycl-ls) + RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-ls) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index c4293873bab8e..ccf57efac3b3e 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -43,6 +43,12 @@ mark_as_advanced(LLVM_UNVERSIONED_LIBLTO_ON_DARWIN) include(${LLVM_COMMON_CMAKE_UTILS}/Modules/LLVMVersion.cmake) include(${LLVM_COMMON_CMAKE_UTILS}/Modules/DPCPPVersion.cmake) +# Redirect all compiler tools into the versioned DPC++ library directory so +# they don't conflict with a system LLVM installation. The public dpclang* +# entry-points in ${CMAKE_INSTALL_BINDIR} are added by clang/tools/driver. +set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "" FORCE) +set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) + set_directory_properties(PROPERTIES LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}") if (NOT PACKAGE_VERSION) diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt index a1cb33c6553b2..c717c103c4f43 100644 --- a/sycl/tools/sycl-ls/CMakeLists.txt +++ b/sycl/tools/sycl-ls/CMakeLists.txt @@ -26,4 +26,4 @@ if (WIN32) target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900) endif() install(TARGETS sycl-ls - RUNTIME DESTINATION "bin" COMPONENT sycl-ls) + RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-ls) diff --git a/sycl/tools/sycl-prof/CMakeLists.txt b/sycl/tools/sycl-prof/CMakeLists.txt index c37040614206c..9b320a6ba99ad 100644 --- a/sycl/tools/sycl-prof/CMakeLists.txt +++ b/sycl/tools/sycl-prof/CMakeLists.txt @@ -25,7 +25,7 @@ add_dependencies(sycl-toolchain sycl-prof) include(GNUInstallDirs) install(TARGETS sycl-prof sycl_profiler_collector - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-prof + RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-prof LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-prof ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-prof ) diff --git a/sycl/tools/sycl-sanitize/CMakeLists.txt b/sycl/tools/sycl-sanitize/CMakeLists.txt index 4a1e6e3c9cc93..acedec1d14d69 100644 --- a/sycl/tools/sycl-sanitize/CMakeLists.txt +++ b/sycl/tools/sycl-sanitize/CMakeLists.txt @@ -26,7 +26,7 @@ add_dependencies(sycl-toolchain sycl-sanitize) include(GNUInstallDirs) install(TARGETS sycl-sanitize sycl_sanitizer_collector - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-sanitize + RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-sanitize LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-sanitize ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-sanitize ) diff --git a/sycl/tools/sycl-trace/CMakeLists.txt b/sycl/tools/sycl-trace/CMakeLists.txt index f1e804dee0b91..cf79d3bc4da49 100644 --- a/sycl/tools/sycl-trace/CMakeLists.txt +++ b/sycl/tools/sycl-trace/CMakeLists.txt @@ -177,7 +177,7 @@ add_dependencies(sycl-toolchain sycl-trace) include(GNUInstallDirs) install(TARGETS sycl-trace sycl_ur_trace_collector ${EXTRA_TARGETS_TO_INSTALL} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-trace + RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-trace LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-trace ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-trace ) diff --git a/sycl/tools/syclbin-dump/CMakeLists.txt b/sycl/tools/syclbin-dump/CMakeLists.txt index d1eb71823f646..4ddffada834ca 100644 --- a/sycl/tools/syclbin-dump/CMakeLists.txt +++ b/sycl/tools/syclbin-dump/CMakeLists.txt @@ -22,4 +22,4 @@ endif() add_dependencies(sycl-toolchain syclbin-dump) install(TARGETS syclbin-dump - RUNTIME DESTINATION "bin" COMPONENT syclbin-dump) + RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT syclbin-dump) From a678dba1b13b2d77da24822364fe292ffc8ff6fb Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 21:32:08 +0200 Subject: [PATCH 04/48] Move sycl-ls back to install/bin folder --- sycl/tools/sycl-ls/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt index c717c103c4f43..a1cb33c6553b2 100644 --- a/sycl/tools/sycl-ls/CMakeLists.txt +++ b/sycl/tools/sycl-ls/CMakeLists.txt @@ -26,4 +26,4 @@ if (WIN32) target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900) endif() install(TARGETS sycl-ls - RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-ls) + RUNTIME DESTINATION "bin" COMPONENT sycl-ls) From 814058dcff22812024c77e418b8ee2cf808dcafa Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 21:38:41 +0200 Subject: [PATCH 05/48] Make it only for Linux` --- clang/tools/driver/CMakeLists.txt | 2 +- cmake/Modules/DPCPPVersion.cmake | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 3ea4c4bc93b80..23ab2597d2892 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -97,7 +97,7 @@ endforeach() # These versioned names avoid conflicts with a system LLVM installation while # the real binaries live in ${DPCPP_INSTALL_INTERNAL_BINDIR} alongside all companion # tools so that the driver can find them via its own executable path. -if(CLANG_BUILD_TOOLS) +if(CLANG_BUILD_TOOLS AND CMAKE_SYSTEM_NAME STREQUAL "Linux") # Ensure ${CMAKE_INSTALL_BINDIR} exists — no real binaries install there # anymore so it would otherwise never be created. install(DIRECTORY DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT clang) diff --git a/cmake/Modules/DPCPPVersion.cmake b/cmake/Modules/DPCPPVersion.cmake index e52c1068b4201..549cba130f90c 100644 --- a/cmake/Modules/DPCPPVersion.cmake +++ b/cmake/Modules/DPCPPVersion.cmake @@ -4,9 +4,14 @@ if(NOT DEFINED DPCPP_VERSION_MAJOR) set(DPCPP_VERSION_MAJOR 7) endif() -# Install directory for all DPC++ compiler tools. Placing them under a -# versioned subdirectory avoids conflicts with a system LLVM installation. -set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") +# Install directory for all DPC++ compiler tools. On Linux, tools are placed +# under a versioned subdirectory to avoid conflicts with a system LLVM +# installation. On other platforms the standard bin/ directory is used. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") +else() + set(DPCPP_INSTALL_INTERNAL_BINDIR "bin") +endif() if(NOT DEFINED DPCPP_VERSION_MINOR) set(DPCPP_VERSION_MINOR 1) endif() From e0be600518e9e463b853e9018c27d47318004698 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 22:55:04 +0200 Subject: [PATCH 06/48] Fix regressions + add a test --- cmake/Modules/DPCPPVersion.cmake | 8 -------- llvm/CMakeLists.txt | 28 ++++++++++++++++++++------ llvm/cmake/modules/AddLLVM.cmake | 17 +++++++++++++++- sycl/test/lit.cfg.py | 1 + sycl/test/lit.site.cfg.py.in | 1 + sycl/test/tools/dpclang-basic-sycl.cpp | 15 ++++++++++++++ 6 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 sycl/test/tools/dpclang-basic-sycl.cpp diff --git a/cmake/Modules/DPCPPVersion.cmake b/cmake/Modules/DPCPPVersion.cmake index 549cba130f90c..30d0029cb2b4e 100644 --- a/cmake/Modules/DPCPPVersion.cmake +++ b/cmake/Modules/DPCPPVersion.cmake @@ -4,14 +4,6 @@ if(NOT DEFINED DPCPP_VERSION_MAJOR) set(DPCPP_VERSION_MAJOR 7) endif() -# Install directory for all DPC++ compiler tools. On Linux, tools are placed -# under a versioned subdirectory to avoid conflicts with a system LLVM -# installation. On other platforms the standard bin/ directory is used. -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") -else() - set(DPCPP_INSTALL_INTERNAL_BINDIR "bin") -endif() if(NOT DEFINED DPCPP_VERSION_MINOR) set(DPCPP_VERSION_MINOR 1) endif() diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index ccf57efac3b3e..6a489305c5ada 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -43,12 +43,6 @@ mark_as_advanced(LLVM_UNVERSIONED_LIBLTO_ON_DARWIN) include(${LLVM_COMMON_CMAKE_UTILS}/Modules/LLVMVersion.cmake) include(${LLVM_COMMON_CMAKE_UTILS}/Modules/DPCPPVersion.cmake) -# Redirect all compiler tools into the versioned DPC++ library directory so -# they don't conflict with a system LLVM installation. The public dpclang* -# entry-points in ${CMAKE_INSTALL_BINDIR} are added by clang/tools/driver. -set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "" FORCE) -set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) - set_directory_properties(PROPERTIES LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}") if (NOT PACKAGE_VERSION) @@ -540,6 +534,28 @@ include(GNUInstallPackageDir) set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") +# Redirect all compiler tools into the versioned DPC++ library directory so +# they don't conflict with a system LLVM installation. The public dpclang* +# entry-points in ${CMAKE_INSTALL_BINDIR} are added by clang/tools/driver. +# This block must be after project() so that CMAKE_SYSTEM_NAME is defined. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") +else() + set(DPCPP_INSTALL_INTERNAL_BINDIR "bin") +endif() +set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "" FORCE) +set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) + +# Fix the clang resource directory path. The default is computed as +# dirname(binary)/../lib/clang/VERSION, which breaks when the binary lives in +# ${DPCPP_INSTALL_INTERNAL_BINDIR} instead of bin/. Compute the correct +# relative path from the internal bin dir to lib/clang/VERSION. +file(RELATIVE_PATH _clang_resource_dir + "/dummy/${DPCPP_INSTALL_INTERNAL_BINDIR}" + "/dummy/lib/clang/${LLVM_VERSION_MAJOR}") +set(CLANG_RESOURCE_DIR "${_clang_resource_dir}" CACHE STRING "" FORCE) +unset(_clang_resource_dir) + set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") mark_as_advanced(LLVM_TOOLS_INSTALL_DIR) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 28858db434f91..fe68d4a9d3c97 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2690,7 +2690,22 @@ function(llvm_setup_rpath name) set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) elseif(UNIX) set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) - set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") + # For executables installed in DPCPP_INSTALL_INTERNAL_BINDIR (Linux only), + # compute the relative path from that directory to the lib directory so + # the dynamic linker can find the shared libraries at runtime. + get_target_property(_target_type ${name} TYPE) + if(_target_type STREQUAL "EXECUTABLE" AND + CMAKE_SYSTEM_NAME STREQUAL "Linux" AND + DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) + file(RELATIVE_PATH _rpath_to_lib + "/dummy/${DPCPP_INSTALL_INTERNAL_BINDIR}" + "/dummy/lib${LLVM_LIBDIR_SUFFIX}") + set(_install_rpath "\$ORIGIN/${_rpath_to_lib}") + unset(_rpath_to_lib) + else() + set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") + endif() + unset(_target_type) if("${CMAKE_SYSTEM_NAME}" MATCHES "(FreeBSD|DragonFly)") set_property(TARGET ${name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-z,origin ") diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 368fe12063e7f..0d06b7c2a58f4 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -52,6 +52,7 @@ ) config.substitutions.append(("%python", '"%s"' % (sys.executable))) +config.substitutions.append(("%dpclangxx", os.path.join(config.install_bin_dir, "dpclang++"))) # Propagate extra environment variables if config.extra_environment: diff --git a/sycl/test/lit.site.cfg.py.in b/sycl/test/lit.site.cfg.py.in index 2d74880f2ff8a..d4c4fabec2563 100644 --- a/sycl/test/lit.site.cfg.py.in +++ b/sycl/test/lit.site.cfg.py.in @@ -24,6 +24,7 @@ config.sycl_clang_extra_flags = "@SYCL_CLANG_EXTRA_FLAGS@" config.test_include_path = "@TEST_INCLUDE_PATH@" config.llvm_enable_projects = "@LLVM_ENABLE_PROJECTS@" +config.install_bin_dir = "@CMAKE_INSTALL_PREFIX@/bin" config.sycl_threads_lib = '@SYCL_THREADS_LIB@' config.sycl_use_libcxx = 'ON' if @LLVM_LIBCXX_USED@ else 'OFF' diff --git a/sycl/test/tools/dpclang-basic-sycl.cpp b/sycl/test/tools/dpclang-basic-sycl.cpp new file mode 100644 index 0000000000000..012b1de1b7717 --- /dev/null +++ b/sycl/test/tools/dpclang-basic-sycl.cpp @@ -0,0 +1,15 @@ +// Verify that the dpclang++ binary can compile basic SYCL code. +// RUN: %dpclangxx -fsycl -fsycl-targets=%sycl_triple -I %sycl_include -c %s -o %t.o + +#include + +void test() { + sycl::queue q; + int result = 0; + sycl::buffer buf(&result, 1); + + q.submit([&](sycl::handler &h) { + sycl::accessor acc(buf, h, sycl::write_only); + h.single_task([=]() { acc[0] = 42; }); + }); +} From 4d91d11310552db29d3076b68dd5a9fad463f7fc Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 23:00:18 +0200 Subject: [PATCH 07/48] Small fix --- cmake/Modules/DPCPPVersion.cmake | 1 - libsycl/tools/sycl-ls/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/Modules/DPCPPVersion.cmake b/cmake/Modules/DPCPPVersion.cmake index 30d0029cb2b4e..7d0a7699929a1 100644 --- a/cmake/Modules/DPCPPVersion.cmake +++ b/cmake/Modules/DPCPPVersion.cmake @@ -3,7 +3,6 @@ if(NOT DEFINED DPCPP_VERSION_MAJOR) set(DPCPP_VERSION_MAJOR 7) endif() - if(NOT DEFINED DPCPP_VERSION_MINOR) set(DPCPP_VERSION_MINOR 1) endif() diff --git a/libsycl/tools/sycl-ls/CMakeLists.txt b/libsycl/tools/sycl-ls/CMakeLists.txt index 6d3d2026b4dbd..e34ba77c88c37 100644 --- a/libsycl/tools/sycl-ls/CMakeLists.txt +++ b/libsycl/tools/sycl-ls/CMakeLists.txt @@ -26,4 +26,4 @@ if (WIN32) target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900) endif() install(TARGETS sycl-ls - RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-ls) + RUNTIME DESTINATION "bin" COMPONENT sycl-ls) From 56207c8ca1137ac1f8d885ab80b85fc776f451fe Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 23:06:05 +0200 Subject: [PATCH 08/48] Fix formatting --- sycl/test/lit.cfg.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 0d06b7c2a58f4..2e47a94910012 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -52,7 +52,8 @@ ) config.substitutions.append(("%python", '"%s"' % (sys.executable))) -config.substitutions.append(("%dpclangxx", os.path.join(config.install_bin_dir, "dpclang++"))) +config.substitutions.append( + ("%dpclangxx", os.path.join(config.install_bin_dir, "dpclang++"))) # Propagate extra environment variables if config.extra_environment: From 81105710233040d210d98d247681464410071ab2 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 29 May 2026 23:12:35 +0200 Subject: [PATCH 09/48] Fix formatting --- sycl/test/lit.cfg.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 2e47a94910012..0d42b44ced22e 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -53,7 +53,8 @@ config.substitutions.append(("%python", '"%s"' % (sys.executable))) config.substitutions.append( - ("%dpclangxx", os.path.join(config.install_bin_dir, "dpclang++"))) + ("%dpclangxx", os.path.join(config.install_bin_dir, "dpclang++")) +) # Propagate extra environment variables if config.extra_environment: From 1b19d1317842880593a299009cc9c621bf2b2b20 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Wed, 3 Jun 2026 20:10:30 +0200 Subject: [PATCH 10/48] Update CI --- .github/workflows/sycl-linux-build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sycl-linux-build.yml b/.github/workflows/sycl-linux-build.yml index 87d93d4dbd9b3..830363e163795 100644 --- a/.github/workflows/sycl-linux-build.yml +++ b/.github/workflows/sycl-linux-build.yml @@ -326,7 +326,7 @@ jobs: testing_mode: build-only target_devices: all binaries_artifact: ${{ inputs.e2e_binaries_artifact }} - sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++ + sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/dpclang++ extra_lit_opts: --param sycl_build_targets="spir;nvidia" - name: Build E2E tests with NewOffloadModel @@ -341,7 +341,7 @@ jobs: testing_mode: build-only target_devices: all binaries_artifact: ${{ inputs.e2e_binaries_new_offload_model_artifact }} - sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++ + sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/dpclang++ extra_lit_opts: --param sycl_build_targets="spir;nvidia" --param enable_new_offload_model=True - name: Build E2E tests with SPIR-V Backend @@ -352,7 +352,7 @@ jobs: testing_mode: build-only target_devices: all binaries_artifact: ${{ inputs.e2e_binaries_spirv_backend_artifact }} - sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++ + sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/dpclang++ extra_lit_opts: --param spirv-backend=True - name: Build E2E tests in Preview Mode @@ -363,5 +363,5 @@ jobs: testing_mode: build-only target_devices: all binaries_artifact: ${{ inputs.e2e_binaries_preview_artifact }} - sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++ + sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/dpclang++ extra_lit_opts: --param test-preview-mode=True From 1139bebfe2ab6ed7490859d5423d4da1b5eb0e44 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 15 Jun 2026 12:15:04 +0200 Subject: [PATCH 11/48] Try to fix CI for Linux --- llvm/CMakeLists.txt | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 6a489305c5ada..b453053591d91 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -546,15 +546,25 @@ endif() set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "" FORCE) set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) -# Fix the clang resource directory path. The default is computed as -# dirname(binary)/../lib/clang/VERSION, which breaks when the binary lives in -# ${DPCPP_INSTALL_INTERNAL_BINDIR} instead of bin/. Compute the correct -# relative path from the internal bin dir to lib/clang/VERSION. -file(RELATIVE_PATH _clang_resource_dir - "/dummy/${DPCPP_INSTALL_INTERNAL_BINDIR}" - "/dummy/lib/clang/${LLVM_VERSION_MAJOR}") -set(CLANG_RESOURCE_DIR "${_clang_resource_dir}" CACHE STRING "" FORCE) -unset(_clang_resource_dir) +# The default resource-dir formula is: dirname(binary)/../lib/clang/VERSION. +# For binaries installed in lib/dpcpp-N/bin/ this resolves to +# lib/dpcpp-N/lib/clang/VERSION which is wrong. Installing a +# lib -> ../../lib symlink inside lib/dpcpp-N/ makes the formula resolve +# correctly without baking a path into the binary (which breaks build-tree +# tests). +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LLVM_USE_SYMLINKS) + cmake_path(GET DPCPP_INSTALL_INTERNAL_BINDIR PARENT_PATH _dpcpp_dir) + install(CODE " + set(DESTDIR \"\$ENV{DESTDIR}\") + set(_dir \"\${DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_dpcpp_dir}\") + if(NOT EXISTS \"\${_dir}/lib\") + execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink + ../../lib lib + WORKING_DIRECTORY \"\${_dir}\") + endif() + " COMPONENT clang) + unset(_dpcpp_dir) +endif() set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") From fc08eb4d84dd697a186cb6009090a00e3585d472 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 15 Jun 2026 13:32:38 +0200 Subject: [PATCH 12/48] Fix CI on Linux --- .github/workflows/sycl-linux-precommit.yml | 2 +- .github/workflows/sycl-linux-run-tests.yml | 2 +- .github/workflows/sycl-yarpgen.yml | 2 +- clang/tools/driver/CMakeLists.txt | 5 +++++ sycl/test/lit.site.cfg.py.in | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sycl-linux-precommit.yml b/.github/workflows/sycl-linux-precommit.yml index 6c38b8b7b95a1..523611829e5c7 100644 --- a/.github/workflows/sycl-linux-precommit.yml +++ b/.github/workflows/sycl-linux-precommit.yml @@ -100,7 +100,7 @@ jobs: ref: ${{ github.ref || github.sha }} testing_mode: full target_devices: native_cpu:cpu - sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++ + sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/dpclang++ extra_lit_opts: --param sycl_build_targets="native_cpu" extra_cmake_args: -DSYCL_TEST_E2E_TARGETS="native_cpu:cpu" -DSYCL_TEST_E2E_STANDALONE=ON diff --git a/.github/workflows/sycl-linux-run-tests.yml b/.github/workflows/sycl-linux-run-tests.yml index 528772589c01d..7b141392c5e57 100644 --- a/.github/workflows/sycl-linux-run-tests.yml +++ b/.github/workflows/sycl-linux-run-tests.yml @@ -321,7 +321,7 @@ jobs: tar xf sycl_linux.tar.gz -C toolchain echo PATH=$PWD/toolchain/bin/:$PATH >> $GITHUB_ENV echo LD_LIBRARY_PATH=$PWD/toolchain/lib/:$LD_LIBRARY_PATH >> $GITHUB_ENV - - run: which clang++ sycl-ls + - run: which dpclang++ sycl-ls - run: sycl-ls --verbose - run: SYCL_UR_TRACE=1 sycl-ls - name: Print IGC version diff --git a/.github/workflows/sycl-yarpgen.yml b/.github/workflows/sycl-yarpgen.yml index c7f840b1b966c..985c2d3932b6a 100644 --- a/.github/workflows/sycl-yarpgen.yml +++ b/.github/workflows/sycl-yarpgen.yml @@ -58,7 +58,7 @@ jobs: echo PATH=$PWD/toolchain/bin/:$PATH >> $GITHUB_ENV echo LD_LIBRARY_PATH=$PWD/toolchain/lib/:$LD_LIBRARY_PATH >> $GITHUB_ENV - - run: which clang++ + - run: which dpclang++ - run: sycl-ls diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 23ab2597d2892..d0ee9e5c70d89 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -93,6 +93,11 @@ foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK}) add_clang_symlink(${link} clang) endforeach() +# Create dpclang++ build-tree symlink so tests can use it without installing. +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + add_clang_symlink(dpclang++ clang) +endif() + # Install public dpclang* symlinks in ${CMAKE_INSTALL_BINDIR}. # These versioned names avoid conflicts with a system LLVM installation while # the real binaries live in ${DPCPP_INSTALL_INTERNAL_BINDIR} alongside all companion diff --git a/sycl/test/lit.site.cfg.py.in b/sycl/test/lit.site.cfg.py.in index d4c4fabec2563..2b83023d9f272 100644 --- a/sycl/test/lit.site.cfg.py.in +++ b/sycl/test/lit.site.cfg.py.in @@ -24,7 +24,7 @@ config.sycl_clang_extra_flags = "@SYCL_CLANG_EXTRA_FLAGS@" config.test_include_path = "@TEST_INCLUDE_PATH@" config.llvm_enable_projects = "@LLVM_ENABLE_PROJECTS@" -config.install_bin_dir = "@CMAKE_INSTALL_PREFIX@/bin" +config.install_bin_dir = "@LLVM_TOOLS_DIR@" config.sycl_threads_lib = '@SYCL_THREADS_LIB@' config.sycl_use_libcxx = 'ON' if @LLVM_LIBCXX_USED@ else 'OFF' From 417df3dc9bbea263b4ee9f2a91947545a88b8a69 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 15 Jun 2026 14:55:20 +0200 Subject: [PATCH 13/48] Fix CI --- clang/lib/Driver/ToolChains/SYCL.cpp | 59 +++++++++++++------ devops/actions/run-tests/linux/cts/action.yml | 8 ++- llvm/CMakeLists.txt | 9 ++- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 313fc4bc683a0..b4e0452c63631 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -31,27 +31,49 @@ SYCLInstallationDetector::SYCLInstallationDetector( // 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); - SmallString<128> LibPath(DriverDir); - llvm::sys::path::append(LibPath, "..", "lib", HostTriple.str(), - "libsycl.so"); + + // The binary may live in a versioned subdirectory (e.g. lib/dpcpp-N/bin/) + // rather than directly in bin/. Walk up from D.Dir until we find a + // directory that looks like the install root (contains include/sycl or + // lib/clang), falling back to D.Dir/.. if nothing is found. + SmallString<128> InstallRoot(D.Dir); + for (int Depth = 0; Depth < 4; ++Depth) { + SmallString<128> Probe(InstallRoot); + llvm::sys::path::append(Probe, "..", "include", "sycl"); + llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); + if (D.getVFS().exists(Probe)) { + llvm::sys::path::append(InstallRoot, ".."); + llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); + break; + } + llvm::sys::path::append(InstallRoot, ".."); + llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); + } + + SmallString<128> DriverDir(InstallRoot); + SmallString<128> LibPath(InstallRoot); + llvm::sys::path::append(LibPath, "lib", HostTriple.str(), "libsycl.so"); // Flat lib path for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF builds, // where the library is installed directly in lib/ with no triple subdir. - SmallString<128> FlatLibPath(DriverDir); - llvm::sys::path::append(FlatLibPath, "..", "lib", "libsycl.so"); + SmallString<128> FlatLibPath(InstallRoot); + llvm::sys::path::append(FlatLibPath, "lib", "libsycl.so"); - if (DriverDir.starts_with(SysRoot) && + if (InstallRoot.starts_with(SysRoot) && Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in lib// - if (D.getVFS().exists(LibPath)) - llvm::sys::path::append(DriverDir, "..", "lib", HostTriple.str()); + if (D.getVFS().exists(LibPath)) { + DriverDir = InstallRoot; + llvm::sys::path::append(DriverDir, "lib", HostTriple.str()); + } // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF: library is in lib/ - else if (D.getVFS().exists(FlatLibPath)) - llvm::sys::path::append(DriverDir, "..", "lib"); - if (!DriverDir.equals(D.Dir)) + else if (D.getVFS().exists(FlatLibPath)) { + DriverDir = InstallRoot; + llvm::sys::path::append(DriverDir, "lib"); + } + if (!DriverDir.equals(InstallRoot)) SYCLRTLibPath = DriverDir; } - InstallationCandidates.emplace_back(D.Dir + "/.."); + InstallationCandidates.emplace_back(InstallRoot); } static llvm::SmallString<64> @@ -142,10 +164,13 @@ void SYCLInstallationDetector::addSYCLIncludeArgs( return; } // Add the SYCL header search locations in the specified order. - // ../include/sycl/stl_wrappers - // ../include - SmallString<128> IncludePath(D.Dir); - llvm::sys::path::append(IncludePath, ".."); + // /include/sycl/stl_wrappers + // /include + // Use the install root from InstallationCandidates (which already accounts + // for versioned binary subdirectories like lib/dpcpp-N/bin/). + SmallString<128> IncludePath(InstallationCandidates.empty() + ? StringRef(D.Dir + "/..") + : StringRef(InstallationCandidates[0])); llvm::sys::path::append(IncludePath, "include"); // This is used to provide our wrappers around STL headers that provide // additional functions/template specializations when the user includes those diff --git a/devops/actions/run-tests/linux/cts/action.yml b/devops/actions/run-tests/linux/cts/action.yml index f42da162fa315..c43fa710f5f98 100644 --- a/devops/actions/run-tests/linux/cts/action.yml +++ b/devops/actions/run-tests/linux/cts/action.yml @@ -14,6 +14,10 @@ inputs: required: true retention-days: required: false + sycl_compiler: + description: "Path to the SYCL compiler (dpclang++). Defaults to 'dpclang++' found in PATH." + required: false + default: "$(which dpclang++)" runs: using: "composite" @@ -56,11 +60,11 @@ runs: echo "::endgroup::" fi - cmake -GNinja -B./build-cts -S./khronos_sycl_cts -DCMAKE_CXX_COMPILER=$(which clang++) \ + cmake -GNinja -B./build-cts -S./khronos_sycl_cts -DCMAKE_CXX_COMPILER="${{ inputs.sycl_compiler }}" \ -DSYCL_IMPLEMENTATION=DPCPP \ -DSYCL_CTS_EXCLUDE_TEST_CATEGORIES="$cts_exclude_filter" \ -DSYCL_CTS_ENABLE_OPENCL_INTEROP_TESTS=OFF \ - -DDPCPP_INSTALL_DIR="$(dirname $(which clang++))/.." \ + -DDPCPP_INSTALL_DIR="$(dirname ${{ inputs.sycl_compiler }})/.." \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ $CMAKE_EXTRA_ARGS # Ignore errors so that if one category build fails others still have a diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index b453053591d91..2f7c768c87afb 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -547,11 +547,10 @@ set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "" FO set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) # The default resource-dir formula is: dirname(binary)/../lib/clang/VERSION. -# For binaries installed in lib/dpcpp-N/bin/ this resolves to -# lib/dpcpp-N/lib/clang/VERSION which is wrong. Installing a -# lib -> ../../lib symlink inside lib/dpcpp-N/ makes the formula resolve -# correctly without baking a path into the binary (which breaks build-tree -# tests). +# For binaries installed in lib/dpcpp-N/bin/ this resolves inside lib/dpcpp-N/ +# instead of the install root. Installing a lib -> ../../lib symlink inside +# lib/dpcpp-N/ makes the formula resolve correctly without baking a path into +# the binary (which breaks build-tree tests). if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LLVM_USE_SYMLINKS) cmake_path(GET DPCPP_INSTALL_INTERNAL_BINDIR PARENT_PATH _dpcpp_dir) install(CODE " From 8b44d373886a5018044b1aa0862489946730c672 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 15 Jun 2026 15:03:19 +0200 Subject: [PATCH 14/48] Fix merge conflict` --- clang/lib/Driver/ToolChains/SYCL.cpp | 53 ++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index b4e0452c63631..9a89b0284b47f 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -34,8 +34,8 @@ SYCLInstallationDetector::SYCLInstallationDetector( // The binary may live in a versioned subdirectory (e.g. lib/dpcpp-N/bin/) // rather than directly in bin/. Walk up from D.Dir until we find a - // directory that looks like the install root (contains include/sycl or - // lib/clang), falling back to D.Dir/.. if nothing is found. + // directory that looks like the install root (contains include/sycl), + // falling back to D.Dir/.. if nothing is found. SmallString<128> InstallRoot(D.Dir); for (int Depth = 0; Depth < 4; ++Depth) { SmallString<128> Probe(InstallRoot); @@ -51,6 +51,54 @@ SYCLInstallationDetector::SYCLInstallationDetector( } SmallString<128> DriverDir(InstallRoot); + +#if 0 // !INTEL_CUSTOMIZATION + if (HostTriple.isWindowsMSVCEnvironment() || + HostTriple.isWindowsItaniumEnvironment()) { + // Windows: Check for LLVMSYCL.lib + // NOTE: Only checks for LLVMSYCL.lib existence (release variant). + // Debug vs release library selection happens at link time based on CRT + // flags. + if (InstallRoot.starts_with(SysRoot) && + Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { + SmallString<128> LibDir(InstallRoot); + llvm::sys::path::append(LibDir, "lib"); + + // Verify SYCL runtime library exists + SmallString<128> SYCLLibPath(LibDir); + llvm::sys::path::append(SYCLLibPath, "LLVMSYCL.lib"); + + if (D.getVFS().exists(SYCLLibPath)) + SYCLRTLibPath = LibDir; + } + } else { + SmallString<128> LibPath(InstallRoot); + llvm::sys::path::append(LibPath, "lib", HostTriple.str(), "libsycl.so"); + // Flat lib path for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF builds, + // where the library is installed directly in lib/ with no triple subdir. + SmallString<128> FlatLibPath(InstallRoot); + llvm::sys::path::append(FlatLibPath, "lib", "libsycl.so"); + + if (InstallRoot.starts_with(SysRoot) && + Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { + // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in lib// + if (D.getVFS().exists(LibPath)) { + DriverDir = InstallRoot; + llvm::sys::path::append(DriverDir, "lib", HostTriple.str()); + } + // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF: library is in lib/ + else if (D.getVFS().exists(FlatLibPath)) { + DriverDir = InstallRoot; + llvm::sys::path::append(DriverDir, "lib"); + } else + return; // Neither path exists: broken install, leave SYCLRTLibPath + // unset + + SYCLRTLibPath = DriverDir; + } + } +#else // !INTEL_CUSTOMIZATION + // Intel: SYCL RT is libsycl.so; Windows lib path is handled at link stage. SmallString<128> LibPath(InstallRoot); llvm::sys::path::append(LibPath, "lib", HostTriple.str(), "libsycl.so"); // Flat lib path for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF builds, @@ -73,6 +121,7 @@ SYCLInstallationDetector::SYCLInstallationDetector( if (!DriverDir.equals(InstallRoot)) SYCLRTLibPath = DriverDir; } +#endif // !INTEL_CUSTOMIZATION InstallationCandidates.emplace_back(InstallRoot); } From 44c1954654874db3af3e97e619c6a9e6346321b3 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 16 Jun 2026 18:00:10 +0200 Subject: [PATCH 15/48] Try to fix CI --- clang/test/Driver/sycl-device-old-model.cpp | 2 +- clang/test/Driver/sycl-device.cpp | 2 +- clang/test/Driver/sycl-offload-jit.cpp | 4 ++-- clang/test/Driver/sycl-offload-nvptx.cpp | 4 ++-- clang/test/Driver/sycl-offload-old-model.cpp | 8 ++++---- clang/test/Driver/sycl-offload.cpp | 8 ++++---- clang/test/Driver/sycl.cpp | 6 +++--- clang/tools/driver/CMakeLists.txt | 2 +- devops/actions/run-tests/linux/cts/action.yml | 8 ++------ llvm/CMakeLists.txt | 14 ++++++++------ 10 files changed, 28 insertions(+), 30 deletions(-) diff --git a/clang/test/Driver/sycl-device-old-model.cpp b/clang/test/Driver/sycl-device-old-model.cpp index 8fc8bfb86f929..6353e787127ab 100644 --- a/clang/test/Driver/sycl-device-old-model.cpp +++ b/clang/test/Driver/sycl-device-old-model.cpp @@ -6,7 +6,7 @@ /// Check "-fsycl-is-device" is passed when compiling for device: // RUN: %clang -### -fsycl-device-only --no-offload-new-driver %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s -// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{[^"]*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{[^"]*}}include" /// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl" /// or "-fsycl-device-only" or both: diff --git a/clang/test/Driver/sycl-device.cpp b/clang/test/Driver/sycl-device.cpp index 8013b64d7386f..3098bb8603bc0 100644 --- a/clang/test/Driver/sycl-device.cpp +++ b/clang/test/Driver/sycl-device.cpp @@ -8,7 +8,7 @@ // RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s // RUN: %clang -### --config=%S/Inputs/empty.cfg -fsycl-device-only %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s -// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{.*}}include" /// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl" /// or "-fsycl-device-only" or both: diff --git a/clang/test/Driver/sycl-offload-jit.cpp b/clang/test/Driver/sycl-offload-jit.cpp index 89f064acc4a04..a77d1154f3ae4 100644 --- a/clang/test/Driver/sycl-offload-jit.cpp +++ b/clang/test/Driver/sycl-offload-jit.cpp @@ -33,8 +33,8 @@ // The test also checks if SYCL header include paths are added to the SYCL host and device compilation. // INTEL-RUN: %clang --offload-new-driver --sysroot=%S/Inputs/SYCL -### --target=x86_64-unknown-linux-gnu -fsycl %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK-LSYCL,CHECK-SYCL-HEADERS-HOST,CHECK-SYCL-HEADERS-DEVICE %s -// CHECK-SYCL-HEADERS-DEVICE: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" -// CHECK-SYCL-HEADERS-HOST: "-fsycl-is-host"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-SYCL-HEADERS-DEVICE: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}include" +// CHECK-SYCL-HEADERS-HOST: "-fsycl-is-host"{{.*}} "-internal-isystem" "{{.*}}include" // CHECK-LSYCL: clang-linker-wrapper{{.*}} "{{.*}}libsycl.so" // Check that -fsycl -fno-sycl does not pass libsycl.so to the linker. // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -fno-sycl %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload-nvptx.cpp b/clang/test/Driver/sycl-offload-nvptx.cpp index 4a976d391f64f..c3d063468ffeb 100644 --- a/clang/test/Driver/sycl-offload-nvptx.cpp +++ b/clang/test/Driver/sycl-offload-nvptx.cpp @@ -15,7 +15,7 @@ // RUN: -resource-dir %{resource_dir} %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-ACTIONS-WIN %s -// CHK-ACTIONS: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l64.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} "-std=c++17"{{.*}} +// CHK-ACTIONS: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l64.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} "-std=c++17"{{.*}} // CHK-ACTIONS: sycl-post-link // CHK-ACTIONS-NOT: -split // CHK-ACTIONS-SAME: -o @@ -27,7 +27,7 @@ // CHK-ACTIONS-NOT: "-mllvm -sycl-opt" // CHK-ACTIONS: clang-offload-wrapper"{{.*}} "-host=x86_64-unknown-linux-gnu" "-target=nvptx64" "-kind=sycl"{{.*}} -// CHK-ACTIONS-WIN: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-pc-windows-msvc"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l32.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} +// CHK-ACTIONS-WIN: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-pc-windows-msvc"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l32.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} // CHK-ACTIONS-WIN: sycl-post-link // CHK-ACTIONS-WIN-NOT: -split // CHK-ACTIONS-WIN-SAME: -o diff --git a/clang/test/Driver/sycl-offload-old-model.cpp b/clang/test/Driver/sycl-offload-old-model.cpp index edd69cc9aae40..0ba5072d45e05 100644 --- a/clang/test/Driver/sycl-offload-old-model.cpp +++ b/clang/test/Driver/sycl-offload-old-model.cpp @@ -856,13 +856,13 @@ // RUN: %clang -### -fsycl --no-offload-new-driver %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // RUN: %clang_cl -### -fsycl --no-offload-new-driver %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-device" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-host" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" /// Check for option incompatibility with -fsycl // RUN: not %clang -### -fsycl --no-offload-new-driver -ffreestanding %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload.cpp b/clang/test/Driver/sycl-offload.cpp index 44cf684999acc..d0fc782201603 100644 --- a/clang/test/Driver/sycl-offload.cpp +++ b/clang/test/Driver/sycl-offload.cpp @@ -544,13 +544,13 @@ // RUN: %clang -### -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // RUN: %clang_cl -### -fsycl --offload-new-driver /clang:--sysroot=%S/Inputs/SYCL %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-device" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-host" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" /// Check for option incompatibility with -fsycl // RUN: not %clang -### -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -ffreestanding %s 2>&1 \ diff --git a/clang/test/Driver/sycl.cpp b/clang/test/Driver/sycl.cpp index abf549dea1714..a4235bd351329 100644 --- a/clang/test/Driver/sycl.cpp +++ b/clang/test/Driver/sycl.cpp @@ -13,7 +13,7 @@ // ENABLED: "-cc1"{{.*}} "-fsycl-is-device" // ENABLED-SAME: "-sycl-std={{[-.sycl0-9]+}}" -// ENABLED-SAME: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// ENABLED-SAME: "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // NOT_ENABLED-NOT: "-fsycl-is-device" // NOT_ENABLED-NOT: "-fsycl-std-layout-kernel-params" @@ -44,7 +44,7 @@ // RUN: %clang_cl -### --target=i386-pc-windows-msvc -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT -DSPIRARCH=spir // DEFAULT: "-triple" "[[SPIRARCH]]-unknown-{{.*}}"{{.*}} "-fsycl-is-device"{{.*}} "-sycl-std=2020"{{.*}} "-emit-llvm-bc" -// DEFAULT: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// DEFAULT: "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // DEFAULT: "-internal-isystem" "{{.*lib.*clang.*include}}" // DEFAULT: "-std=c++17" // DEFAULT-NOT: "{{.*}}llvm-spirv"{{.*}} @@ -87,7 +87,7 @@ // RUN: %clangxx -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=HEADER-ORDER // RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=HEADER-ORDER // HEADER-ORDER-NOT: clang{{.*}} "/usr/include" -// HEADER-ORDER: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// HEADER-ORDER: "-internal-isystem" "{{.*}}include" /// Verify -fsycl-device-only phases // RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT-PHASES diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index d0ee9e5c70d89..014df665720a5 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -95,7 +95,7 @@ endforeach() # Create dpclang++ build-tree symlink so tests can use it without installing. if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - add_clang_symlink(dpclang++ clang) + llvm_add_tool_symlink(CLANG dpclang++ clang ALWAYS_GENERATE) endif() # Install public dpclang* symlinks in ${CMAKE_INSTALL_BINDIR}. diff --git a/devops/actions/run-tests/linux/cts/action.yml b/devops/actions/run-tests/linux/cts/action.yml index c43fa710f5f98..c6bbbd01bb157 100644 --- a/devops/actions/run-tests/linux/cts/action.yml +++ b/devops/actions/run-tests/linux/cts/action.yml @@ -14,10 +14,6 @@ inputs: required: true retention-days: required: false - sycl_compiler: - description: "Path to the SYCL compiler (dpclang++). Defaults to 'dpclang++' found in PATH." - required: false - default: "$(which dpclang++)" runs: using: "composite" @@ -60,11 +56,11 @@ runs: echo "::endgroup::" fi - cmake -GNinja -B./build-cts -S./khronos_sycl_cts -DCMAKE_CXX_COMPILER="${{ inputs.sycl_compiler }}" \ + cmake -GNinja -B./build-cts -S./khronos_sycl_cts -DCMAKE_CXX_COMPILER="$(which dpclang++)" \ -DSYCL_IMPLEMENTATION=DPCPP \ -DSYCL_CTS_EXCLUDE_TEST_CATEGORIES="$cts_exclude_filter" \ -DSYCL_CTS_ENABLE_OPENCL_INTEROP_TESTS=OFF \ - -DDPCPP_INSTALL_DIR="$(dirname ${{ inputs.sycl_compiler }})/.." \ + -DDPCPP_INSTALL_DIR="$(dirname $(which dpclang++))/.." \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ $CMAKE_EXTRA_ARGS # Ignore errors so that if one category build fails others still have a diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 1d5bb0b8f3f7d..499cb5f4d857b 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -548,18 +548,20 @@ set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FOR # The default resource-dir formula is: dirname(binary)/../lib/clang/VERSION. # For binaries installed in lib/dpcpp-N/bin/ this resolves inside lib/dpcpp-N/ -# instead of the install root. Installing a lib -> ../../lib symlink inside -# lib/dpcpp-N/ makes the formula resolve correctly without baking a path into -# the binary (which breaks build-tree tests). +# instead of the install root. Installing a lib/clang -> ../../../lib/clang +# symlink inside lib/dpcpp-N/ makes the formula resolve correctly. +# We symlink only lib/clang (not the whole lib/) to avoid exposing +# lib/dpcpp-N/lib/dpcpp-N which is confusing and wrong-looking. if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LLVM_USE_SYMLINKS) cmake_path(GET DPCPP_INSTALL_INTERNAL_BINDIR PARENT_PATH _dpcpp_dir) install(CODE " set(DESTDIR \"\$ENV{DESTDIR}\") set(_dir \"\${DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_dpcpp_dir}\") - if(NOT EXISTS \"\${_dir}/lib\") + file(MAKE_DIRECTORY \"\${_dir}/lib\") + if(NOT EXISTS \"\${_dir}/lib/clang\") execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink - ../../lib lib - WORKING_DIRECTORY \"\${_dir}\") + ../../../lib/clang clang + WORKING_DIRECTORY \"\${_dir}/lib\") endif() " COMPONENT clang) unset(_dpcpp_dir) From 9887a91873350d2130e8329de7b638f0054027d1 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 16 Jun 2026 18:45:50 +0200 Subject: [PATCH 16/48] Try to fix CI --- clang/lib/Driver/ToolChains/Linux.cpp | 31 +++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index c01c76cc22550..4fc82c71551ea 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -382,10 +382,33 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs // libc++.so in D.Dir+"/../lib/". Detect this path. // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported. - if (StringRef(D.Dir).starts_with(SysRoot) && - (Args.hasArg(options::OPT_fsycl) || - D.getVFS().exists(D.Dir + "/../lib/libsycl.so"))) - addPathIfExists(D, D.Dir + "/../lib", Paths); + // Also handles the SYCL runtime library: when binaries live in a versioned + // subdirectory (e.g. lib/dpcpp-N/bin/) walk up to find the install root that + // contains lib/libsycl.so rather than assuming D.Dir/../lib. + { + SmallString<128> SYCLRoot(D.Dir); + for (int I = 0; I < 4; ++I) { + SmallString<128> Probe(SYCLRoot); + llvm::sys::path::append(Probe, "..", "include", "sycl"); + llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); + if (D.getVFS().exists(Probe)) { + llvm::sys::path::append(SYCLRoot, ".."); + llvm::sys::path::remove_dots(SYCLRoot, /*remove_dot_dot=*/true); + break; + } + llvm::sys::path::append(SYCLRoot, ".."); + llvm::sys::path::remove_dots(SYCLRoot, /*remove_dot_dot=*/true); + } + SmallString<128> SYCLLibProbe(SYCLRoot); + llvm::sys::path::append(SYCLLibProbe, "lib", "libsycl.so"); + if (StringRef(SYCLRoot).starts_with(SysRoot) && + (Args.hasArg(options::OPT_fsycl) || + D.getVFS().exists(SYCLLibProbe))) { + SmallString<128> SYCLLib(SYCLRoot); + llvm::sys::path::append(SYCLLib, "lib"); + addPathIfExists(D, SYCLLib, Paths); + } + } addPathIfExists(D, concat(SysRoot, "/lib"), Paths); addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths); From 079ce50ff08e8e29200ccfd64ba57af4d8d93592 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Wed, 17 Jun 2026 16:36:39 +0200 Subject: [PATCH 17/48] Fix CI --- .../clang/Driver/SyclInstallationDetector.h | 4 ++++ clang/lib/Driver/ToolChains/Clang.cpp | 19 +++++++++++++++++-- .../Driver/sycl-host-compiler-old-model.cpp | 12 ++++++------ clang/test/Driver/sycl-host-compiler.cpp | 12 ++++++------ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/clang/include/clang/Driver/SyclInstallationDetector.h b/clang/include/clang/Driver/SyclInstallationDetector.h index 75b83e873020e..0feadd4e1c96d 100644 --- a/clang/include/clang/Driver/SyclInstallationDetector.h +++ b/clang/include/clang/Driver/SyclInstallationDetector.h @@ -38,6 +38,10 @@ class SYCLInstallationDetector { // Return the filesystem path to the detected SYCL runtime library. StringRef getSYCLRTLibPath() const { return SYCLRTLibPath; } + // Return the install root (the directory containing include/ and lib/). + StringRef getInstallRoot() const { + return InstallationCandidates.empty() ? StringRef() : StringRef(InstallationCandidates[0]); + } void print(llvm::raw_ostream &OS) const; private: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 76e131a86701b..459e209e3b088 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5208,8 +5208,23 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA, if (!TCArgs.hasArg(options::OPT_nostdlibinc, options::OPT_nostdinc)) { // Add default header search directories. - SmallString<128> BaseDir(C.getDriver().Dir); - llvm::sys::path::append(BaseDir, "..", "include"); + // The binary may live in a versioned subdirectory (e.g. lib/dpcpp-N/bin/). + // Walk up from D.Dir until we find the install root (contains include/sycl). + SmallString<128> InstallRoot(C.getDriver().Dir); + for (int I = 0; I < 4; ++I) { + SmallString<128> Probe(InstallRoot); + llvm::sys::path::append(Probe, "..", "include", "sycl"); + llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); + if (C.getDriver().getVFS().exists(Probe)) { + llvm::sys::path::append(InstallRoot, ".."); + llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); + break; + } + llvm::sys::path::append(InstallRoot, ".."); + llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); + } + SmallString<128> BaseDir(InstallRoot); + llvm::sys::path::append(BaseDir, "include"); SmallString<128> SYCLDir(BaseDir); llvm::sys::path::append(SYCLDir, "sycl"); // This is used to provide our wrappers around STL headers that provide diff --git a/clang/test/Driver/sycl-host-compiler-old-model.cpp b/clang/test/Driver/sycl-host-compiler-old-model.cpp index fb9af06364295..1ec1f2327595d 100644 --- a/clang/test/Driver/sycl-host-compiler-old-model.cpp +++ b/clang/test/Driver/sycl-host-compiler-old-model.cpp @@ -6,9 +6,9 @@ // HOST_COMPILER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}" // HOST_COMPILER: g++{{.*}} "-c" "-include" "[[INTHEADER]]" // HOST_COMPILER-SAME: "-iquote" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}include" // HOST_COMPILER-SAME: "-o" "[[HOSTOBJ:.+\.o]]" // HOST_COMPILER: ld{{.*}} "[[HOSTOBJ]]" @@ -17,9 +17,9 @@ // HOST_COMPILER_CL: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}" // HOST_COMPILER_CL: cl{{.*}} "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]" // HOST_COMPILER_CL-SAME: "/external:W0" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include" // HOST_COMPILER_CL: link{{.*}} "[[HOSTOBJ]]" /// check for additional host options diff --git a/clang/test/Driver/sycl-host-compiler.cpp b/clang/test/Driver/sycl-host-compiler.cpp index 477ee562864cc..c68987249a7d9 100644 --- a/clang/test/Driver/sycl-host-compiler.cpp +++ b/clang/test/Driver/sycl-host-compiler.cpp @@ -12,9 +12,9 @@ // HOST_COMPILER: g++{{.*}} "[[APPENDFILESRC]]" // HOST_COMPILER-SAME: "-c" "-include" "[[INTHEADER]]" // HOST_COMPILER-SAME: "-iquote" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}include" // HOST_COMPILER-SAME: "-o" "[[HOSTOBJ:.+\.o]]" // HOST_COMPILER: clang-offload-bundler{{.*}} "-output=[[BUNDLEOBJ:.+\.o]]" "-input=[[DEVICEBC]]" "-input=[[HOSTOBJ]]" // HOST_COMPILER: clang-linker-wrapper{{.*}} "[[BUNDLEOBJ]]" @@ -29,9 +29,9 @@ // HOST_COMPILER_CL: cl{{.*}} "[[APPENDFILESRC]]" // HOST_COMPILER_CL-SAME: "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]" // HOST_COMPILER_CL-SAME: "/external:W0" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include" // HOST_COMPILER_CL: clang-offload-bundler{{.*}} "-output=[[BUNDLEOBJ:.+\.obj]]" "-input=[[DEVICEBC]]" "-input=[[HOSTOBJ]]" // HOST_COMPILER_CL: clang-linker-wrapper{{.*}} "[[BUNDLEOBJ]]" From 984b2e4317df7f99e17f58a67fb9aae4dcc7f698 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Wed, 17 Jun 2026 18:23:38 +0200 Subject: [PATCH 18/48] Fix CI --- sycl/test-e2e/lit.site.cfg.py.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index 04736673a3177..56c13f6fb991e 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -14,12 +14,14 @@ config.dpcpp_bin_dir = os.path.join(config.dpcpp_root_dir, 'bin') def get_dpcpp_tool_path(name): try: - return subprocess.check_output([config.dpcpp_compiler, "-print-prog-name=" + name], text=True) + return subprocess.check_output([config.dpcpp_compiler, "-print-prog-name=" + name], text=True).strip() except subprocess.CalledProcessError: return os.path.join(config.dpcpp_bin_dir, name) config.llvm_main_include_dir = "@LLVM_MAIN_INCLUDE_DIR@" -config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-config")) +# Use llvm-link (always in SYCL_TOOLCHAIN_DEPLOY_COMPONENTS) to find the +# internal tools directory. llvm-config is not always deployed there. +config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-link")) config.lit_tools_dir = os.path.dirname("@TEST_SUITE_LIT@") config.dump_ir_supported = lit_config.params.get("dump_ir", ("@DUMP_IR_SUPPORTED@" if "@DUMP_IR_SUPPORTED@" else False)) config.sycl_tools_dir = config.llvm_tools_dir From 42408f31c62f018ae9cc54e7dd3d59972ae9824e Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Thu, 18 Jun 2026 14:19:00 +0200 Subject: [PATCH 19/48] Update CI config --- devops/actions/run-tests/linux/e2e/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devops/actions/run-tests/linux/e2e/action.yml b/devops/actions/run-tests/linux/e2e/action.yml index 625d120fbb15a..c9f11c5324694 100644 --- a/devops/actions/run-tests/linux/e2e/action.yml +++ b/devops/actions/run-tests/linux/e2e/action.yml @@ -66,7 +66,7 @@ runs: if: inputs.testing_mode != 'run-only' shell: bash run: | - cmake -GNinja -B./build-e2e -S./llvm/sycl/test-e2e -DCMAKE_CXX_COMPILER="${{ inputs.sycl_compiler || '$(which clang++)'}}" -DLLVM_LIT="$PWD/llvm/llvm/utils/lit/lit.py" ${{ steps.cmake_opts.outputs.opts }} + cmake -GNinja -B./build-e2e -S./llvm/sycl/test-e2e -DCMAKE_CXX_COMPILER="${{ inputs.sycl_compiler || '$(which dpclang++)'}}" -DLLVM_LIT="$PWD/llvm/llvm/utils/lit/lit.py" ${{ steps.cmake_opts.outputs.opts }} - name: SYCL End-to-end tests id: run_e2e continue-on-error: true From 0623bae865068c86215d75d74c0e1b96b797fe1b Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Thu, 18 Jun 2026 15:27:45 +0200 Subject: [PATCH 20/48] Try to fix failures on Windows --- .../test/Driver/sycl-offload-header-check.cpp | 2 +- clang/tools/driver/CMakeLists.txt | 74 +++++++++++-------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/clang/test/Driver/sycl-offload-header-check.cpp b/clang/test/Driver/sycl-offload-header-check.cpp index 43f03d56a064e..3789faffae5f6 100644 --- a/clang/test/Driver/sycl-offload-header-check.cpp +++ b/clang/test/Driver/sycl-offload-header-check.cpp @@ -10,6 +10,6 @@ // RUN: %clang -### -fsycl %s 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-HEADER %s // CHECK-HEADER: clang{{.*}} "-fsycl-int-header=[[HEADER:.+\.h]]" -// CHECK-HEADER: {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER: {{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-NOT: clang{{.*}} "-include-internal-header" "[[HEADER]]" // CHECK-HEADER: clang{{.*}} "-include-internal-header" "{{.*}}_dirname{{.+}}.h" diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 014df665720a5..0787c3a722905 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -93,20 +93,16 @@ foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK}) add_clang_symlink(${link} clang) endforeach() -# Create dpclang++ build-tree symlink so tests can use it without installing. -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - llvm_add_tool_symlink(CLANG dpclang++ clang ALWAYS_GENERATE) -endif() +# Create dpclang++ build-tree symlink/copy so tests can use it without +# installing. llvm_add_tool_symlink (not add_clang_symlink) suppresses the +# install rule — dpclang++ must NOT be installed into lib/dpcpp-N/bin/. +llvm_add_tool_symlink(CLANG dpclang++ clang ALWAYS_GENERATE) # Install public dpclang* symlinks in ${CMAKE_INSTALL_BINDIR}. # These versioned names avoid conflicts with a system LLVM installation while # the real binaries live in ${DPCPP_INSTALL_INTERNAL_BINDIR} alongside all companion # tools so that the driver can find them via its own executable path. -if(CLANG_BUILD_TOOLS AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - # Ensure ${CMAKE_INSTALL_BINDIR} exists — no real binaries install there - # anymore so it would otherwise never be created. - install(DIRECTORY DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT clang) - +if(CLANG_BUILD_TOOLS) foreach(path ${CMAKE_MODULE_PATH}) if(EXISTS ${path}/LLVMInstallSymlink.cmake) set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake) @@ -114,34 +110,48 @@ if(CLANG_BUILD_TOOLS AND CMAKE_SYSTEM_NAME STREQUAL "Linux") endif() endforeach() - if(LLVM_USE_SYMLINKS) - set(_dpclang_link_or_copy create_symlink) - else() - set(_dpclang_link_or_copy copy) - endif() - - # Compute the relative path from $bindir to clang++ inside the tools dir so - # the symlinks work regardless of the installation prefix. - set(_abs_bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") - set(_abs_toolsdir "${CMAKE_INSTALL_PREFIX}/${DPCPP_INSTALL_INTERNAL_BINDIR}") - file(RELATIVE_PATH _dpclang_clangpp "${_abs_bindir}" "${_abs_toolsdir}/clang++") + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # On Linux, real binaries live in lib/dpcpp-N/bin/ so the public dpclang* + # entry-points go into ${CMAKE_INSTALL_BINDIR} as symlinks pointing there. + # Ensure ${CMAKE_INSTALL_BINDIR} exists — no real binaries install there. + install(DIRECTORY DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT clang) - # dpclang-MAJOR is the versioned public entry-point; it chains through clang++ - # (itself a symlink to the versioned clang binary) so realpath resolves to the - # tools directory where all companion tools reside. - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}\" \"${_dpclang_clangpp}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) + if(LLVM_USE_SYMLINKS) + set(_dpclang_link_or_copy create_symlink) + else() + set(_dpclang_link_or_copy copy) + endif() - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"dpclang\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) + # Compute the relative path from $bindir to clang++ inside the tools dir. + set(_abs_bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") + set(_abs_toolsdir "${CMAKE_INSTALL_PREFIX}/${DPCPP_INSTALL_INTERNAL_BINDIR}") + file(RELATIVE_PATH _dpclang_clangpp "${_abs_bindir}" "${_abs_toolsdir}/clang++") - foreach(_link dpclang++ dpclang-cl dpclang-cpp) + # dpclang-MAJOR → clang++ (in lib/dpcpp-N/bin/); dpclang/dpclang++/etc → dpclang-MAJOR install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"${_link}\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}\" \"${_dpclang_clangpp}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" COMPONENT clang) - endforeach() + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"dpclang\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + foreach(_link dpclang++ dpclang-cl dpclang-cpp) + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"${_link}\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + endforeach() + else() + # On Windows (and other non-Linux), all tools already install into bin/. + # Add dpclang* as copies of clang (clang.exe) in the same directory. + set(_dpclang_link_or_copy copy) + foreach(_link dpclang dpclang++ dpclang-cl dpclang-cpp) + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"${_link}\" \"clang\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + endforeach() + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}\" \"clang\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + endif() endif() # Configure plist creation for OS X. From a832242d60bfbf6ff25abb7502569943413187fc Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 22 Jun 2026 13:31:09 +0200 Subject: [PATCH 21/48] Fix clang-format --- clang/include/clang/Driver/SyclInstallationDetector.h | 4 +++- clang/lib/Driver/ToolChains/Clang.cpp | 3 ++- clang/lib/Driver/ToolChains/Linux.cpp | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Driver/SyclInstallationDetector.h b/clang/include/clang/Driver/SyclInstallationDetector.h index 0feadd4e1c96d..9597a556cb542 100644 --- a/clang/include/clang/Driver/SyclInstallationDetector.h +++ b/clang/include/clang/Driver/SyclInstallationDetector.h @@ -40,7 +40,9 @@ class SYCLInstallationDetector { StringRef getSYCLRTLibPath() const { return SYCLRTLibPath; } // Return the install root (the directory containing include/ and lib/). StringRef getInstallRoot() const { - return InstallationCandidates.empty() ? StringRef() : StringRef(InstallationCandidates[0]); + return InstallationCandidates.empty() + ? StringRef() + : StringRef(InstallationCandidates[0]); } void print(llvm::raw_ostream &OS) const; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 459e209e3b088..55d32b5c87782 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5209,7 +5209,8 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA, if (!TCArgs.hasArg(options::OPT_nostdlibinc, options::OPT_nostdinc)) { // Add default header search directories. // The binary may live in a versioned subdirectory (e.g. lib/dpcpp-N/bin/). - // Walk up from D.Dir until we find the install root (contains include/sycl). + // Walk up from D.Dir until we find the install root (contains + // include/sycl). SmallString<128> InstallRoot(C.getDriver().Dir); for (int I = 0; I < 4; ++I) { SmallString<128> Probe(InstallRoot); diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index 4fc82c71551ea..e325a62a3a39e 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -402,8 +402,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) SmallString<128> SYCLLibProbe(SYCLRoot); llvm::sys::path::append(SYCLLibProbe, "lib", "libsycl.so"); if (StringRef(SYCLRoot).starts_with(SysRoot) && - (Args.hasArg(options::OPT_fsycl) || - D.getVFS().exists(SYCLLibProbe))) { + (Args.hasArg(options::OPT_fsycl) || D.getVFS().exists(SYCLLibProbe))) { SmallString<128> SYCLLib(SYCLRoot); llvm::sys::path::append(SYCLLib, "lib"); addPathIfExists(D, SYCLLib, Paths); From fea0eaf3526df60e6e4e256b1628e920dab0862a Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 22 Jun 2026 15:26:25 +0200 Subject: [PATCH 22/48] Some improvements --- clang/include/clang/Driver/CommonArgs.h | 5 ++++ clang/lib/Driver/ToolChains/Clang.cpp | 18 +------------ clang/lib/Driver/ToolChains/CommonArgs.cpp | 25 +++++++++++++++++++ clang/lib/Driver/ToolChains/Linux.cpp | 18 +++---------- clang/lib/Driver/ToolChains/SYCL.cpp | 18 +------------ .../Driver/sycl-host-compiler-old-model.cpp | 12 ++++----- clang/test/Driver/sycl-host-compiler.cpp | 12 ++++----- .../test/Driver/sycl-offload-header-check.cpp | 2 +- clang/test/Driver/sycl.cpp | 6 ++--- clang/tools/driver/CMakeLists.txt | 15 ++++++----- libsycl/tools/sycl-ls/CMakeLists.txt | 4 +++ llvm/CMakeLists.txt | 2 -- llvm/cmake/modules/AddLLVM.cmake | 10 +++++--- 13 files changed, 71 insertions(+), 76 deletions(-) diff --git a/clang/include/clang/Driver/CommonArgs.h b/clang/include/clang/Driver/CommonArgs.h index 079a6597c4ba0..d187cd2aa8c5f 100644 --- a/clang/include/clang/Driver/CommonArgs.h +++ b/clang/include/clang/Driver/CommonArgs.h @@ -22,6 +22,11 @@ namespace clang { namespace driver { + +/// Walk up from \p D.Dir until a directory containing include/sycl is found +/// and return it as the install root. Falls back to D.Dir/.. if not found. +llvm::SmallString<128> findSYCLInstallRoot(const Driver &D); + namespace tools { void addPathIfExists(const Driver &D, const Twine &Path, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 55d32b5c87782..e532191e9abb3 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5208,23 +5208,7 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA, if (!TCArgs.hasArg(options::OPT_nostdlibinc, options::OPT_nostdinc)) { // Add default header search directories. - // The binary may live in a versioned subdirectory (e.g. lib/dpcpp-N/bin/). - // Walk up from D.Dir until we find the install root (contains - // include/sycl). - SmallString<128> InstallRoot(C.getDriver().Dir); - for (int I = 0; I < 4; ++I) { - SmallString<128> Probe(InstallRoot); - llvm::sys::path::append(Probe, "..", "include", "sycl"); - llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); - if (C.getDriver().getVFS().exists(Probe)) { - llvm::sys::path::append(InstallRoot, ".."); - llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); - break; - } - llvm::sys::path::append(InstallRoot, ".."); - llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); - } - SmallString<128> BaseDir(InstallRoot); + SmallString<128> BaseDir(findSYCLInstallRoot(C.getDriver())); llvm::sys::path::append(BaseDir, "include"); SmallString<128> SYCLDir(BaseDir); llvm::sys::path::append(SYCLDir, "sycl"); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 656912736e606..c0cd23cf2ef89 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -68,6 +68,31 @@ using namespace clang::driver::tools; using namespace clang; using namespace llvm::opt; +llvm::SmallString<128> clang::driver::findSYCLInstallRoot(const Driver &D) { + llvm::SmallString<128> Root(D.Dir); + bool Found = false; + for (int Depth = 0; Depth < 4; ++Depth) { + llvm::SmallString<128> Probe(Root); + llvm::sys::path::append(Probe, "..", "include", "sycl"); + llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); + if (D.getVFS().exists(Probe)) { + llvm::sys::path::append(Root, ".."); + llvm::sys::path::remove_dots(Root, /*remove_dot_dot=*/true); + Found = true; + break; + } + llvm::sys::path::append(Root, ".."); + llvm::sys::path::remove_dots(Root, /*remove_dot_dot=*/true); + } + if (!Found) { + // Fallback: one level up from D.Dir (original behaviour). + Root = D.Dir; + llvm::sys::path::append(Root, ".."); + llvm::sys::path::remove_dots(Root, /*remove_dot_dot=*/true); + } + return Root; +} + static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args, const llvm::Triple &Triple) { if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry)) diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index e325a62a3a39e..2d3e3ce61d730 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -383,22 +383,10 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) // libc++.so in D.Dir+"/../lib/". Detect this path. // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported. // Also handles the SYCL runtime library: when binaries live in a versioned - // subdirectory (e.g. lib/dpcpp-N/bin/) walk up to find the install root that - // contains lib/libsycl.so rather than assuming D.Dir/../lib. + // subdirectory (e.g. lib/dpcpp-N/bin/), findSYCLInstallRoot walks up to + // find the root that contains lib/libsycl.so. { - SmallString<128> SYCLRoot(D.Dir); - for (int I = 0; I < 4; ++I) { - SmallString<128> Probe(SYCLRoot); - llvm::sys::path::append(Probe, "..", "include", "sycl"); - llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); - if (D.getVFS().exists(Probe)) { - llvm::sys::path::append(SYCLRoot, ".."); - llvm::sys::path::remove_dots(SYCLRoot, /*remove_dot_dot=*/true); - break; - } - llvm::sys::path::append(SYCLRoot, ".."); - llvm::sys::path::remove_dots(SYCLRoot, /*remove_dot_dot=*/true); - } + SmallString<128> SYCLRoot = findSYCLInstallRoot(D); SmallString<128> SYCLLibProbe(SYCLRoot); llvm::sys::path::append(SYCLLibProbe, "lib", "libsycl.so"); if (StringRef(SYCLRoot).starts_with(SysRoot) && diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index cd5c9baa8e643..e0cd2ce74c9ee 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -32,23 +32,7 @@ SYCLInstallationDetector::SYCLInstallationDetector( // directory in SYCLRTLibPath for use by the linker. StringRef SysRoot = D.SysRoot; - // The binary may live in a versioned subdirectory (e.g. lib/dpcpp-N/bin/) - // rather than directly in bin/. Walk up from D.Dir until we find a - // directory that looks like the install root (contains include/sycl), - // falling back to D.Dir/.. if nothing is found. - SmallString<128> InstallRoot(D.Dir); - for (int Depth = 0; Depth < 4; ++Depth) { - SmallString<128> Probe(InstallRoot); - llvm::sys::path::append(Probe, "..", "include", "sycl"); - llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); - if (D.getVFS().exists(Probe)) { - llvm::sys::path::append(InstallRoot, ".."); - llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); - break; - } - llvm::sys::path::append(InstallRoot, ".."); - llvm::sys::path::remove_dots(InstallRoot, /*remove_dot_dot=*/true); - } + SmallString<128> InstallRoot = findSYCLInstallRoot(D); SmallString<128> DriverDir(InstallRoot); diff --git a/clang/test/Driver/sycl-host-compiler-old-model.cpp b/clang/test/Driver/sycl-host-compiler-old-model.cpp index 1ec1f2327595d..9c318d0dfc2f1 100644 --- a/clang/test/Driver/sycl-host-compiler-old-model.cpp +++ b/clang/test/Driver/sycl-host-compiler-old-model.cpp @@ -6,9 +6,9 @@ // HOST_COMPILER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}" // HOST_COMPILER: g++{{.*}} "-c" "-include" "[[INTHEADER]]" // HOST_COMPILER-SAME: "-iquote" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}include" +// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl" +// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include" // HOST_COMPILER-SAME: "-o" "[[HOSTOBJ:.+\.o]]" // HOST_COMPILER: ld{{.*}} "[[HOSTOBJ]]" @@ -17,9 +17,9 @@ // HOST_COMPILER_CL: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}" // HOST_COMPILER_CL: cl{{.*}} "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]" // HOST_COMPILER_CL-SAME: "/external:W0" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include" // HOST_COMPILER_CL: link{{.*}} "[[HOSTOBJ]]" /// check for additional host options diff --git a/clang/test/Driver/sycl-host-compiler.cpp b/clang/test/Driver/sycl-host-compiler.cpp index c68987249a7d9..90fa034e08190 100644 --- a/clang/test/Driver/sycl-host-compiler.cpp +++ b/clang/test/Driver/sycl-host-compiler.cpp @@ -12,9 +12,9 @@ // HOST_COMPILER: g++{{.*}} "[[APPENDFILESRC]]" // HOST_COMPILER-SAME: "-c" "-include" "[[INTHEADER]]" // HOST_COMPILER-SAME: "-iquote" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER-SAME: "-isystem" "{{.*}}include" +// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl" +// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include" // HOST_COMPILER-SAME: "-o" "[[HOSTOBJ:.+\.o]]" // HOST_COMPILER: clang-offload-bundler{{.*}} "-output=[[BUNDLEOBJ:.+\.o]]" "-input=[[DEVICEBC]]" "-input=[[HOSTOBJ]]" // HOST_COMPILER: clang-linker-wrapper{{.*}} "[[BUNDLEOBJ]]" @@ -29,9 +29,9 @@ // HOST_COMPILER_CL: cl{{.*}} "[[APPENDFILESRC]]" // HOST_COMPILER_CL-SAME: "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]" // HOST_COMPILER_CL-SAME: "/external:W0" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}include" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include" // HOST_COMPILER_CL: clang-offload-bundler{{.*}} "-output=[[BUNDLEOBJ:.+\.obj]]" "-input=[[DEVICEBC]]" "-input=[[HOSTOBJ]]" // HOST_COMPILER_CL: clang-linker-wrapper{{.*}} "[[BUNDLEOBJ]]" diff --git a/clang/test/Driver/sycl-offload-header-check.cpp b/clang/test/Driver/sycl-offload-header-check.cpp index 3789faffae5f6..bc80b7a1af9b5 100644 --- a/clang/test/Driver/sycl-offload-header-check.cpp +++ b/clang/test/Driver/sycl-offload-header-check.cpp @@ -10,6 +10,6 @@ // RUN: %clang -### -fsycl %s 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-HEADER %s // CHECK-HEADER: clang{{.*}} "-fsycl-int-header=[[HEADER:.+\.h]]" -// CHECK-HEADER: {{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER: {{.*}} "-internal-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-NOT: clang{{.*}} "-include-internal-header" "[[HEADER]]" // CHECK-HEADER: clang{{.*}} "-include-internal-header" "{{.*}}_dirname{{.+}}.h" diff --git a/clang/test/Driver/sycl.cpp b/clang/test/Driver/sycl.cpp index a4235bd351329..3e76d89ba6a52 100644 --- a/clang/test/Driver/sycl.cpp +++ b/clang/test/Driver/sycl.cpp @@ -13,7 +13,7 @@ // ENABLED: "-cc1"{{.*}} "-fsycl-is-device" // ENABLED-SAME: "-sycl-std={{[-.sycl0-9]+}}" -// ENABLED-SAME: "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// ENABLED-SAME: "-internal-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // NOT_ENABLED-NOT: "-fsycl-is-device" // NOT_ENABLED-NOT: "-fsycl-std-layout-kernel-params" @@ -44,7 +44,7 @@ // RUN: %clang_cl -### --target=i386-pc-windows-msvc -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT -DSPIRARCH=spir // DEFAULT: "-triple" "[[SPIRARCH]]-unknown-{{.*}}"{{.*}} "-fsycl-is-device"{{.*}} "-sycl-std=2020"{{.*}} "-emit-llvm-bc" -// DEFAULT: "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// DEFAULT: "-internal-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // DEFAULT: "-internal-isystem" "{{.*lib.*clang.*include}}" // DEFAULT: "-std=c++17" // DEFAULT-NOT: "{{.*}}llvm-spirv"{{.*}} @@ -87,7 +87,7 @@ // RUN: %clangxx -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=HEADER-ORDER // RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=HEADER-ORDER // HEADER-ORDER-NOT: clang{{.*}} "/usr/include" -// HEADER-ORDER: "-internal-isystem" "{{.*}}include" +// HEADER-ORDER: "-internal-isystem" "{{.*[/\\]}}include" /// Verify -fsycl-device-only phases // RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT-PHASES diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 0787c3a722905..fb1a0159bc3f0 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -93,10 +93,12 @@ foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK}) add_clang_symlink(${link} clang) endforeach() -# Create dpclang++ build-tree symlink/copy so tests can use it without -# installing. llvm_add_tool_symlink (not add_clang_symlink) suppresses the -# install rule — dpclang++ must NOT be installed into lib/dpcpp-N/bin/. -llvm_add_tool_symlink(CLANG dpclang++ clang ALWAYS_GENERATE) +# Create dpclang* build-tree symlinks/copies so tests can use them without +# installing. Use llvm_add_tool_symlink (not add_clang_symlink) to suppress +# install rules — these must NOT be installed into lib/dpcpp-N/bin/. +foreach(_link dpclang dpclang++ dpclang-cl dpclang-cpp) + llvm_add_tool_symlink(CLANG ${_link} clang ALWAYS_GENERATE) +endforeach() # Install public dpclang* symlinks in ${CMAKE_INSTALL_BINDIR}. # These versioned names avoid conflicts with a system LLVM installation while @@ -141,8 +143,9 @@ if(CLANG_BUILD_TOOLS) endforeach() else() # On Windows (and other non-Linux), all tools already install into bin/. - # Add dpclang* as copies of clang (clang.exe) in the same directory. - set(_dpclang_link_or_copy copy) + # Use hardlinks so dpclang* entries share the same inode as clang.exe + # without duplicating ~200 MB of binary on disk. + set(_dpclang_link_or_copy create_hardlink) foreach(_link dpclang dpclang++ dpclang-cl dpclang-cpp) install(SCRIPT ${INSTALL_SYMLINK} CODE "install_symlink(\"${_link}\" \"clang\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" diff --git a/libsycl/tools/sycl-ls/CMakeLists.txt b/libsycl/tools/sycl-ls/CMakeLists.txt index e34ba77c88c37..d9df4cd86e28b 100644 --- a/libsycl/tools/sycl-ls/CMakeLists.txt +++ b/libsycl/tools/sycl-ls/CMakeLists.txt @@ -25,5 +25,9 @@ if (WIN32) # - LOAD_LIBRARY_SEARCH_SYSTEM32 (0x800) target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900) endif() +# Intentionally installed into the public "bin/" directory rather than +# DPCPP_INSTALL_INTERNAL_BINDIR (lib/dpcpp-N/bin/ on Linux). sycl-ls is a +# user-facing tool that needs to be on PATH, and the e2e test infrastructure +# locates it via config.dpcpp_bin_dir (= /bin/). install(TARGETS sycl-ls RUNTIME DESTINATION "bin" COMPONENT sycl-ls) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 499cb5f4d857b..7441222cf8f91 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -567,8 +567,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LLVM_USE_SYMLINKS) unset(_dpcpp_dir) endif() -set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING - "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") mark_as_advanced(LLVM_TOOLS_INSTALL_DIR) set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 286898c10adf4..a31e674a68891 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2697,11 +2697,15 @@ function(llvm_setup_rpath name) if(_target_type STREQUAL "EXECUTABLE" AND CMAKE_SYSTEM_NAME STREQUAL "Linux" AND DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) - file(RELATIVE_PATH _rpath_to_lib - "/dummy/${DPCPP_INSTALL_INTERNAL_BINDIR}" - "/dummy/lib${LLVM_LIBDIR_SUFFIX}") + cmake_path(SET _internal_bin_abs NORMALIZE + "/${DPCPP_INSTALL_INTERNAL_BINDIR}") + cmake_path(SET _lib_abs NORMALIZE "/lib${LLVM_LIBDIR_SUFFIX}") + cmake_path(RELATIVE_PATH _lib_abs BASE_DIRECTORY "${_internal_bin_abs}" + OUTPUT_VARIABLE _rpath_to_lib) set(_install_rpath "\$ORIGIN/${_rpath_to_lib}") unset(_rpath_to_lib) + unset(_internal_bin_abs) + unset(_lib_abs) else() set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") endif() From eeb50257bb673a02bb80a26a30252a083883a232 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 22 Jun 2026 18:34:35 +0200 Subject: [PATCH 23/48] Fix Windows --- clang/tools/driver/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index fb1a0159bc3f0..47ab2b289965b 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -143,9 +143,10 @@ if(CLANG_BUILD_TOOLS) endforeach() else() # On Windows (and other non-Linux), all tools already install into bin/. - # Use hardlinks so dpclang* entries share the same inode as clang.exe - # without duplicating ~200 MB of binary on disk. - set(_dpclang_link_or_copy create_hardlink) + # Use copy: hardlinks would save space on the build machine but the savings + # are lost after zip/tar extraction on the target machine anyway, and + # create_hardlink fails if source and destination are on different volumes. + set(_dpclang_link_or_copy copy) foreach(_link dpclang dpclang++ dpclang-cl dpclang-cpp) install(SCRIPT ${INSTALL_SYMLINK} CODE "install_symlink(\"${_link}\" \"clang\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" From 8b4c27e0fadca26a2733ef2a8577eed4503f20a8 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 22 Jun 2026 18:45:29 +0200 Subject: [PATCH 24/48] Add missing binary --- clang/tools/driver/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 47ab2b289965b..10740b97ea82d 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -96,7 +96,7 @@ endforeach() # Create dpclang* build-tree symlinks/copies so tests can use them without # installing. Use llvm_add_tool_symlink (not add_clang_symlink) to suppress # install rules — these must NOT be installed into lib/dpcpp-N/bin/. -foreach(_link dpclang dpclang++ dpclang-cl dpclang-cpp) +foreach(_link dpclang dpclang-${DPCPP_VERSION_MAJOR} dpclang++ dpclang-cl dpclang-cpp) llvm_add_tool_symlink(CLANG ${_link} clang ALWAYS_GENERATE) endforeach() From 0f44a043f2b2223264254ec810c487299afff004 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 29 Jun 2026 18:38:51 +0200 Subject: [PATCH 25/48] Apply CR comments --- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- clang/lib/Driver/ToolChains/CommonArgs.cpp | 42 +++++++++++++--------- clang/lib/Driver/ToolChains/Linux.cpp | 7 ++-- clang/tools/driver/CMakeLists.txt | 7 ++++ cmake/Modules/GetClangResourceDir.cmake | 13 +++++++ libsycl/tools/sycl-ls/CMakeLists.txt | 4 --- llvm/CMakeLists.txt | 25 ++++--------- sycl/test-e2e/lit.site.cfg.py.in | 4 +-- sycl/tools/sycl-prof/CMakeLists.txt | 2 +- sycl/tools/sycl-sanitize/CMakeLists.txt | 2 +- sycl/tools/sycl-trace/CMakeLists.txt | 2 +- sycl/tools/syclbin-dump/CMakeLists.txt | 2 +- 12 files changed, 61 insertions(+), 51 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 73577e059537d..188c592192d8f 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -11947,7 +11947,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA, // -sycl-device-library-location= provides the location in which the // SYCL device libraries can be found. SmallString<128> DeviceLibDir(D.Dir); - llvm::sys::path::append(DeviceLibDir, "..", "lib"); + llvm::sys::path::append(DeviceLibDir, "..", CLANG_INSTALL_LIBDIR_BASENAME); // Check the library location candidates for the the libsycl-crt library // and use that location. Base the location on relative to driver if this // is not resolved. diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 9d8091392a776..7890e477cd41d 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -69,23 +69,31 @@ using namespace clang; using namespace llvm::opt; llvm::SmallString<128> clang::driver::findSYCLInstallRoot(const Driver &D) { - llvm::SmallString<128> Root(D.Dir); - bool Found = false; - for (int Depth = 0; Depth < 4; ++Depth) { - llvm::SmallString<128> Probe(Root); - llvm::sys::path::append(Probe, "..", "include", "sycl"); - llvm::sys::path::remove_dots(Probe, /*remove_dot_dot=*/true); - if (D.getVFS().exists(Probe)) { - llvm::sys::path::append(Root, ".."); - llvm::sys::path::remove_dots(Root, /*remove_dot_dot=*/true); - Found = true; - break; - } - llvm::sys::path::append(Root, ".."); - llvm::sys::path::remove_dots(Root, /*remove_dot_dot=*/true); - } - if (!Found) { - // Fallback: one level up from D.Dir (original behaviour). + // Deduce the install root from the directory the driver was invoked from, + // recognizing the directory layouts the compiler may be installed into. + // This mirrors RocmInstallationDetector::getInstallationPathCandidates() in + // AMDGPU.cpp, which walks up from the clang binary by matching the names of + // the enclosing directories rather than guessing a fixed depth. + StringRef ParentDir = llvm::sys::path::parent_path(D.Dir); + StringRef ParentName = llvm::sys::path::filename(ParentDir); + + // Some layouts install the compiler into lib//bin, so go up again. + if (ParentName == "bin") { + ParentDir = llvm::sys::path::parent_path(ParentDir); + ParentName = llvm::sys::path::filename(ParentDir); + } + + // Some layouts nest the compiler under lib/llvm/bin, so back up out of the + // lib directory as well. Honor a custom libdir name (e.g. lib64). + if (ParentName == CLANG_INSTALL_LIBDIR_BASENAME) + ParentDir = llvm::sys::path::parent_path(ParentDir); + + // Validate the deduced root by checking for the SYCL headers it should + // contain; if they are not present, fall back to one level up from D.Dir. + llvm::SmallString<128> Root(ParentDir); + llvm::SmallString<128> Probe(Root); + llvm::sys::path::append(Probe, "include", "sycl"); + if (!D.getVFS().exists(Probe)) { Root = D.Dir; llvm::sys::path::append(Root, ".."); llvm::sys::path::remove_dots(Root, /*remove_dot_dot=*/true); diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index a858531deb1c0..61fbf2a577d75 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -384,15 +384,16 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported. // Also handles the SYCL runtime library: when binaries live in a versioned // subdirectory (e.g. lib/dpcpp-N/bin/), findSYCLInstallRoot walks up to - // find the root that contains lib/libsycl.so. + // find the root that contains /libsycl.so. { SmallString<128> SYCLRoot = findSYCLInstallRoot(D); SmallString<128> SYCLLibProbe(SYCLRoot); - llvm::sys::path::append(SYCLLibProbe, "lib", "libsycl.so"); + llvm::sys::path::append(SYCLLibProbe, CLANG_INSTALL_LIBDIR_BASENAME, + "libsycl.so"); if (StringRef(SYCLRoot).starts_with(SysRoot) && (Args.hasArg(options::OPT_fsycl) || D.getVFS().exists(SYCLLibProbe))) { SmallString<128> SYCLLib(SYCLRoot); - llvm::sys::path::append(SYCLLib, "lib"); + llvm::sys::path::append(SYCLLib, CLANG_INSTALL_LIBDIR_BASENAME); addPathIfExists(D, SYCLLib, Paths); } } diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 10740b97ea82d..af7a0fca732bd 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -105,6 +105,13 @@ endforeach() # the real binaries live in ${DPCPP_INSTALL_INTERNAL_BINDIR} alongside all companion # tools so that the driver can find them via its own executable path. if(CLANG_BUILD_TOOLS) + # Locate LLVM's install_symlink() helper script. This mirrors the loop in + # llvm_install_symlink() in LLVM's AddLLVM.cmake: LLVMInstallSymlink.cmake + # lives in llvm/cmake/modules for an in-tree build but in + # /lib/cmake/llvm for a standalone clang build. Both candidate + # directories are on CMAKE_MODULE_PATH, so we walk it and take whichever one + # actually exists rather than hardcoding a path that only works for one build + # layout. foreach(path ${CMAKE_MODULE_PATH}) if(EXISTS ${path}/LLVMInstallSymlink.cmake) set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake) diff --git a/cmake/Modules/GetClangResourceDir.cmake b/cmake/Modules/GetClangResourceDir.cmake index 518220188f96d..2f32fc599dd56 100644 --- a/cmake/Modules/GetClangResourceDir.cmake +++ b/cmake/Modules/GetClangResourceDir.cmake @@ -17,6 +17,19 @@ function(get_clang_resource_dir out_var) string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION}) endif() set(ret_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}) + # When the compiler tools are relocated into a versioned DPC++ libdir + # (e.g. lib/dpcpp-N/bin), the driver resolves its resource dir relative to + # the executable as /lib/clang/N (see GetResourcesPath() in + # clang/lib/Options/OptionUtils.cpp). For install destinations (callers + # that pass no PREFIX) mirror that layout so the resource headers and + # libraries are installed where the driver actually looks, instead of the + # top-level lib/clang which would otherwise require a bridging symlink. + if(NOT ARG_PREFIX AND DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) + cmake_path(GET DPCPP_INSTALL_INTERNAL_BINDIR PARENT_PATH _dpcpp_parent) + if(_dpcpp_parent) + set(ret_dir ${_dpcpp_parent}/${ret_dir}) + endif() + endif() endif() if(ARG_PREFIX) diff --git a/libsycl/tools/sycl-ls/CMakeLists.txt b/libsycl/tools/sycl-ls/CMakeLists.txt index d9df4cd86e28b..e34ba77c88c37 100644 --- a/libsycl/tools/sycl-ls/CMakeLists.txt +++ b/libsycl/tools/sycl-ls/CMakeLists.txt @@ -25,9 +25,5 @@ if (WIN32) # - LOAD_LIBRARY_SEARCH_SYSTEM32 (0x800) target_link_options(sycl-ls PRIVATE LINKER:/DEPENDENTLOADFLAG:0x900) endif() -# Intentionally installed into the public "bin/" directory rather than -# DPCPP_INSTALL_INTERNAL_BINDIR (lib/dpcpp-N/bin/ on Linux). sycl-ls is a -# user-facing tool that needs to be on PATH, and the e2e test infrastructure -# locates it via config.dpcpp_bin_dir (= /bin/). install(TARGETS sycl-ls RUNTIME DESTINATION "bin" COMPONENT sycl-ls) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 7441222cf8f91..a4cf691d3680c 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -543,29 +543,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") else() set(DPCPP_INSTALL_INTERNAL_BINDIR "bin") endif() -set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "" FORCE) +set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING + "Path for binary subdirectory (defaults to '${DPCPP_INSTALL_INTERNAL_BINDIR}')" FORCE) set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) # The default resource-dir formula is: dirname(binary)/../lib/clang/VERSION. # For binaries installed in lib/dpcpp-N/bin/ this resolves inside lib/dpcpp-N/ -# instead of the install root. Installing a lib/clang -> ../../../lib/clang -# symlink inside lib/dpcpp-N/ makes the formula resolve correctly. -# We symlink only lib/clang (not the whole lib/) to avoid exposing -# lib/dpcpp-N/lib/dpcpp-N which is confusing and wrong-looking. -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LLVM_USE_SYMLINKS) - cmake_path(GET DPCPP_INSTALL_INTERNAL_BINDIR PARENT_PATH _dpcpp_dir) - install(CODE " - set(DESTDIR \"\$ENV{DESTDIR}\") - set(_dir \"\${DESTDIR}\${CMAKE_INSTALL_PREFIX}/${_dpcpp_dir}\") - file(MAKE_DIRECTORY \"\${_dir}/lib\") - if(NOT EXISTS \"\${_dir}/lib/clang\") - execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink - ../../../lib/clang clang - WORKING_DIRECTORY \"\${_dir}/lib\") - endif() - " COMPONENT clang) - unset(_dpcpp_dir) -endif() +# (i.e. lib/dpcpp-N/lib/clang/VERSION) rather than the install root. The +# resource files are installed directly there by get_clang_resource_dir() +# (see cmake/Modules/GetClangResourceDir.cmake), so no bridging symlink from +# the top-level lib/clang is needed. mark_as_advanced(LLVM_TOOLS_INSTALL_DIR) diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index 2444b12d7927d..0471b71542fb5 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -19,9 +19,7 @@ def get_dpcpp_tool_path(name): return os.path.join(config.dpcpp_bin_dir, name) config.llvm_main_include_dir = "@LLVM_MAIN_INCLUDE_DIR@" -# Use llvm-link (always in SYCL_TOOLCHAIN_DEPLOY_COMPONENTS) to find the -# internal tools directory. llvm-config is not always deployed there. -config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-link")) +config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-config")) config.lit_tools_dir = os.path.dirname("@TEST_SUITE_LIT@") config.dump_ir_supported = lit_config.params.get("dump_ir", ("@DUMP_IR_SUPPORTED@" if "@DUMP_IR_SUPPORTED@" else False)) config.sycl_tools_dir = config.llvm_tools_dir diff --git a/sycl/tools/sycl-prof/CMakeLists.txt b/sycl/tools/sycl-prof/CMakeLists.txt index 9b320a6ba99ad..c37040614206c 100644 --- a/sycl/tools/sycl-prof/CMakeLists.txt +++ b/sycl/tools/sycl-prof/CMakeLists.txt @@ -25,7 +25,7 @@ add_dependencies(sycl-toolchain sycl-prof) include(GNUInstallDirs) install(TARGETS sycl-prof sycl_profiler_collector - RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-prof + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-prof LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-prof ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-prof ) diff --git a/sycl/tools/sycl-sanitize/CMakeLists.txt b/sycl/tools/sycl-sanitize/CMakeLists.txt index acedec1d14d69..4a1e6e3c9cc93 100644 --- a/sycl/tools/sycl-sanitize/CMakeLists.txt +++ b/sycl/tools/sycl-sanitize/CMakeLists.txt @@ -26,7 +26,7 @@ add_dependencies(sycl-toolchain sycl-sanitize) include(GNUInstallDirs) install(TARGETS sycl-sanitize sycl_sanitizer_collector - RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-sanitize + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-sanitize LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-sanitize ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-sanitize ) diff --git a/sycl/tools/sycl-trace/CMakeLists.txt b/sycl/tools/sycl-trace/CMakeLists.txt index cf79d3bc4da49..f1e804dee0b91 100644 --- a/sycl/tools/sycl-trace/CMakeLists.txt +++ b/sycl/tools/sycl-trace/CMakeLists.txt @@ -177,7 +177,7 @@ add_dependencies(sycl-toolchain sycl-trace) include(GNUInstallDirs) install(TARGETS sycl-trace sycl_ur_trace_collector ${EXTRA_TARGETS_TO_INSTALL} - RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT sycl-trace + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT sycl-trace LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-trace ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT sycl-trace ) diff --git a/sycl/tools/syclbin-dump/CMakeLists.txt b/sycl/tools/syclbin-dump/CMakeLists.txt index 4ddffada834ca..9bf370bdcbe4e 100644 --- a/sycl/tools/syclbin-dump/CMakeLists.txt +++ b/sycl/tools/syclbin-dump/CMakeLists.txt @@ -22,4 +22,4 @@ endif() add_dependencies(sycl-toolchain syclbin-dump) install(TARGETS syclbin-dump - RUNTIME DESTINATION ${DPCPP_INSTALL_INTERNAL_BINDIR} COMPONENT syclbin-dump) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT syclbin-dump) From b0802b7fa1e3382d3a11e9c532948733d8eee33b Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Wed, 1 Jul 2026 16:29:08 +0200 Subject: [PATCH 26/48] Fix CI --- sycl/test-e2e/lit.site.cfg.py.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index 0471b71542fb5..2444b12d7927d 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -19,7 +19,9 @@ def get_dpcpp_tool_path(name): return os.path.join(config.dpcpp_bin_dir, name) config.llvm_main_include_dir = "@LLVM_MAIN_INCLUDE_DIR@" -config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-config")) +# Use llvm-link (always in SYCL_TOOLCHAIN_DEPLOY_COMPONENTS) to find the +# internal tools directory. llvm-config is not always deployed there. +config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-link")) config.lit_tools_dir = os.path.dirname("@TEST_SUITE_LIT@") config.dump_ir_supported = lit_config.params.get("dump_ir", ("@DUMP_IR_SUPPORTED@" if "@DUMP_IR_SUPPORTED@" else False)) config.sycl_tools_dir = config.llvm_tools_dir From 3578f68638a643992a0e8ff105c3f2886ad6865f Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Wed, 1 Jul 2026 19:16:13 +0200 Subject: [PATCH 27/48] Fix CI --- sycl/test-e2e/CMakeLists.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sycl/test-e2e/CMakeLists.txt b/sycl/test-e2e/CMakeLists.txt index 2ee613f148a87..67f7eff3e8b26 100644 --- a/sycl/test-e2e/CMakeLists.txt +++ b/sycl/test-e2e/CMakeLists.txt @@ -104,13 +104,26 @@ endif() get_filename_component(DPCPP_ROOT_DIR ${SYCL_CXX_COMPILER} DIRECTORY) if(SYCL_TEST_E2E_STANDALONE) + # llvm-config is not necessarily next to the compiler driver: with the + # dpclang layout the real tools live in lib/dpcpp-/bin/ while the + # public driver is in bin/. Ask the compiler where llvm-config is instead + # of assuming it sits alongside the driver. execute_process( - COMMAND ${DPCPP_ROOT_DIR}/llvm-config${CMAKE_EXECUTABLE_SUFFIX} --libdir + COMMAND ${SYCL_CXX_COMPILER} -print-prog-name=llvm-config${CMAKE_EXECUTABLE_SUFFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE CMPLR_LIBS_RESULT - OUTPUT_VARIABLE CMPLR_LIBS_DIR + RESULT_VARIABLE CMPLR_CONFIG_RESULT + OUTPUT_VARIABLE CMPLR_CONFIG_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(CMPLR_CONFIG_RESULT EQUAL 0 AND EXISTS "${CMPLR_CONFIG_PATH}") + execute_process( + COMMAND ${CMPLR_CONFIG_PATH} --libdir + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE CMPLR_LIBS_RESULT + OUTPUT_VARIABLE CMPLR_LIBS_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif() if(NOT CMPLR_LIBS_RESULT EQUAL 0 OR NOT CMPLR_LIBS_DIR) message(FATAL_ERROR "Failed to determine SYCL library directory") endif() From 9fb8f4926dc2d2e0ef87489c66a76a80d05148fc Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Thu, 2 Jul 2026 14:54:41 +0200 Subject: [PATCH 28/48] Fix CI --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 10 ++++++++++ llvm/runtimes/CMakeLists.txt | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 7890e477cd41d..371105d0234ca 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -83,6 +83,16 @@ llvm::SmallString<128> clang::driver::findSYCLInstallRoot(const Driver &D) { ParentName = llvm::sys::path::filename(ParentDir); } + // The dpclang install layout keeps the real tools in lib/dpcpp-/bin + // (the public dpclang* drivers in bin/ are just symlinks into it, and the + // driver resolves them, so D.Dir points at the versioned directory). Step + // out of that versioned subdirectory too. This mirrors AMDGPU.cpp matching + // "aomp*" enclosing directories by name. + if (ParentName.starts_with("dpcpp-")) { + ParentDir = llvm::sys::path::parent_path(ParentDir); + ParentName = llvm::sys::path::filename(ParentDir); + } + // Some layouts nest the compiler under lib/llvm/bin, so back up out of the // lib directory as well. Honor a custom libdir name (e.g. lib64). if (ParentName == CLANG_INSTALL_LIBDIR_BASENAME) diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index 707451408f091..7b5aa09721533 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -4,6 +4,17 @@ # the two files. set(COMMON_CMAKE_ARGS "-DHAVE_LLVM_LIT=ON;-DCLANG_RESOURCE_DIR=${CLANG_RESOURCE_DIR}") +# Forward the versioned DPC++ binary directory into the runtimes sub-builds. +# It is defined in the top-level llvm/CMakeLists.txt but the runtimes are +# configured as a separate CMake invocation that does not inherit it. libclc +# relies on it in get_clang_resource_dir() to install libspirv into the same +# versioned resource directory (lib/dpcpp-N/lib/clang/N) the driver searches; +# without it libclc would fall back to the non-versioned lib/clang/N and the +# driver would fail to find libspirv.*.bc. +if(DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) + list(APPEND COMMON_CMAKE_ARGS + "-DDPCPP_INSTALL_INTERNAL_BINDIR=${DPCPP_INSTALL_INTERNAL_BINDIR}") +endif() if(APPLE AND CMAKE_OSX_SYSROOT AND (LLVM_TARGET_TRIPLE STREQUAL LLVM_HOST_TRIPLE)) # Only propagate the host sysroot for native runtimes builds. list(APPEND RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}") From de25fd13619c4a4f575f715d59aa77f59c5d7fb4 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Thu, 2 Jul 2026 16:28:53 +0200 Subject: [PATCH 29/48] Fix CI --- libclc/CMakeLists.txt | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 3f70fc78e0ddc..aa8826b10964b 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -87,11 +87,29 @@ else() # Setup the paths where libclc runtimes should be stored. By default, in an # in-tree build we place the libraries in clang's resource driectory. include(GetClangResourceDir) + # The trailing library component must match what the driver appends when it + # searches for libspirv: CLANG_INSTALL_LIBDIR_BASENAME (i.e. + # lib${LLVM_LIBDIR_SUFFIX}, e.g. lib64). CLANG_INSTALL_LIBDIR_BASENAME itself + # is defined in clang/CMakeLists.txt and is not in scope in this (runtimes) + # sub-build, so spell out its expansion, which is also what + # get_clang_resource_dir() uses for the leading library component. + set( LIBCLC_LIBDIR_BASENAME "lib${LLVM_LIBDIR_SUFFIX}" ) + + # Install into the clang resource directory that the *installed* driver + # searches. With no PREFIX, get_clang_resource_dir() applies the versioned + # dpclang layout (lib/dpcpp-N/lib/clang/N) used by the install tree. get_clang_resource_dir( LIBCLC_INSTALL_DIR ) - cmake_path( APPEND LIBCLC_INSTALL_DIR "lib" ) - - cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH LIBCLC_OUTPUT_LIBRARY_DIR ) - cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_INSTALL_DIR} ) + cmake_path( APPEND LIBCLC_INSTALL_DIR ${LIBCLC_LIBDIR_BASENAME} ) + + # For the in-tree build output, mirror the *build-tree* driver's resource + # directory instead. That driver resolves its resource dir relative to its + # own location as /lib/clang/N with no dpcpp-N versioning, so use the + # PREFIX form, which is never version-prefixed. Reusing LIBCLC_INSTALL_DIR + # here would emit the libraries into a versioned directory the build-tree + # driver does not search (breaking in-tree check-sycl/libclc tests). + cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH _libclc_build_prefix ) + get_clang_resource_dir( LIBCLC_OUTPUT_LIBRARY_DIR PREFIX ${_libclc_build_prefix} ) + cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_LIBDIR_BASENAME} ) endif() if( NOT LIBCLC_USE_SPIRV_BACKEND ) From 8f13cab5bc55df1c698b520185e517ea7351e409 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Thu, 2 Jul 2026 18:14:15 +0200 Subject: [PATCH 30/48] Fix CI --- .../lib/rtc/DeviceCompilation.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp index 5c44068413c5a..c13929daf816b 100644 --- a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp +++ b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp @@ -177,6 +177,21 @@ std::string getLibPathSuffix() { DPCPP_VERSION_MAJOR); #endif } + +// Location of the internal `clang++` binary relative to the toolchain root. +// The real toolchain relocates the driver into a versioned libdir on Linux +// (mirroring DPCPP_INSTALL_INTERNAL_BINDIR in llvm/CMakeLists.txt); the JIT's +// virtual toolchain must use the same layout so that clang's GetResourcesPath() +// derives the same (versioned) resource directory the bundled resource headers +// and libraries are installed into. +std::string getInternalBinSubPath() { +#ifdef _WIN32 + return "/bin/clang++"; +#else + return llvm::formatv("/{0}/dpcpp-{1}/bin/clang++", CLANG_INSTALL_LIBDIR_BASENAME, + DPCPP_VERSION_MAJOR); +#endif +} class SYCLToolchain { static auto &getToolchainFS() { // TODO: For some reason, removing `thread_local` results in data races @@ -631,8 +646,9 @@ class SYCLToolchain { clang::IgnoringDiagConsumer IgnoreDiag; std::string_view Prefix{jit_compiler::resource::ToolchainPrefix.S, jit_compiler::resource::ToolchainPrefix.Size}; - std::string ClangXXExe = (Prefix + "/bin/clang++").str(); - std::string LibclcDir = GetResourcesPath(ClangXXExe) + "/lib/"; + std::string ClangXXExe = (Prefix + getInternalBinSubPath()).str(); + std::string LibclcDir = + GetResourcesPath(ClangXXExe) + "/" + CLANG_INSTALL_LIBDIR_BASENAME + "/"; PrecompiledPreambles Preambles; }; From 761cc89b78eb9c93512811132e257a420ff6f4b1 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 6 Jul 2026 19:11:32 +0200 Subject: [PATCH 31/48] Fix Windows --- clang/lib/Driver/ToolChain.cpp | 19 ++++++++ clang/tools/driver/CMakeLists.txt | 80 +++++++++++++++---------------- llvm/CMakeLists.txt | 6 +-- 3 files changed, 60 insertions(+), 45 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 2d1888c21b198..3827f4015c02f 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -16,6 +16,7 @@ #include "ToolChains/InterfaceStubs.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Sanitizers.h" +#include "clang/Basic/Version.h" #include "clang/Config/config.h" #include "clang/Driver/Action.h" #include "clang/Driver/CommonArgs.h" @@ -105,6 +106,24 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, getFilePaths().push_back(*Path); for (const auto &Path : getArchSpecificLibPaths()) addIfExists(getFilePaths(), Path); + + // The real compiler tools (clang, clang++, llvm-ar, clang-offload-bundler, + // ...) are installed into a versioned DPC++ subdirectory so they don't + // conflict with a system LLVM installation. On Linux the public dpclang* + // entry-points in bin/ are symlinks into that directory, so D.Dir already + // points at it once the symlink is resolved. On Windows those entry-points + // are real copies that live in bin/, so D.Dir is bin/ and the companion + // tools are one directory removed; seed the versioned directory into the + // program search path so the driver can still find them. The existence + // check makes this a harmless duplicate on Linux and a no-op for install + // layouts that don't use the versioned directory at all. + { + SmallString<128> InternalBin(findSYCLInstallRoot(D)); + llvm::sys::path::append(InternalBin, CLANG_INSTALL_LIBDIR_BASENAME, + "dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR), "bin"); + if (getVFS().exists(InternalBin)) + getProgramPaths().push_back(std::string(InternalBin)); + } } ToolChain::OrderedMultilibs ToolChain::getOrderedMultilibs() const { diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index af7a0fca732bd..44e949c18b22f 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -119,50 +119,50 @@ if(CLANG_BUILD_TOOLS) endif() endforeach() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # On Linux, real binaries live in lib/dpcpp-N/bin/ so the public dpclang* - # entry-points go into ${CMAKE_INSTALL_BINDIR} as symlinks pointing there. - # Ensure ${CMAKE_INSTALL_BINDIR} exists — no real binaries install there. - install(DIRECTORY DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT clang) - - if(LLVM_USE_SYMLINKS) - set(_dpclang_link_or_copy create_symlink) - else() - set(_dpclang_link_or_copy copy) - endif() - - # Compute the relative path from $bindir to clang++ inside the tools dir. - set(_abs_bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") - set(_abs_toolsdir "${CMAKE_INSTALL_PREFIX}/${DPCPP_INSTALL_INTERNAL_BINDIR}") - file(RELATIVE_PATH _dpclang_clangpp "${_abs_bindir}" "${_abs_toolsdir}/clang++") - - # dpclang-MAJOR → clang++ (in lib/dpcpp-N/bin/); dpclang/dpclang++/etc → dpclang-MAJOR - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}\" \"${_dpclang_clangpp}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"dpclang\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) - foreach(_link dpclang++ dpclang-cl dpclang-cpp) - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"${_link}\" \"dpclang-${DPCPP_VERSION_MAJOR}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) - endforeach() + # Both Linux and Windows relocate the real tools into lib/dpcpp-N/bin/ so + # they don't collide with a system LLVM. The public dpclang* entry-points go + # into ${CMAKE_INSTALL_BINDIR}; no real binaries install there directly, so + # make sure the directory exists. + install(DIRECTORY DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT clang) + + # ${CMAKE_EXECUTABLE_SUFFIX} is empty on Linux and ".exe" on Windows, so the + # same code produces dpclang / dpclang-N / ... on Linux and dpclang.exe / + # dpclang-N.exe / ... on Windows. + set(_exe "${CMAKE_EXECUTABLE_SUFFIX}") + + # dpclang-N points at clang++ inside the versioned tools dir; the remaining + # names chain to dpclang-N. install_symlink resolves a relative source + # against ${CMAKE_INSTALL_BINDIR}, so use a path relative to bin/. + set(_abs_bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") + set(_abs_toolsdir "${CMAKE_INSTALL_PREFIX}/${DPCPP_INSTALL_INTERNAL_BINDIR}") + file(RELATIVE_PATH _dpclang_primary_target + "${_abs_bindir}" "${_abs_toolsdir}/clang++${_exe}") + + if(LLVM_USE_SYMLINKS) + # Linux default: relative symlinks. Resolving the symlink at startup lands + # the driver inside the versioned tools dir where its companion tools live. + set(_dpclang_link_or_copy create_symlink) else() - # On Windows (and other non-Linux), all tools already install into bin/. - # Use copy: hardlinks would save space on the build machine but the savings - # are lost after zip/tar extraction on the target machine anyway, and - # create_hardlink fails if source and destination are on different volumes. + # Windows default (LLVM_USE_SYMLINKS defaults to OFF on non-UNIX hosts): + # real copies. A copied executable is not a symlink, so the driver can't + # discover its companion tools by walking up from its own location; the + # base ToolChain constructor seeds lib/dpcpp-N/bin/ into the program + # search path (see clang/lib/Driver/ToolChain.cpp) to compensate. set(_dpclang_link_or_copy copy) - foreach(_link dpclang dpclang++ dpclang-cl dpclang-cpp) - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"${_link}\" \"clang\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) - endforeach() + endif() + + # dpclang-MAJOR → clang++ (in lib/dpcpp-N/bin/); dpclang/dpclang++/etc → dpclang-MAJOR + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}${_exe}\" \"${_dpclang_primary_target}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + install(SCRIPT ${INSTALL_SYMLINK} + CODE "install_symlink(\"dpclang${_exe}\" \"dpclang-${DPCPP_VERSION_MAJOR}${_exe}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + COMPONENT clang) + foreach(_link dpclang++ dpclang-cl dpclang-cpp) install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}\" \"clang\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" + CODE "install_symlink(\"${_link}${_exe}\" \"dpclang-${DPCPP_VERSION_MAJOR}${_exe}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" COMPONENT clang) - endif() + endforeach() endif() # Configure plist creation for OS X. diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index a4cf691d3680c..e8a491a3132fb 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -538,11 +538,7 @@ set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING # they don't conflict with a system LLVM installation. The public dpclang* # entry-points in ${CMAKE_INSTALL_BINDIR} are added by clang/tools/driver. # This block must be after project() so that CMAKE_SYSTEM_NAME is defined. -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") -else() - set(DPCPP_INSTALL_INTERNAL_BINDIR "bin") -endif() +set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "Path for binary subdirectory (defaults to '${DPCPP_INSTALL_INTERNAL_BINDIR}')" FORCE) set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) From b0c0c73c1ae66dad3b7fc87e91efa131db6df7ff Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 6 Jul 2026 19:48:25 +0200 Subject: [PATCH 32/48] Fix Windows --- .github/workflows/sycl-blender-build-and-test.yml | 8 ++++---- devops/actions/run-tests/windows/cts/action.yml | 2 +- devops/actions/run-tests/windows/e2e/action.yml | 2 +- lld/cmake/modules/AddLLD.cmake | 14 ++++++++++++-- llvm/CMakeLists.txt | 7 ++++++- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sycl-blender-build-and-test.yml b/.github/workflows/sycl-blender-build-and-test.yml index f4ec6f1af10a4..357f39f3af2f1 100644 --- a/.github/workflows/sycl-blender-build-and-test.yml +++ b/.github/workflows/sycl-blender-build-and-test.yml @@ -67,15 +67,15 @@ jobs: uses: ./devops/actions/blender/oidn with: cmake_install_prefix: ${{ env.OIDN_INSTALL_DIR }} - c_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/clang${{ runner.os == 'Windows' && '.exe' || '' }} - cxx_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/clang++${{ runner.os == 'Windows' && '.exe' || '' }} + c_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/dpclang${{ runner.os == 'Windows' && '.exe' || '' }} + cxx_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/dpclang++${{ runner.os == 'Windows' && '.exe' || '' }} - name: Build Embree uses: ./devops/actions/blender/embree with: cmake_install_prefix: ${{ env.EMBREE_INSTALL_DIR }} - c_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/clang${{ runner.os == 'Windows' && '.exe' || '' }} - cxx_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/clang++${{ runner.os == 'Windows' && '.exe' || '' }} + c_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/dpclang${{ runner.os == 'Windows' && '.exe' || '' }} + cxx_compiler: ${{ env.SYCL_INSTALL_DIR }}/bin/dpclang++${{ runner.os == 'Windows' && '.exe' || '' }} - name: Build Blender uses: ./devops/actions/blender/blender-build diff --git a/devops/actions/run-tests/windows/cts/action.yml b/devops/actions/run-tests/windows/cts/action.yml index 902f34c56a121..da8fdc88732b5 100644 --- a/devops/actions/run-tests/windows/cts/action.yml +++ b/devops/actions/run-tests/windows/cts/action.yml @@ -60,7 +60,7 @@ runs: -DSYCL_IMPLEMENTATION=DPCPP \ -DSYCL_CTS_EXCLUDE_TEST_CATEGORIES="$cts_exclude_filter" \ -DSYCL_CTS_ENABLE_OPENCL_INTEROP_TESTS=OFF \ - -DDPCPP_INSTALL_DIR="$(dirname $(which clang++))/.." \ + -DDPCPP_INSTALL_DIR="$(dirname $(which dpclang++))/.." \ -DCMAKE_CXX_COMPILER=cl \ -DCMAKE_BUILD_TYPE=Release \ $CMAKE_EXTRA_ARGS diff --git a/devops/actions/run-tests/windows/e2e/action.yml b/devops/actions/run-tests/windows/e2e/action.yml index f4b9e54b67ab3..f22bb0f65185c 100644 --- a/devops/actions/run-tests/windows/e2e/action.yml +++ b/devops/actions/run-tests/windows/e2e/action.yml @@ -64,7 +64,7 @@ runs: - name: Configure E2E tests shell: bash run: | - cmake -GNinja -B build-e2e -S./llvm/sycl/test-e2e -DCMAKE_CXX_COMPILER="${{ inputs.sycl_compiler || '$(which clang++).exe' }}" -DLEVEL_ZERO_LIBS_DIR="D:\\github\\level-zero_win-sdk\\lib" -DLEVEL_ZERO_INCLUDE="D:\\github\\level-zero_win-sdk\\include" -DLLVM_LIT="..\\llvm\\llvm\\utils\\lit\\lit.py" ${{ steps.cmake_opts.outputs.opts }} + cmake -GNinja -B build-e2e -S./llvm/sycl/test-e2e -DCMAKE_CXX_COMPILER="${{ inputs.sycl_compiler || '$(which dpclang++).exe' }}" -DLEVEL_ZERO_LIBS_DIR="D:\\github\\level-zero_win-sdk\\lib" -DLEVEL_ZERO_INCLUDE="D:\\github\\level-zero_win-sdk\\include" -DLLVM_LIT="..\\llvm\\llvm\\utils\\lit\\lit.py" ${{ steps.cmake_opts.outputs.opts }} - name: Keep track of files after configuring E2E step if: ${{ !cancelled() && inputs.binaries_artifact != '' && inputs.testing_mode != 'run-only' }} diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake index 37f73afa915f4..28c45cb8c977e 100644 --- a/lld/cmake/modules/AddLLD.cmake +++ b/lld/cmake/modules/AddLLD.cmake @@ -52,14 +52,24 @@ macro(add_lld_tool name) add_lld_executable(${name} ${ARGN}) if (LLD_BUILD_TOOLS) + # Install the real lld binary into the versioned DPC++ tools dir (e.g. + # lib/dpcpp-N/bin) so it doesn't conflict with a system LLVM, matching + # add_clang_tool. The public ld.lld/ld64.lld/lld-link/wasm-ld entry-points + # are symlinks/copies created via LLD_TOOLS_INSTALL_DIR, which is also + # redirected there (see llvm/CMakeLists.txt). + if(DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) + set(_lld_runtime_dest "${DPCPP_INSTALL_INTERNAL_BINDIR}") + else() + set(_lld_runtime_dest "${CMAKE_INSTALL_BINDIR}") + endif() get_target_export_arg(${name} LLD export_to_lldtargets) install(TARGETS ${name} ${export_to_lldtargets} - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + RUNTIME DESTINATION "${_lld_runtime_dest}" COMPONENT ${name}) if (LLVM_ENABLE_PDB) - install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL) + install(FILES $ DESTINATION "${_lld_runtime_dest}" COMPONENT ${name} OPTIONAL) endif() if(NOT CMAKE_CONFIGURATION_TYPES) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index e8a491a3132fb..a4359fb386df3 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -539,9 +539,14 @@ set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING # entry-points in ${CMAKE_INSTALL_BINDIR} are added by clang/tools/driver. # This block must be after project() so that CMAKE_SYSTEM_NAME is defined. set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") -set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING +set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING "Path for binary subdirectory (defaults to '${DPCPP_INSTALL_INTERNAL_BINDIR}')" FORCE) set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) +# lld resolves its own install dir via LLD_TOOLS_INSTALL_DIR (used for its +# ld.lld/ld64.lld/lld-link/wasm-ld symlinks); redirect it too so the linkers +# don't collide with a system LLVM. The real lld binary destination is patched +# separately in lld/cmake/modules/AddLLD.cmake, mirroring add_clang_tool. +set(LLD_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) # The default resource-dir formula is: dirname(binary)/../lib/clang/VERSION. # For binaries installed in lib/dpcpp-N/bin/ this resolves inside lib/dpcpp-N/ From 42c7929f6b49ab82dc8f30594a2872426325b3f7 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 6 Jul 2026 19:53:31 +0200 Subject: [PATCH 33/48] Fix for SYCL RTC --- sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp index c13929daf816b..39e5a38a3e39a 100644 --- a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp +++ b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp @@ -185,12 +185,8 @@ std::string getLibPathSuffix() { // derives the same (versioned) resource directory the bundled resource headers // and libraries are installed into. std::string getInternalBinSubPath() { -#ifdef _WIN32 - return "/bin/clang++"; -#else - return llvm::formatv("/{0}/dpcpp-{1}/bin/clang++", CLANG_INSTALL_LIBDIR_BASENAME, - DPCPP_VERSION_MAJOR); -#endif + return llvm::formatv("/{0}/dpcpp-{1}/bin/clang++", + CLANG_INSTALL_LIBDIR_BASENAME, DPCPP_VERSION_MAJOR); } class SYCLToolchain { static auto &getToolchainFS() { From d88713051a35bc92bbe76cd1d8c719ddddc52681 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 6 Jul 2026 21:03:54 +0200 Subject: [PATCH 34/48] Fix E2E --- clang/lib/Driver/ToolChains/Clang.cpp | 13 +++++++++---- clang/lib/Driver/ToolChains/SYCL.cpp | 16 +++++++++++----- .../jit-compiler/lib/rtc/DeviceCompilation.cpp | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 188c592192d8f..4ce1c435d2100 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -10641,8 +10641,10 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA, ClangArgs.push_back( TCArgs.MakeArgString(Twine("-mcmodel=") + A->getValue())); - SmallString<128> ClangPath(C.getDriver().Dir); - llvm::sys::path::append(ClangPath, "clang"); + // Resolve clang via the program search path: with the dpclang layout the + // real clang binary lives in lib/dpcpp-N/bin/, which the driver's own + // path may not point at directly (a Windows driver copy runs from bin/). + std::string ClangPath = getToolChain().GetProgramPath("clang"); const char *Clang = C.getArgs().MakeArgString(ClangPath); auto PostWrapCompileCmd = std::make_unique(JA, *this, ResponseFileSupport::None(), @@ -11209,8 +11211,11 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA, for (auto &Arg : Cmd->getArguments()) ForeachArgs.push_back(Arg); - SmallString<128> ForeachPath(C.getDriver().Dir); - llvm::sys::path::append(ForeachPath, "llvm-foreach"); + // Resolve llvm-foreach via the program search path so it is found in the + // versioned tools directory (lib/dpcpp-N/bin/) rather than assuming it sits + // right next to the driver, which is not the case for a Windows driver copy + // invoked from bin/. + std::string ForeachPath = getToolChain().GetProgramPath("llvm-foreach"); const char *Foreach = C.getArgs().MakeArgString(ForeachPath); C.addCommand(std::make_unique( JA, *this, ResponseFileSupport::None(), Foreach, ForeachArgs, diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index c090c4eb31e2e..e890f60562802 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -312,8 +312,11 @@ void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA, for (auto &Arg : InputCommand->getArguments()) ForeachArgs.push_back(Arg); - SmallString<128> ForeachPath(C.getDriver().Dir); - llvm::sys::path::append(ForeachPath, "llvm-foreach"); + // Resolve llvm-foreach via the program search path so it is found in the + // versioned tools directory (lib/dpcpp-N/bin/) rather than assuming it sits + // right next to the driver, which is not the case for a Windows driver copy + // invoked from bin/. + std::string ForeachPath = T->getToolChain().GetProgramPath("llvm-foreach"); const char *Foreach = C.getArgs().MakeArgString(ForeachPath); auto Cmd = std::make_unique(JA, *T, ResponseFileSupport::None(), @@ -968,9 +971,12 @@ const char *SYCL::Linker::constructLLVMLinkCommand( Objs.push_back( C.getArgs().MakeArgString(getToolChain().getInputFilename(II))); - // Get llvm-link path. - SmallString<128> ExecPath(C.getDriver().Dir); - llvm::sys::path::append(ExecPath, "llvm-link"); + // Get llvm-link path. Use GetProgramPath rather than assuming the tool sits + // next to the driver: with the dpclang layout the real companion tools live + // in lib/dpcpp-N/bin/ while a Windows driver copy is invoked from bin/, so + // the program search path (seeded in ToolChain's constructor) is what points + // at the versioned tools directory. + std::string ExecPath = getToolChain().GetProgramPath("llvm-link"); const char *Exec = C.getArgs().MakeArgString(ExecPath); auto AddLinkCommand = [this, &C, &JA, Exec](const char *Output, diff --git a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp index 39e5a38a3e39a..e11e41758b987 100644 --- a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp +++ b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp @@ -185,7 +185,7 @@ std::string getLibPathSuffix() { // derives the same (versioned) resource directory the bundled resource headers // and libraries are installed into. std::string getInternalBinSubPath() { - return llvm::formatv("/{0}/dpcpp-{1}/bin/clang++", + return llvm::formatv("/{0}/dpcpp-{1}/bin/clang++", CLANG_INSTALL_LIBDIR_BASENAME, DPCPP_VERSION_MAJOR); } class SYCLToolchain { From 75cfdcd89be773ccc4b29029bb207a201671732f Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 6 Jul 2026 22:02:46 +0200 Subject: [PATCH 35/48] Try to fix CI on Windows --- clang/lib/Driver/Driver.cpp | 38 ++++++++++++++++++---------------- clang/lib/Driver/ToolChain.cpp | 38 ++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 93f594599a06e..225562766e5fe 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3695,13 +3695,15 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, static bool runBundler(const SmallVectorImpl &InputArgs, Compilation &C) { - // Find bundler. - StringRef ExecPath(C.getArgs().MakeArgString(C.getDriver().Dir)); - llvm::ErrorOr BundlerBinary = - llvm::sys::findProgramByName("clang-offload-bundler", ExecPath); + // Find bundler. Resolve it via the toolchain program paths (which include + // the versioned dpclang tools dir, lib/dpcpp-N/bin/) rather than only the + // directory the driver runs from: on Windows the driver is a copy in bin/ + // and the bundler lives in the versioned dir, so a search restricted to + // C.getDriver().Dir would not find it. + std::string BundlerBinary = + C.getDriver().GetProgramPath("clang-offload-bundler", C.getDefaultToolChain()); SmallVector BundlerArgs; - BundlerArgs.push_back(BundlerBinary.getError() ? "clang-offload-bundler" - : BundlerBinary.get().c_str()); + BundlerArgs.push_back(BundlerBinary.c_str()); BundlerArgs.append(InputArgs); // Since this is run in real time and not in the toolchain, output the // command line if requested. @@ -3714,10 +3716,7 @@ static bool runBundler(const SmallVectorImpl &InputArgs, llvm::errs() << A << " "; llvm::errs() << '\n'; } - if (BundlerBinary.getError()) - return false; - - return !llvm::sys::ExecuteAndWait(BundlerBinary.get(), BundlerArgs); + return !llvm::sys::ExecuteAndWait(BundlerBinary, BundlerArgs); } static SmallVector getOffloadSections(Compilation &C, @@ -3731,15 +3730,20 @@ static SmallVector getOffloadSections(Compilation &C, return {}; // Use the bundler to grab the list of sections from the given archive - // or object. - StringRef ExecPath(C.getArgs().MakeArgString(C.getDriver().Dir)); - llvm::ErrorOr BundlerBinary = - llvm::sys::findProgramByName("clang-offload-bundler", ExecPath); + // or object. Resolve it via the toolchain program paths (which include the + // versioned dpclang tools dir, lib/dpcpp-N/bin/) rather than only the + // directory the driver runs from: on Windows the driver is a copy in bin/ + // and the bundler lives in the versioned dir. GetProgramPath falls back to + // the bare tool name when it can't be located, so this never dereferences an + // errored value (previously an unchecked ErrorOr::get() crashed here when + // the bundler was not next to the driver). + std::string BundlerBinary = + C.getDriver().GetProgramPath("clang-offload-bundler", C.getDefaultToolChain()); const char *Input = C.getArgs().MakeArgString(Twine("-input=") + File.str()); // Always use -type=ao for bundle checking. The 'bundles' are // actually archives. SmallVector BundlerArgs = { - BundlerBinary.get(), IsArchive ? "-type=ao" : "-type=o", Input, "-list"}; + BundlerBinary, IsArchive ? "-type=ao" : "-type=o", Input, "-list"}; // Since this is run in real time and not in the toolchain, output the // command line if requested. bool OutputOnly = C.getArgs().hasArg(options::OPT__HASH_HASH_HASH); @@ -3751,8 +3755,6 @@ static SmallVector getOffloadSections(Compilation &C, llvm::errs() << A << " "; llvm::errs() << '\n'; } - if (BundlerBinary.getError()) - return {}; llvm::SmallString<64> OutputFile( C.getDriver().GetTemporaryPath("bundle-list", "txt")); llvm::FileRemover OutputRemover(OutputFile.c_str()); @@ -3763,7 +3765,7 @@ static SmallVector getOffloadSections(Compilation &C, }; std::string ErrorMessage; - if (llvm::sys::ExecuteAndWait(BundlerBinary.get(), BundlerArgs, {}, Redirects, + if (llvm::sys::ExecuteAndWait(BundlerBinary, BundlerArgs, {}, Redirects, /*SecondsToWait*/ 0, /*MemoryLimit*/ 0, &ErrorMessage)) { // Could not get the information, return false diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 3827f4015c02f..7af19f8573797 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -108,20 +108,36 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, addIfExists(getFilePaths(), Path); // The real compiler tools (clang, clang++, llvm-ar, clang-offload-bundler, - // ...) are installed into a versioned DPC++ subdirectory so they don't - // conflict with a system LLVM installation. On Linux the public dpclang* - // entry-points in bin/ are symlinks into that directory, so D.Dir already - // points at it once the symlink is resolved. On Windows those entry-points - // are real copies that live in bin/, so D.Dir is bin/ and the companion - // tools are one directory removed; seed the versioned directory into the - // program search path so the driver can still find them. The existence - // check makes this a harmless duplicate on Linux and a no-op for install - // layouts that don't use the versioned directory at all. + // ...) are installed into a versioned DPC++ subdirectory (lib/dpcpp-N/bin/) + // so they don't conflict with a system LLVM installation. On Linux the + // public dpclang* entry-points in bin/ are symlinks into that directory, so + // D.Dir already points at it once the symlink is resolved. On Windows those + // entry-points are real copies that live in bin/, so D.Dir is bin/ and the + // companion tools are one directory removed; seed the versioned directory + // into the program search path so the driver can still find them. + // + // This is scoped to only fire for a real dpclang install layout: the + // versioned directory must exist, must be distinct from the directory the + // driver already runs from (D.Dir), and must actually contain the clang + // binary. That keeps it inert for a build tree (where the versioned dir + // isn't populated) and for the Linux install (where D.Dir already is the + // versioned dir), so libclang / non-driver consumers see no behavior change. { + std::string DpcppVersionedDir = + (llvm::Twine("dpcpp-") + llvm::Twine(DPCPP_VERSION_MAJOR)).str(); SmallString<128> InternalBin(findSYCLInstallRoot(D)); llvm::sys::path::append(InternalBin, CLANG_INSTALL_LIBDIR_BASENAME, - "dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR), "bin"); - if (getVFS().exists(InternalBin)) + DpcppVersionedDir, "bin"); + llvm::sys::path::remove_dots(InternalBin, /*remove_dot_dot=*/true); + // Normalize D.Dir the same way before comparing so the Linux install + // (where the resolved driver already lives in the versioned dir) is + // recognized as the same directory and skipped. + SmallString<128> DriverDir(D.Dir); + llvm::sys::path::remove_dots(DriverDir, /*remove_dot_dot=*/true); + SmallString<128> ClangProbe(InternalBin); + llvm::sys::path::append(ClangProbe, "clang"); + if (StringRef(InternalBin) != StringRef(DriverDir) && + getVFS().exists(ClangProbe)) getProgramPaths().push_back(std::string(InternalBin)); } } From fa3a81bbbb8369a43b5e6bf19f70451af20af516 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 6 Jul 2026 23:06:46 +0200 Subject: [PATCH 36/48] Fix CI --- clang/lib/Driver/ToolChain.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 7af19f8573797..8fab8a25e2bfe 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -117,11 +117,11 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, // into the program search path so the driver can still find them. // // This is scoped to only fire for a real dpclang install layout: the - // versioned directory must exist, must be distinct from the directory the - // driver already runs from (D.Dir), and must actually contain the clang - // binary. That keeps it inert for a build tree (where the versioned dir - // isn't populated) and for the Linux install (where D.Dir already is the - // versioned dir), so libclang / non-driver consumers see no behavior change. + // versioned directory must exist and must be distinct from the directory the + // driver already runs from (D.Dir). That keeps it inert for a build tree + // (where the versioned dir isn't populated) and for the Linux install (where + // the resolved driver already is the versioned dir), so libclang and other + // non-driver consumers see no behavior change. { std::string DpcppVersionedDir = (llvm::Twine("dpcpp-") + llvm::Twine(DPCPP_VERSION_MAJOR)).str(); @@ -134,10 +134,8 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, // recognized as the same directory and skipped. SmallString<128> DriverDir(D.Dir); llvm::sys::path::remove_dots(DriverDir, /*remove_dot_dot=*/true); - SmallString<128> ClangProbe(InternalBin); - llvm::sys::path::append(ClangProbe, "clang"); if (StringRef(InternalBin) != StringRef(DriverDir) && - getVFS().exists(ClangProbe)) + getVFS().exists(InternalBin)) getProgramPaths().push_back(std::string(InternalBin)); } } From 02c10da9afa1be34cb37147aa33946c7dc87b329 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Mon, 6 Jul 2026 23:50:46 +0200 Subject: [PATCH 37/48] Fix E2E test --- clang/lib/Options/OptionUtils.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/clang/lib/Options/OptionUtils.cpp b/clang/lib/Options/OptionUtils.cpp index e5aefa012f679..7fd81080a8500 100644 --- a/clang/lib/Options/OptionUtils.cpp +++ b/clang/lib/Options/OptionUtils.cpp @@ -230,6 +230,31 @@ std::string clang::GetResourcesPath(StringRef BinaryPath) { // path of the embedding binary, which for LLVM binaries will be in bin/. // ../lib gets us to lib/ in both cases. P = llvm::sys::path::parent_path(Dir); + + // In the dpclang install layout the real tools live in + // /lib/dpcpp-N/bin, and the resources are installed alongside them + // in /lib/dpcpp-N/lib/clang/N (see get_clang_resource_dir() in + // cmake/Modules/GetClangResourceDir.cmake). On Linux the public dpclang* + // drivers are symlinks resolved into that versioned bin dir, so the plain + // ../lib formula above already lands in /lib/dpcpp-N/lib. On Windows + // the drivers are real copies that live in /bin, so ../lib lands in + // /lib and misses the versioned subdirectory. Detect that case (the + // binary sits directly in a "bin" dir whose sibling versioned lib exists) + // and redirect into lib/dpcpp-N/lib so the resource dir matches where the + // files were actually installed. + // The final append below adds "/clang/N", so P must be the + // directory that contains the versioned libdir, i.e. /lib/dpcpp-N. + if (llvm::sys::path::filename(Dir) == "bin") { + SmallString<128> Versioned(P); + llvm::sys::path::append( + Versioned, CLANG_INSTALL_LIBDIR_BASENAME, + ("dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR)).str()); + SmallString<128> VersionedLib(Versioned); + llvm::sys::path::append(VersionedLib, CLANG_INSTALL_LIBDIR_BASENAME); + if (llvm::sys::fs::is_directory(VersionedLib)) + P = Versioned; + } + // This search path is also created in the COFF driver of lld, so any // changes here also needs to happen in lld/COFF/Driver.cpp llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang", From 3c066a505552a2d6daf21086d9593416692441ff Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 7 Jul 2026 01:07:24 +0200 Subject: [PATCH 38/48] Fix some paths --- .../workflows/sycl-pytorch-build-and-test.yml | 7 ---- clang/lib/Driver/Driver.cpp | 8 ++--- clang/lib/Driver/ToolChains/SYCL.cpp | 33 ++++++++++--------- clang/test/Driver/sycl-device-lib.cpp | 6 ++-- libdevice/cmake/modules/SYCLLibdevice.cmake | 13 ++------ .../lib/rtc/DeviceCompilation.cpp | 7 ++-- sycl/CMakeLists.txt | 10 +++++- sycl/test-e2e/lit.site.cfg.py.in | 2 +- 8 files changed, 39 insertions(+), 47 deletions(-) diff --git a/.github/workflows/sycl-pytorch-build-and-test.yml b/.github/workflows/sycl-pytorch-build-and-test.yml index 6cf8c7656eec9..cb73729945d1f 100644 --- a/.github/workflows/sycl-pytorch-build-and-test.yml +++ b/.github/workflows/sycl-pytorch-build-and-test.yml @@ -57,13 +57,6 @@ jobs: tar -xf $TOOLCHAIN_ARTIFACT_FILENAME -C install rm $TOOLCHAIN_ARTIFACT_FILENAME - - name: Create dpclang Symlinks - shell: bash - run: | - # Symlink to the expected compiler names until we provide them. - ln -sf "$SYCL_INSTALL_DIR/bin/clang" "$SYCL_INSTALL_DIR/bin/dpclang" - ln -sf "$SYCL_INSTALL_DIR/bin/clang++" "$SYCL_INSTALL_DIR/bin/dpclang++" - - name: Checkout PyTorch uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 225562766e5fe..601ee058b164f 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3700,8 +3700,8 @@ static bool runBundler(const SmallVectorImpl &InputArgs, // directory the driver runs from: on Windows the driver is a copy in bin/ // and the bundler lives in the versioned dir, so a search restricted to // C.getDriver().Dir would not find it. - std::string BundlerBinary = - C.getDriver().GetProgramPath("clang-offload-bundler", C.getDefaultToolChain()); + std::string BundlerBinary = C.getDriver().GetProgramPath( + "clang-offload-bundler", C.getDefaultToolChain()); SmallVector BundlerArgs; BundlerArgs.push_back(BundlerBinary.c_str()); BundlerArgs.append(InputArgs); @@ -3737,8 +3737,8 @@ static SmallVector getOffloadSections(Compilation &C, // the bare tool name when it can't be located, so this never dereferences an // errored value (previously an unchecked ErrorOr::get() crashed here when // the bundler was not next to the driver). - std::string BundlerBinary = - C.getDriver().GetProgramPath("clang-offload-bundler", C.getDefaultToolChain()); + std::string BundlerBinary = C.getDriver().GetProgramPath( + "clang-offload-bundler", C.getDefaultToolChain()); const char *Input = C.getArgs().MakeArgString(Twine("-input=") + File.str()); // Always use -type=ao for bundle checking. The 'bundles' are // actually archives. diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index e890f60562802..8b80bf8908bc9 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -176,26 +176,13 @@ void SYCLInstallationDetector::addLibspirvLinkArgs( void SYCLInstallationDetector::getSYCLDeviceLibPath( llvm::SmallVector, 4> &DeviceLibPaths) const { - std::string LinuxDirSuffix = - llvm::formatv("/{0}/dpcpp-{1}/sycl", CLANG_INSTALL_LIBDIR_BASENAME, - DPCPP_VERSION_MAJOR); + // The device library bitcode files are installed directly into the libdir + // (e.g. lib/) on all platforms. for (const auto &IC : InstallationCandidates) { - if (!HostTriple.isWindowsMSVCEnvironment() && - !HostTriple.isWindowsItaniumEnvironment()) { - SmallString<128> InstallPath(IC); - llvm::sys::path::append(InstallPath, LinuxDirSuffix); - DeviceLibPaths.emplace_back(InstallPath); - } SmallString<128> InstallPath(IC); llvm::sys::path::append(InstallPath, CLANG_INSTALL_LIBDIR_BASENAME); DeviceLibPaths.emplace_back(InstallPath); } - if (!HostTriple.isWindowsMSVCEnvironment() && - !HostTriple.isWindowsItaniumEnvironment()) { - SmallString<128> Path(D.SysRoot); - llvm::sys::path::append(Path, LinuxDirSuffix); - DeviceLibPaths.emplace_back(Path.str()); - } SmallString<128> Path(D.SysRoot); llvm::sys::path::append(Path, CLANG_INSTALL_LIBDIR_BASENAME); DeviceLibPaths.emplace_back(Path.str()); @@ -209,11 +196,13 @@ void SYCLInstallationDetector::addSYCLIncludeArgs( // Add the SYCL header search locations in the specified order. // /include/sycl/stl_wrappers // /include + // /lib/dpcpp-N/include // Use the install root from InstallationCandidates (which already accounts // for versioned binary subdirectories like lib/dpcpp-N/bin/). - SmallString<128> IncludePath(InstallationCandidates.empty() + SmallString<128> InstallRoot(InstallationCandidates.empty() ? StringRef(D.Dir + "/..") : StringRef(InstallationCandidates[0])); + SmallString<128> IncludePath(InstallRoot); llvm::sys::path::append(IncludePath, "include"); // This is used to provide our wrappers around STL headers that provide // additional functions/template specializations when the user includes those @@ -225,6 +214,18 @@ void SYCLInstallationDetector::addSYCLIncludeArgs( CC1Args.push_back(DriverArgs.MakeArgString(STLWrappersPath)); CC1Args.push_back("-internal-isystem"); CC1Args.push_back(DriverArgs.MakeArgString(IncludePath)); + // The wrapper headers (e.g. ) are + // installed into the versioned DPC++ include directory + // (lib/dpcpp-N/include) so they don't pollute the top-level include/. Add + // that directory too so those relative includes resolve. In the build tree + // the headers still live under /include, which is already on the + // search path above; a nonexistent path here is harmless. + SmallString<128> VersionedIncludePath(InstallRoot); + llvm::sys::path::append(VersionedIncludePath, CLANG_INSTALL_LIBDIR_BASENAME, + "dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR), + "include"); + CC1Args.push_back("-internal-isystem"); + CC1Args.push_back(DriverArgs.MakeArgString(VersionedIncludePath)); } void SYCLInstallationDetector::print(llvm::raw_ostream &OS) const { diff --git a/clang/test/Driver/sycl-device-lib.cpp b/clang/test/Driver/sycl-device-lib.cpp index bdeeb8e868323..4ec58817752d2 100644 --- a/clang/test/Driver/sycl-device-lib.cpp +++ b/clang/test/Driver/sycl-device-lib.cpp @@ -9,9 +9,9 @@ /// test behavior of device library default link // RUN: %clangxx -fsycl --offload-new-driver %s --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_LINK_DEFAULT -// SYCL_DEVICE_LIB_LINK_DEFAULT: clang{{.*}} "-mlink-builtin-bitcode" "{{.*}}/lib/dpcpp-{{[0-9]+}}/sycl/libsycl-crt.bc" -// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/dpcpp-{{[0-9]+}}/sycl/libsycl-cmath.bc -// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/dpcpp-{{[0-9]+}}/sycl/libsycl-imf.bc +// SYCL_DEVICE_LIB_LINK_DEFAULT: clang{{.*}} "-mlink-builtin-bitcode" "{{.*}}/lib/libsycl-crt.bc" +// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/libsycl-cmath.bc +// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/libsycl-imf.bc // SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: "-mlink-builtin-bitcode-postopt" /// ########################################################################### diff --git a/libdevice/cmake/modules/SYCLLibdevice.cmake b/libdevice/cmake/modules/SYCLLibdevice.cmake index 648e4da85ca7a..7e91b5c3b30a5 100644 --- a/libdevice/cmake/modules/SYCLLibdevice.cmake +++ b/libdevice/cmake/modules/SYCLLibdevice.cmake @@ -10,16 +10,9 @@ endif() set(bc-suffix bc) set(install_dest_obj lib${LLVM_LIBDIR_SUFFIX}) -if(WIN32) - # On Windows, install to lib/ - set(install_dest_bc lib${LLVM_LIBDIR_SUFFIX}) - set(bc_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") -else() - # On other platforms, install to lib/dpcpp-/sycl - set(bc_dir "lib${LLVM_LIBDIR_SUFFIX}/dpcpp-${DPCPP_VERSION_MAJOR}/sycl") - set(install_dest_bc ${bc_dir}) - set(bc_binary_dir "${CMAKE_BINARY_DIR}/${bc_dir}") -endif() +# Install the device library bitcode files into lib/ on all platforms. +set(install_dest_bc lib${LLVM_LIBDIR_SUFFIX}) +set(bc_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") string(CONCAT sycl_pvc_target_opt "-fsycl-targets=" diff --git a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp index e11e41758b987..62eb7e9202514 100644 --- a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp +++ b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp @@ -170,12 +170,9 @@ template <> struct std::hash { namespace { std::string getLibPathSuffix() { -#ifdef _WIN32 + // The device library bitcode files are installed directly into the libdir + // (e.g. lib/) on all platforms. return llvm::formatv("/{0}/", CLANG_INSTALL_LIBDIR_BASENAME); -#else - return llvm::formatv("/{0}/dpcpp-{1}/sycl/", CLANG_INSTALL_LIBDIR_BASENAME, - DPCPP_VERSION_MAJOR); -#endif } // Location of the internal `clang++` binary relative to the toolchain root. diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 37591e5f8765d..2a7e6a7184247 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -156,6 +156,14 @@ set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION set(SYCL_INCLUDE_DIR "include") set(SYCL_INCLUDE_BUILD_DIR ${LLVM_BINARY_DIR}/${SYCL_INCLUDE_DIR}) +# The wrapper headers (e.g. ) are +# relocated into the versioned DPC++ include directory so the top-level +# include/ isn't polluted with a "std" directory that could shadow or conflict +# with a system toolchain. The compiler driver adds this directory to the +# SYCL header search path (see addSYCLIncludeArgs in +# clang/lib/Driver/ToolChains/SYCL.cpp). +set(SYCL_STD_INCLUDE_DIR "lib${LLVM_LIBDIR_SUFFIX}/dpcpp-${DPCPP_VERSION_MAJOR}/include") + if(NOT SYCL_HEADERS_ONLY) add_llvm_external_project(opencl) list(FIND LLVM_ENABLE_PROJECTS opencl OPENCL_PROJ_FOUND) @@ -308,7 +316,7 @@ add_custom_command( # Copy SYCL headers from source to install directory install(DIRECTORY "${sycl_inc_dir}/sycl" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers) install(DIRECTORY "${sycl_inc_dir}/CL" DESTINATION ${SYCL_INCLUDE_DIR}/ COMPONENT sycl-headers) -install(DIRECTORY "${sycl_inc_dir}/std" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers) +install(DIRECTORY "${sycl_inc_dir}/std" DESTINATION ${SYCL_STD_INCLUDE_DIR} COMPONENT sycl-headers) install(DIRECTORY "${UNIFIED_RUNTIME_INCLUDE_DIR}/unified-runtime" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers) if (WIN32) diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index 2444b12d7927d..c881f2e456682 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -28,7 +28,7 @@ config.sycl_tools_dir = config.llvm_tools_dir config.sycl_include = os.path.join(config.dpcpp_root_dir, 'include') config.sycl_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" config.sycl_libs_dir = os.path.join(config.dpcpp_root_dir, ('bin' if platform.system() == "Windows" else '@SYCL_LIBDIR_BASENAME@')) -config.sycl_device_libs_dir = os.path.join(config.dpcpp_root_dir, ('@SYCL_LIBDIR_BASENAME@' if platform.system() == "Windows" else "@SYCL_LIBDIR_BASENAME@/dpcpp-@DPCPP_VERSION_MAJOR@/sycl")) +config.sycl_device_libs_dir = os.path.join(config.dpcpp_root_dir, '@SYCL_LIBDIR_BASENAME@') config.opencl_libs_dir = (os.path.dirname("@OpenCL_LIBRARY@") if "@OpenCL_LIBRARY@" else "") config.level_zero_libs_dir = "@LEVEL_ZERO_LIBS_DIR@" From bae507e1b0caddffb74d7626f526374b6b3f741f Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 7 Jul 2026 12:02:16 +0200 Subject: [PATCH 39/48] Apply CR comment --- libclc/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index aa8826b10964b..a35bf8d679ab4 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -107,9 +107,9 @@ else() # PREFIX form, which is never version-prefixed. Reusing LIBCLC_INSTALL_DIR # here would emit the libraries into a versioned directory the build-tree # driver does not search (breaking in-tree check-sycl/libclc tests). - cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH _libclc_build_prefix ) + cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH LIBCLC_OUTPUT_LIBRARY_DIR ) get_clang_resource_dir( LIBCLC_OUTPUT_LIBRARY_DIR PREFIX ${_libclc_build_prefix} ) - cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_LIBDIR_BASENAME} ) + cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_OUTPUT_LIBRARY_DIR} ) endif() if( NOT LIBCLC_USE_SPIRV_BACKEND ) From 7291c6bd99d3c939f3dd59072c6299fbc2cd8de7 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 7 Jul 2026 13:03:34 +0200 Subject: [PATCH 40/48] Apply CR comment --- libclc/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index a35bf8d679ab4..756ed2fa61a75 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -108,8 +108,8 @@ else() # here would emit the libraries into a versioned directory the build-tree # driver does not search (breaking in-tree check-sycl/libclc tests). cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH LIBCLC_OUTPUT_LIBRARY_DIR ) - get_clang_resource_dir( LIBCLC_OUTPUT_LIBRARY_DIR PREFIX ${_libclc_build_prefix} ) - cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_OUTPUT_LIBRARY_DIR} ) + get_clang_resource_dir( LIBCLC_OUTPUT_LIBRARY_DIR PREFIX ${LIBCLC_OUTPUT_LIBRARY_DIR} ) + cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_LIBDIR_BASENAME} ) endif() if( NOT LIBCLC_USE_SPIRV_BACKEND ) From 4efea35ddb9d16780d1b2e6fc82eaf984e032207 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 7 Jul 2026 16:27:17 +0200 Subject: [PATCH 41/48] Revert changing location of devicelib files --- clang/lib/Driver/ToolChains/SYCL.cpp | 17 +++++++++++++++-- clang/test/Driver/sycl-device-lib.cpp | 6 +++--- libdevice/cmake/modules/SYCLLibdevice.cmake | 13 ++++++++++--- .../jit-compiler/lib/rtc/DeviceCompilation.cpp | 7 +++++-- sycl/test-e2e/lit.site.cfg.py.in | 2 +- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 8b80bf8908bc9..9fa1da8411b8d 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -176,13 +176,26 @@ void SYCLInstallationDetector::addLibspirvLinkArgs( void SYCLInstallationDetector::getSYCLDeviceLibPath( llvm::SmallVector, 4> &DeviceLibPaths) const { - // The device library bitcode files are installed directly into the libdir - // (e.g. lib/) on all platforms. + std::string LinuxDirSuffix = + llvm::formatv("/{0}/dpcpp-{1}/sycl", CLANG_INSTALL_LIBDIR_BASENAME, + DPCPP_VERSION_MAJOR); for (const auto &IC : InstallationCandidates) { + if (!HostTriple.isWindowsMSVCEnvironment() && + !HostTriple.isWindowsItaniumEnvironment()) { + SmallString<128> InstallPath(IC); + llvm::sys::path::append(InstallPath, LinuxDirSuffix); + DeviceLibPaths.emplace_back(InstallPath); + } SmallString<128> InstallPath(IC); llvm::sys::path::append(InstallPath, CLANG_INSTALL_LIBDIR_BASENAME); DeviceLibPaths.emplace_back(InstallPath); } + if (!HostTriple.isWindowsMSVCEnvironment() && + !HostTriple.isWindowsItaniumEnvironment()) { + SmallString<128> Path(D.SysRoot); + llvm::sys::path::append(Path, LinuxDirSuffix); + DeviceLibPaths.emplace_back(Path.str()); + } SmallString<128> Path(D.SysRoot); llvm::sys::path::append(Path, CLANG_INSTALL_LIBDIR_BASENAME); DeviceLibPaths.emplace_back(Path.str()); diff --git a/clang/test/Driver/sycl-device-lib.cpp b/clang/test/Driver/sycl-device-lib.cpp index 4ec58817752d2..bdeeb8e868323 100644 --- a/clang/test/Driver/sycl-device-lib.cpp +++ b/clang/test/Driver/sycl-device-lib.cpp @@ -9,9 +9,9 @@ /// test behavior of device library default link // RUN: %clangxx -fsycl --offload-new-driver %s --sysroot=%S/Inputs/SYCL -### 2>&1 \ // RUN: | FileCheck %s -check-prefix=SYCL_DEVICE_LIB_LINK_DEFAULT -// SYCL_DEVICE_LIB_LINK_DEFAULT: clang{{.*}} "-mlink-builtin-bitcode" "{{.*}}/lib/libsycl-crt.bc" -// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/libsycl-cmath.bc -// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/libsycl-imf.bc +// SYCL_DEVICE_LIB_LINK_DEFAULT: clang{{.*}} "-mlink-builtin-bitcode" "{{.*}}/lib/dpcpp-{{[0-9]+}}/sycl/libsycl-crt.bc" +// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/dpcpp-{{[0-9]+}}/sycl/libsycl-cmath.bc +// SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: {{.*}}/lib/dpcpp-{{[0-9]+}}/sycl/libsycl-imf.bc // SYCL_DEVICE_LIB_LINK_DEFAULT-SAME: "-mlink-builtin-bitcode-postopt" /// ########################################################################### diff --git a/libdevice/cmake/modules/SYCLLibdevice.cmake b/libdevice/cmake/modules/SYCLLibdevice.cmake index 7e91b5c3b30a5..648e4da85ca7a 100644 --- a/libdevice/cmake/modules/SYCLLibdevice.cmake +++ b/libdevice/cmake/modules/SYCLLibdevice.cmake @@ -10,9 +10,16 @@ endif() set(bc-suffix bc) set(install_dest_obj lib${LLVM_LIBDIR_SUFFIX}) -# Install the device library bitcode files into lib/ on all platforms. -set(install_dest_bc lib${LLVM_LIBDIR_SUFFIX}) -set(bc_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +if(WIN32) + # On Windows, install to lib/ + set(install_dest_bc lib${LLVM_LIBDIR_SUFFIX}) + set(bc_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +else() + # On other platforms, install to lib/dpcpp-/sycl + set(bc_dir "lib${LLVM_LIBDIR_SUFFIX}/dpcpp-${DPCPP_VERSION_MAJOR}/sycl") + set(install_dest_bc ${bc_dir}) + set(bc_binary_dir "${CMAKE_BINARY_DIR}/${bc_dir}") +endif() string(CONCAT sycl_pvc_target_opt "-fsycl-targets=" diff --git a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp index 62eb7e9202514..e11e41758b987 100644 --- a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp +++ b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp @@ -170,9 +170,12 @@ template <> struct std::hash { namespace { std::string getLibPathSuffix() { - // The device library bitcode files are installed directly into the libdir - // (e.g. lib/) on all platforms. +#ifdef _WIN32 return llvm::formatv("/{0}/", CLANG_INSTALL_LIBDIR_BASENAME); +#else + return llvm::formatv("/{0}/dpcpp-{1}/sycl/", CLANG_INSTALL_LIBDIR_BASENAME, + DPCPP_VERSION_MAJOR); +#endif } // Location of the internal `clang++` binary relative to the toolchain root. diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index c881f2e456682..2444b12d7927d 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -28,7 +28,7 @@ config.sycl_tools_dir = config.llvm_tools_dir config.sycl_include = os.path.join(config.dpcpp_root_dir, 'include') config.sycl_obj_root = "@CMAKE_CURRENT_BINARY_DIR@" config.sycl_libs_dir = os.path.join(config.dpcpp_root_dir, ('bin' if platform.system() == "Windows" else '@SYCL_LIBDIR_BASENAME@')) -config.sycl_device_libs_dir = os.path.join(config.dpcpp_root_dir, '@SYCL_LIBDIR_BASENAME@') +config.sycl_device_libs_dir = os.path.join(config.dpcpp_root_dir, ('@SYCL_LIBDIR_BASENAME@' if platform.system() == "Windows" else "@SYCL_LIBDIR_BASENAME@/dpcpp-@DPCPP_VERSION_MAJOR@/sycl")) config.opencl_libs_dir = (os.path.dirname("@OpenCL_LIBRARY@") if "@OpenCL_LIBRARY@" else "") config.level_zero_libs_dir = "@LEVEL_ZERO_LIBS_DIR@" From b7171a2bb25cd9f022a68b3196c668b909e78a7e Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 7 Jul 2026 18:10:36 +0200 Subject: [PATCH 42/48] Apply CR comments --- clang/lib/Driver/Driver.cpp | 9 +++++++++ clang/lib/Driver/ToolChains/CommonArgs.cpp | 8 +++++--- clang/tools/driver/CMakeLists.txt | 17 ++++++----------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 601ee058b164f..8fe51febfe362 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3702,6 +3702,11 @@ static bool runBundler(const SmallVectorImpl &InputArgs, // C.getDriver().Dir would not find it. std::string BundlerBinary = C.getDriver().GetProgramPath( "clang-offload-bundler", C.getDefaultToolChain()); + // GetProgramPath falls back to the bare tool name when it can't locate the + // tool. Bail out if it isn't a runnable path rather than trying to execute an + // unresolved name (which could otherwise pick up an unrelated tool on PATH). + if (!llvm::sys::fs::can_execute(BundlerBinary)) + return false; SmallVector BundlerArgs; BundlerArgs.push_back(BundlerBinary.c_str()); BundlerArgs.append(InputArgs); @@ -3739,6 +3744,10 @@ static SmallVector getOffloadSections(Compilation &C, // the bundler was not next to the driver). std::string BundlerBinary = C.getDriver().GetProgramPath( "clang-offload-bundler", C.getDefaultToolChain()); + // Bail out if the tool couldn't be resolved to a runnable path rather than + // trying to execute an unresolved bare name. + if (!llvm::sys::fs::can_execute(BundlerBinary)) + return {}; const char *Input = C.getArgs().MakeArgString(Twine("-input=") + File.str()); // Always use -type=ao for bundle checking. The 'bundles' are // actually archives. diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 371105d0234ca..bb43ceeb8e6be 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -25,6 +25,7 @@ #include "Solaris.h" #include "ToolChains/Cuda.h" #include "clang/Basic/CodeGenOptions.h" +#include "clang/Basic/Version.h" #include "clang/Config/config.h" #include "clang/Driver/Action.h" #include "clang/Driver/Compilation.h" @@ -86,9 +87,10 @@ llvm::SmallString<128> clang::driver::findSYCLInstallRoot(const Driver &D) { // The dpclang install layout keeps the real tools in lib/dpcpp-/bin // (the public dpclang* drivers in bin/ are just symlinks into it, and the // driver resolves them, so D.Dir points at the versioned directory). Step - // out of that versioned subdirectory too. This mirrors AMDGPU.cpp matching - // "aomp*" enclosing directories by name. - if (ParentName.starts_with("dpcpp-")) { + // out of that versioned subdirectory too. Match the exact expected directory + // name for this compiler's version rather than any "dpcpp-*" so an unrelated + // sibling directory can't be mistaken for it. + if (ParentName == "dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR).str()) { ParentDir = llvm::sys::path::parent_path(ParentDir); ParentName = llvm::sys::path::filename(ParentDir); } diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 44e949c18b22f..2994d6d500d6f 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -105,19 +105,14 @@ endforeach() # the real binaries live in ${DPCPP_INSTALL_INTERNAL_BINDIR} alongside all companion # tools so that the driver can find them via its own executable path. if(CLANG_BUILD_TOOLS) - # Locate LLVM's install_symlink() helper script. This mirrors the loop in - # llvm_install_symlink() in LLVM's AddLLVM.cmake: LLVMInstallSymlink.cmake + # Locate LLVM's install_symlink() helper script. LLVMInstallSymlink.cmake # lives in llvm/cmake/modules for an in-tree build but in # /lib/cmake/llvm for a standalone clang build. Both candidate - # directories are on CMAKE_MODULE_PATH, so we walk it and take whichever one - # actually exists rather than hardcoding a path that only works for one build - # layout. - foreach(path ${CMAKE_MODULE_PATH}) - if(EXISTS ${path}/LLVMInstallSymlink.cmake) - set(INSTALL_SYMLINK ${path}/LLVMInstallSymlink.cmake) - break() - endif() - endforeach() + # directories are on CMAKE_MODULE_PATH, so search it (and only it) for + # whichever one actually exists rather than hardcoding a path that only works + # for one build layout. + find_file(INSTALL_SYMLINK LLVMInstallSymlink.cmake + PATHS ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH) # Both Linux and Windows relocate the real tools into lib/dpcpp-N/bin/ so # they don't collide with a system LLVM. The public dpclang* entry-points go From 05e80f68ddac441fe44f095a13ffde7ffac29f1d Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Tue, 7 Jul 2026 18:58:57 +0200 Subject: [PATCH 43/48] Apply CR comments --- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- cmake/Modules/GetClangResourceDir.cmake | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index bb43ceeb8e6be..a145092902495 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -87,7 +87,7 @@ llvm::SmallString<128> clang::driver::findSYCLInstallRoot(const Driver &D) { // The dpclang install layout keeps the real tools in lib/dpcpp-/bin // (the public dpclang* drivers in bin/ are just symlinks into it, and the // driver resolves them, so D.Dir points at the versioned directory). Step - // out of that versioned subdirectory too. Match the exact expected directory + // out of that versioned subdirectory to match the exact expected directory // name for this compiler's version rather than any "dpcpp-*" so an unrelated // sibling directory can't be mistaken for it. if (ParentName == "dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR).str()) { diff --git a/cmake/Modules/GetClangResourceDir.cmake b/cmake/Modules/GetClangResourceDir.cmake index 2f32fc599dd56..976bf0fd311aa 100644 --- a/cmake/Modules/GetClangResourceDir.cmake +++ b/cmake/Modules/GetClangResourceDir.cmake @@ -19,11 +19,10 @@ function(get_clang_resource_dir out_var) set(ret_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}) # When the compiler tools are relocated into a versioned DPC++ libdir # (e.g. lib/dpcpp-N/bin), the driver resolves its resource dir relative to - # the executable as /lib/clang/N (see GetResourcesPath() in - # clang/lib/Options/OptionUtils.cpp). For install destinations (callers - # that pass no PREFIX) mirror that layout so the resource headers and - # libraries are installed where the driver actually looks, instead of the - # top-level lib/clang which would otherwise require a bridging symlink. + # the executable as /lib/clang/N. For install destinations + # (callers that pass no PREFIX) mirror that layout so the resource headers + # and libraries are installed where the driver actually looks, instead of + # the top-level lib/clang which would otherwise require a bridging symlink. if(NOT ARG_PREFIX AND DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) cmake_path(GET DPCPP_INSTALL_INTERNAL_BINDIR PARENT_PATH _dpcpp_parent) if(_dpcpp_parent) From 7f5938bc31b139979327666f85aacc16e37475b3 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 10 Jul 2026 17:34:29 +0200 Subject: [PATCH 44/48] Apply CR comments --- .github/workflows/sycl-linux-run-tests.yml | 6 +- .../workflows/sycl-prebuilt-e2e-container.yml | 2 +- .../workflows/sycl-pytorch-build-and-test.yml | 4 +- .github/workflows/sycl-windows-run-tests.yml | 4 +- .github/workflows/sycl-yarpgen.yml | 2 +- clang/cmake/modules/AddClang.cmake | 4 +- clang/include/clang/Driver/CommonArgs.h | 5 - .../clang/Driver/SyclInstallationDetector.h | 6 - clang/lib/Driver/Driver.cpp | 47 +++---- clang/lib/Driver/ToolChain.cpp | 33 ----- clang/lib/Driver/ToolChains/Clang.cpp | 19 +-- clang/lib/Driver/ToolChains/CommonArgs.cpp | 45 ------- clang/lib/Driver/ToolChains/Linux.cpp | 19 +-- clang/lib/Driver/ToolChains/SYCL.cpp | 124 ++++++------------ clang/lib/Options/OptionUtils.cpp | 25 ---- clang/test/Driver/sycl-device-old-model.cpp | 2 +- clang/test/Driver/sycl-device.cpp | 2 +- .../Driver/sycl-host-compiler-old-model.cpp | 12 +- clang/test/Driver/sycl-host-compiler.cpp | 12 +- .../test/Driver/sycl-offload-header-check.cpp | 2 +- clang/test/Driver/sycl-offload-jit.cpp | 4 +- clang/test/Driver/sycl-offload-nvptx.cpp | 4 +- clang/test/Driver/sycl-offload-old-model.cpp | 8 +- clang/test/Driver/sycl-offload.cpp | 8 +- clang/test/Driver/sycl.cpp | 6 +- clang/tools/CMakeLists.txt | 1 + clang/tools/dpllvm/CMakeLists.txt | 48 +++++++ clang/tools/dpllvm/dpllvm.cpp | 73 +++++++++++ clang/tools/driver/CMakeLists.txt | 67 ---------- cmake/Modules/GetClangResourceDir.cmake | 12 -- devops/actions/run-tests/benchmark/action.yml | 12 +- devops/scripts/benchmarks/utils/utils.py | 4 +- libclc/CMakeLists.txt | 24 +--- lld/cmake/modules/AddLLD.cmake | 14 +- llvm/CMakeLists.txt | 23 +--- llvm/cmake/modules/AddLLVM.cmake | 21 +-- llvm/runtimes/CMakeLists.txt | 11 -- .../lib/rtc/DeviceCompilation.cpp | 16 +-- sycl/CMakeLists.txt | 12 +- sycl/test-e2e/CMakeLists.txt | 19 +-- sycl/test-e2e/lit.site.cfg.py.in | 6 +- sycl/tools/syclbin-dump/CMakeLists.txt | 2 +- 42 files changed, 262 insertions(+), 508 deletions(-) create mode 100644 clang/tools/dpllvm/CMakeLists.txt create mode 100644 clang/tools/dpllvm/dpllvm.cpp diff --git a/.github/workflows/sycl-linux-run-tests.yml b/.github/workflows/sycl-linux-run-tests.yml index 7b141392c5e57..41918bb9a29ae 100644 --- a/.github/workflows/sycl-linux-run-tests.yml +++ b/.github/workflows/sycl-linux-run-tests.yml @@ -321,9 +321,9 @@ jobs: tar xf sycl_linux.tar.gz -C toolchain echo PATH=$PWD/toolchain/bin/:$PATH >> $GITHUB_ENV echo LD_LIBRARY_PATH=$PWD/toolchain/lib/:$LD_LIBRARY_PATH >> $GITHUB_ENV - - run: which dpclang++ sycl-ls - - run: sycl-ls --verbose - - run: SYCL_UR_TRACE=1 sycl-ls + - run: which dpclang++ dpsycl-ls + - run: dpsycl-ls --verbose + - run: SYCL_UR_TRACE=1 dpsycl-ls - name: Print IGC version run: | if [ -f /usr/local/lib/igc/IGCTAG.txt ]; then diff --git a/.github/workflows/sycl-prebuilt-e2e-container.yml b/.github/workflows/sycl-prebuilt-e2e-container.yml index a326e98c5d73d..15891fc59f6f2 100644 --- a/.github/workflows/sycl-prebuilt-e2e-container.yml +++ b/.github/workflows/sycl-prebuilt-e2e-container.yml @@ -109,7 +109,7 @@ jobs: echo LD_LIBRARY_PATH=$PWD/toolchain/lib:$LD_LIBRARY_PATH >> $GITHUB_ENV echo PATH=$PWD/toolchain/bin:$PATH >> $GITHUB_ENV - run: | - sycl-ls + dpsycl-ls - name: Run E2E tests uses: ./devops/actions/run-tests/linux/e2e timeout-minutes: 20 diff --git a/.github/workflows/sycl-pytorch-build-and-test.yml b/.github/workflows/sycl-pytorch-build-and-test.yml index cb73729945d1f..08634e72a2080 100644 --- a/.github/workflows/sycl-pytorch-build-and-test.yml +++ b/.github/workflows/sycl-pytorch-build-and-test.yml @@ -145,8 +145,8 @@ jobs: # Install PyTorch. pip3 install ./dist/*.whl - - name: Run sycl-ls - run: sycl-ls --verbose + - name: Run dpsycl-ls + run: dpsycl-ls --verbose - name: Run PyTorch XPU Sanity Check shell: bash diff --git a/.github/workflows/sycl-windows-run-tests.yml b/.github/workflows/sycl-windows-run-tests.yml index ff0ca1fa2ef35..c9a499b060f19 100644 --- a/.github/workflows/sycl-windows-run-tests.yml +++ b/.github/workflows/sycl-windows-run-tests.yml @@ -135,9 +135,9 @@ jobs: echo "PATH=$env:GITHUB_WORKSPACE\\install\\bin;$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append echo "LIB=$env:GITHUB_WORKSPACE\\install\\lib;$env:LIB" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - run: | - sycl-ls + dpsycl-ls - run: | - sycl-ls --verbose + dpsycl-ls --verbose - name: Run E2E Tests if: inputs.tests_selector == 'e2e' diff --git a/.github/workflows/sycl-yarpgen.yml b/.github/workflows/sycl-yarpgen.yml index 985c2d3932b6a..df0a5735951b2 100644 --- a/.github/workflows/sycl-yarpgen.yml +++ b/.github/workflows/sycl-yarpgen.yml @@ -60,7 +60,7 @@ jobs: - run: which dpclang++ - - run: sycl-ls + - run: dpsycl-ls - name: Set up yarpgen run: | diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index f7d1f6137b1b7..e2112d7c326e2 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -183,11 +183,11 @@ macro(add_clang_tool name) get_target_export_arg(${name} Clang export_to_clangtargets) install(TARGETS ${name} ${export_to_clangtargets} - RUNTIME DESTINATION "${DPCPP_INSTALL_INTERNAL_BINDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) if (LLVM_ENABLE_PDB) - install(FILES $ DESTINATION "${DPCPP_INSTALL_INTERNAL_BINDIR}" COMPONENT ${name} OPTIONAL) + install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL) endif() if(NOT LLVM_ENABLE_IDE) diff --git a/clang/include/clang/Driver/CommonArgs.h b/clang/include/clang/Driver/CommonArgs.h index 9b10610820b0b..1a0232145ac67 100644 --- a/clang/include/clang/Driver/CommonArgs.h +++ b/clang/include/clang/Driver/CommonArgs.h @@ -22,11 +22,6 @@ namespace clang { namespace driver { - -/// Walk up from \p D.Dir until a directory containing include/sycl is found -/// and return it as the install root. Falls back to D.Dir/.. if not found. -llvm::SmallString<128> findSYCLInstallRoot(const Driver &D); - namespace tools { void addPathIfExists(const Driver &D, const Twine &Path, diff --git a/clang/include/clang/Driver/SyclInstallationDetector.h b/clang/include/clang/Driver/SyclInstallationDetector.h index 9597a556cb542..75b83e873020e 100644 --- a/clang/include/clang/Driver/SyclInstallationDetector.h +++ b/clang/include/clang/Driver/SyclInstallationDetector.h @@ -38,12 +38,6 @@ class SYCLInstallationDetector { // Return the filesystem path to the detected SYCL runtime library. StringRef getSYCLRTLibPath() const { return SYCLRTLibPath; } - // Return the install root (the directory containing include/ and lib/). - StringRef getInstallRoot() const { - return InstallationCandidates.empty() - ? StringRef() - : StringRef(InstallationCandidates[0]); - } void print(llvm::raw_ostream &OS) const; private: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 8fe51febfe362..93f594599a06e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -3695,20 +3695,13 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, static bool runBundler(const SmallVectorImpl &InputArgs, Compilation &C) { - // Find bundler. Resolve it via the toolchain program paths (which include - // the versioned dpclang tools dir, lib/dpcpp-N/bin/) rather than only the - // directory the driver runs from: on Windows the driver is a copy in bin/ - // and the bundler lives in the versioned dir, so a search restricted to - // C.getDriver().Dir would not find it. - std::string BundlerBinary = C.getDriver().GetProgramPath( - "clang-offload-bundler", C.getDefaultToolChain()); - // GetProgramPath falls back to the bare tool name when it can't locate the - // tool. Bail out if it isn't a runnable path rather than trying to execute an - // unresolved name (which could otherwise pick up an unrelated tool on PATH). - if (!llvm::sys::fs::can_execute(BundlerBinary)) - return false; + // Find bundler. + StringRef ExecPath(C.getArgs().MakeArgString(C.getDriver().Dir)); + llvm::ErrorOr BundlerBinary = + llvm::sys::findProgramByName("clang-offload-bundler", ExecPath); SmallVector BundlerArgs; - BundlerArgs.push_back(BundlerBinary.c_str()); + BundlerArgs.push_back(BundlerBinary.getError() ? "clang-offload-bundler" + : BundlerBinary.get().c_str()); BundlerArgs.append(InputArgs); // Since this is run in real time and not in the toolchain, output the // command line if requested. @@ -3721,7 +3714,10 @@ static bool runBundler(const SmallVectorImpl &InputArgs, llvm::errs() << A << " "; llvm::errs() << '\n'; } - return !llvm::sys::ExecuteAndWait(BundlerBinary, BundlerArgs); + if (BundlerBinary.getError()) + return false; + + return !llvm::sys::ExecuteAndWait(BundlerBinary.get(), BundlerArgs); } static SmallVector getOffloadSections(Compilation &C, @@ -3735,24 +3731,15 @@ static SmallVector getOffloadSections(Compilation &C, return {}; // Use the bundler to grab the list of sections from the given archive - // or object. Resolve it via the toolchain program paths (which include the - // versioned dpclang tools dir, lib/dpcpp-N/bin/) rather than only the - // directory the driver runs from: on Windows the driver is a copy in bin/ - // and the bundler lives in the versioned dir. GetProgramPath falls back to - // the bare tool name when it can't be located, so this never dereferences an - // errored value (previously an unchecked ErrorOr::get() crashed here when - // the bundler was not next to the driver). - std::string BundlerBinary = C.getDriver().GetProgramPath( - "clang-offload-bundler", C.getDefaultToolChain()); - // Bail out if the tool couldn't be resolved to a runnable path rather than - // trying to execute an unresolved bare name. - if (!llvm::sys::fs::can_execute(BundlerBinary)) - return {}; + // or object. + StringRef ExecPath(C.getArgs().MakeArgString(C.getDriver().Dir)); + llvm::ErrorOr BundlerBinary = + llvm::sys::findProgramByName("clang-offload-bundler", ExecPath); const char *Input = C.getArgs().MakeArgString(Twine("-input=") + File.str()); // Always use -type=ao for bundle checking. The 'bundles' are // actually archives. SmallVector BundlerArgs = { - BundlerBinary, IsArchive ? "-type=ao" : "-type=o", Input, "-list"}; + BundlerBinary.get(), IsArchive ? "-type=ao" : "-type=o", Input, "-list"}; // Since this is run in real time and not in the toolchain, output the // command line if requested. bool OutputOnly = C.getArgs().hasArg(options::OPT__HASH_HASH_HASH); @@ -3764,6 +3751,8 @@ static SmallVector getOffloadSections(Compilation &C, llvm::errs() << A << " "; llvm::errs() << '\n'; } + if (BundlerBinary.getError()) + return {}; llvm::SmallString<64> OutputFile( C.getDriver().GetTemporaryPath("bundle-list", "txt")); llvm::FileRemover OutputRemover(OutputFile.c_str()); @@ -3774,7 +3763,7 @@ static SmallVector getOffloadSections(Compilation &C, }; std::string ErrorMessage; - if (llvm::sys::ExecuteAndWait(BundlerBinary, BundlerArgs, {}, Redirects, + if (llvm::sys::ExecuteAndWait(BundlerBinary.get(), BundlerArgs, {}, Redirects, /*SecondsToWait*/ 0, /*MemoryLimit*/ 0, &ErrorMessage)) { // Could not get the information, return false diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 8fab8a25e2bfe..2d1888c21b198 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -16,7 +16,6 @@ #include "ToolChains/InterfaceStubs.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Sanitizers.h" -#include "clang/Basic/Version.h" #include "clang/Config/config.h" #include "clang/Driver/Action.h" #include "clang/Driver/CommonArgs.h" @@ -106,38 +105,6 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, getFilePaths().push_back(*Path); for (const auto &Path : getArchSpecificLibPaths()) addIfExists(getFilePaths(), Path); - - // The real compiler tools (clang, clang++, llvm-ar, clang-offload-bundler, - // ...) are installed into a versioned DPC++ subdirectory (lib/dpcpp-N/bin/) - // so they don't conflict with a system LLVM installation. On Linux the - // public dpclang* entry-points in bin/ are symlinks into that directory, so - // D.Dir already points at it once the symlink is resolved. On Windows those - // entry-points are real copies that live in bin/, so D.Dir is bin/ and the - // companion tools are one directory removed; seed the versioned directory - // into the program search path so the driver can still find them. - // - // This is scoped to only fire for a real dpclang install layout: the - // versioned directory must exist and must be distinct from the directory the - // driver already runs from (D.Dir). That keeps it inert for a build tree - // (where the versioned dir isn't populated) and for the Linux install (where - // the resolved driver already is the versioned dir), so libclang and other - // non-driver consumers see no behavior change. - { - std::string DpcppVersionedDir = - (llvm::Twine("dpcpp-") + llvm::Twine(DPCPP_VERSION_MAJOR)).str(); - SmallString<128> InternalBin(findSYCLInstallRoot(D)); - llvm::sys::path::append(InternalBin, CLANG_INSTALL_LIBDIR_BASENAME, - DpcppVersionedDir, "bin"); - llvm::sys::path::remove_dots(InternalBin, /*remove_dot_dot=*/true); - // Normalize D.Dir the same way before comparing so the Linux install - // (where the resolved driver already lives in the versioned dir) is - // recognized as the same directory and skipped. - SmallString<128> DriverDir(D.Dir); - llvm::sys::path::remove_dots(DriverDir, /*remove_dot_dot=*/true); - if (StringRef(InternalBin) != StringRef(DriverDir) && - getVFS().exists(InternalBin)) - getProgramPaths().push_back(std::string(InternalBin)); - } } ToolChain::OrderedMultilibs ToolChain::getOrderedMultilibs() const { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 4ce1c435d2100..69f1d8ecdf221 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5231,8 +5231,8 @@ void Clang::ConstructHostCompilerJob(Compilation &C, const JobAction &JA, if (!TCArgs.hasArg(options::OPT_nostdlibinc, options::OPT_nostdinc)) { // Add default header search directories. - SmallString<128> BaseDir(findSYCLInstallRoot(C.getDriver())); - llvm::sys::path::append(BaseDir, "include"); + SmallString<128> BaseDir(C.getDriver().Dir); + llvm::sys::path::append(BaseDir, "..", "include"); SmallString<128> SYCLDir(BaseDir); llvm::sys::path::append(SYCLDir, "sycl"); // This is used to provide our wrappers around STL headers that provide @@ -10641,10 +10641,8 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA, ClangArgs.push_back( TCArgs.MakeArgString(Twine("-mcmodel=") + A->getValue())); - // Resolve clang via the program search path: with the dpclang layout the - // real clang binary lives in lib/dpcpp-N/bin/, which the driver's own - // path may not point at directly (a Windows driver copy runs from bin/). - std::string ClangPath = getToolChain().GetProgramPath("clang"); + SmallString<128> ClangPath(C.getDriver().Dir); + llvm::sys::path::append(ClangPath, "clang"); const char *Clang = C.getArgs().MakeArgString(ClangPath); auto PostWrapCompileCmd = std::make_unique(JA, *this, ResponseFileSupport::None(), @@ -11211,11 +11209,8 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA, for (auto &Arg : Cmd->getArguments()) ForeachArgs.push_back(Arg); - // Resolve llvm-foreach via the program search path so it is found in the - // versioned tools directory (lib/dpcpp-N/bin/) rather than assuming it sits - // right next to the driver, which is not the case for a Windows driver copy - // invoked from bin/. - std::string ForeachPath = getToolChain().GetProgramPath("llvm-foreach"); + SmallString<128> ForeachPath(C.getDriver().Dir); + llvm::sys::path::append(ForeachPath, "llvm-foreach"); const char *Foreach = C.getArgs().MakeArgString(ForeachPath); C.addCommand(std::make_unique( JA, *this, ResponseFileSupport::None(), Foreach, ForeachArgs, @@ -11952,7 +11947,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA, // -sycl-device-library-location= provides the location in which the // SYCL device libraries can be found. SmallString<128> DeviceLibDir(D.Dir); - llvm::sys::path::append(DeviceLibDir, "..", CLANG_INSTALL_LIBDIR_BASENAME); + llvm::sys::path::append(DeviceLibDir, "..", "lib"); // Check the library location candidates for the the libsycl-crt library // and use that location. Base the location on relative to driver if this // is not resolved. diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index a145092902495..fd69ba86c5a81 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -25,7 +25,6 @@ #include "Solaris.h" #include "ToolChains/Cuda.h" #include "clang/Basic/CodeGenOptions.h" -#include "clang/Basic/Version.h" #include "clang/Config/config.h" #include "clang/Driver/Action.h" #include "clang/Driver/Compilation.h" @@ -69,50 +68,6 @@ using namespace clang::driver::tools; using namespace clang; using namespace llvm::opt; -llvm::SmallString<128> clang::driver::findSYCLInstallRoot(const Driver &D) { - // Deduce the install root from the directory the driver was invoked from, - // recognizing the directory layouts the compiler may be installed into. - // This mirrors RocmInstallationDetector::getInstallationPathCandidates() in - // AMDGPU.cpp, which walks up from the clang binary by matching the names of - // the enclosing directories rather than guessing a fixed depth. - StringRef ParentDir = llvm::sys::path::parent_path(D.Dir); - StringRef ParentName = llvm::sys::path::filename(ParentDir); - - // Some layouts install the compiler into lib//bin, so go up again. - if (ParentName == "bin") { - ParentDir = llvm::sys::path::parent_path(ParentDir); - ParentName = llvm::sys::path::filename(ParentDir); - } - - // The dpclang install layout keeps the real tools in lib/dpcpp-/bin - // (the public dpclang* drivers in bin/ are just symlinks into it, and the - // driver resolves them, so D.Dir points at the versioned directory). Step - // out of that versioned subdirectory to match the exact expected directory - // name for this compiler's version rather than any "dpcpp-*" so an unrelated - // sibling directory can't be mistaken for it. - if (ParentName == "dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR).str()) { - ParentDir = llvm::sys::path::parent_path(ParentDir); - ParentName = llvm::sys::path::filename(ParentDir); - } - - // Some layouts nest the compiler under lib/llvm/bin, so back up out of the - // lib directory as well. Honor a custom libdir name (e.g. lib64). - if (ParentName == CLANG_INSTALL_LIBDIR_BASENAME) - ParentDir = llvm::sys::path::parent_path(ParentDir); - - // Validate the deduced root by checking for the SYCL headers it should - // contain; if they are not present, fall back to one level up from D.Dir. - llvm::SmallString<128> Root(ParentDir); - llvm::SmallString<128> Probe(Root); - llvm::sys::path::append(Probe, "include", "sycl"); - if (!D.getVFS().exists(Probe)) { - Root = D.Dir; - llvm::sys::path::append(Root, ".."); - llvm::sys::path::remove_dots(Root, /*remove_dot_dot=*/true); - } - return Root; -} - static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args, const llvm::Triple &Triple) { if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry)) diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index 61fbf2a577d75..e6ecd00c050dc 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -382,21 +382,10 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs // libc++.so in D.Dir+"/../lib/". Detect this path. // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported. - // Also handles the SYCL runtime library: when binaries live in a versioned - // subdirectory (e.g. lib/dpcpp-N/bin/), findSYCLInstallRoot walks up to - // find the root that contains /libsycl.so. - { - SmallString<128> SYCLRoot = findSYCLInstallRoot(D); - SmallString<128> SYCLLibProbe(SYCLRoot); - llvm::sys::path::append(SYCLLibProbe, CLANG_INSTALL_LIBDIR_BASENAME, - "libsycl.so"); - if (StringRef(SYCLRoot).starts_with(SysRoot) && - (Args.hasArg(options::OPT_fsycl) || D.getVFS().exists(SYCLLibProbe))) { - SmallString<128> SYCLLib(SYCLRoot); - llvm::sys::path::append(SYCLLib, CLANG_INSTALL_LIBDIR_BASENAME); - addPathIfExists(D, SYCLLib, Paths); - } - } + if (StringRef(D.Dir).starts_with(SysRoot) && + (Args.hasArg(options::OPT_fsycl) || + D.getVFS().exists(D.Dir + "/../lib/libsycl.so"))) + addPathIfExists(D, D.Dir + "/../lib", Paths); addPathIfExists(D, concat(SysRoot, "/lib"), Paths); addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths); diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index 9fa1da8411b8d..31e16ba241e45 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -32,10 +32,7 @@ SYCLInstallationDetector::SYCLInstallationDetector( // 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> InstallRoot = findSYCLInstallRoot(D); - - SmallString<128> DriverDir(InstallRoot); + SmallString<128> DriverDir(D.Dir); #if 0 // !INTEL_CUSTOMIZATION if (HostTriple.isWindowsMSVCEnvironment() || @@ -44,10 +41,10 @@ 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 (InstallRoot.starts_with(SysRoot) && + if (DriverDir.starts_with(SysRoot) && Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { - SmallString<128> LibDir(InstallRoot); - llvm::sys::path::append(LibDir, CLANG_INSTALL_LIBDIR_BASENAME); + SmallString<128> LibDir(DriverDir); + llvm::sys::path::append(LibDir, "..", CLANG_INSTALL_LIBDIR_BASENAME); // Verify SYCL runtime library exists SmallString<128> SYCLLibPath(LibDir); @@ -57,30 +54,24 @@ SYCLInstallationDetector::SYCLInstallationDetector( SYCLRTLibPath = LibDir; } } else { - SmallString<128> LibPath(InstallRoot); - llvm::sys::path::append(LibPath, CLANG_INSTALL_LIBDIR_BASENAME, - HostTriple.str(), "libsycl.so"); - // Flat lib path for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF builds, - // where the library is installed directly in the libdir with no triple - // subdir. - SmallString<128> FlatLibPath(InstallRoot); - llvm::sys::path::append(FlatLibPath, CLANG_INSTALL_LIBDIR_BASENAME, + SmallString<128> LibPath(DriverDir); + llvm::sys::path::append(LibPath, "..", CLANG_INSTALL_LIBDIR_BASENAME, HostTriple.str(), "libsycl.so"); + // Flat lib path for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF builds, + // where the library is installed directly in lib/ with no triple subdir. + SmallString<128> FlatLibPath(DriverDir); + llvm::sys::path::append(FlatLibPath, "..", CLANG_INSTALL_LIBDIR_BASENAME, "libsycl.so"); - if (InstallRoot.starts_with(SysRoot) && + if (DriverDir.starts_with(SysRoot) && Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { - // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in // - if (D.getVFS().exists(LibPath)) { - DriverDir = InstallRoot; - llvm::sys::path::append(DriverDir, CLANG_INSTALL_LIBDIR_BASENAME, - HostTriple.str()); - } - // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF: library is in the libdir - else if (D.getVFS().exists(FlatLibPath)) { - DriverDir = InstallRoot; - llvm::sys::path::append(DriverDir, CLANG_INSTALL_LIBDIR_BASENAME); - } else - return; // Neither path exists: broken install, leave SYCLRTLibPath + // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in lib// + if (D.getVFS().exists(LibPath)) + llvm::sys::path::append(DriverDir, "..", CLANG_INSTALL_LIBDIR_BASENAME, HostTriple.str()); + // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF: library is in lib/ + else if (D.getVFS().exists(FlatLibPath)) + llvm::sys::path::append(DriverDir, "..", CLANG_INSTALL_LIBDIR_BASENAME); + else + return; // Neither path exists : broken install, leave SYCLRTLibPath // unset SYCLRTLibPath = DriverDir; @@ -88,34 +79,28 @@ SYCLInstallationDetector::SYCLInstallationDetector( } #else // !INTEL_CUSTOMIZATION // Intel: SYCL RT is libsycl.so; Windows lib path is handled at link stage. - SmallString<128> LibPath(InstallRoot); - llvm::sys::path::append(LibPath, CLANG_INSTALL_LIBDIR_BASENAME, + SmallString<128> LibPath(DriverDir); + llvm::sys::path::append(LibPath, "..", CLANG_INSTALL_LIBDIR_BASENAME, HostTriple.str(), "libsycl.so"); // Flat lib path for LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF builds, - // where the library is installed directly in the libdir with no triple - // subdir. - SmallString<128> FlatLibPath(InstallRoot); - llvm::sys::path::append(FlatLibPath, CLANG_INSTALL_LIBDIR_BASENAME, + // where the library is installed directly in lib/ with no triple subdir. + SmallString<128> FlatLibPath(DriverDir); + llvm::sys::path::append(FlatLibPath, "..", CLANG_INSTALL_LIBDIR_BASENAME, "libsycl.so"); - if (InstallRoot.starts_with(SysRoot) && + if (DriverDir.starts_with(SysRoot) && Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { - // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in // - if (D.getVFS().exists(LibPath)) { - DriverDir = InstallRoot; - llvm::sys::path::append(DriverDir, CLANG_INSTALL_LIBDIR_BASENAME, - HostTriple.str()); - } - // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF: library is in the libdir - else if (D.getVFS().exists(FlatLibPath)) { - DriverDir = InstallRoot; - llvm::sys::path::append(DriverDir, CLANG_INSTALL_LIBDIR_BASENAME); - } - if (!DriverDir.equals(InstallRoot)) - SYCLRTLibPath = DriverDir; + // We put driver in bin/compiler, so one more ../ than llorg. + if (D.getVFS().exists(DriverDir + "/../../lib/libsycl.so")) + llvm::sys::path::append(DriverDir, "..", "..", + CLANG_INSTALL_LIBDIR_BASENAME); + else + llvm::sys::path::append(DriverDir, "..", CLANG_INSTALL_LIBDIR_BASENAME); + + SYCLRTLibPath = DriverDir; } #endif // !INTEL_CUSTOMIZATION - InstallationCandidates.emplace_back(InstallRoot); + InstallationCandidates.emplace_back(D.Dir + "/.."); } static llvm::SmallString<64> @@ -207,15 +192,10 @@ void SYCLInstallationDetector::addSYCLIncludeArgs( return; } // Add the SYCL header search locations in the specified order. - // /include/sycl/stl_wrappers - // /include - // /lib/dpcpp-N/include - // Use the install root from InstallationCandidates (which already accounts - // for versioned binary subdirectories like lib/dpcpp-N/bin/). - SmallString<128> InstallRoot(InstallationCandidates.empty() - ? StringRef(D.Dir + "/..") - : StringRef(InstallationCandidates[0])); - SmallString<128> IncludePath(InstallRoot); + // ../include/sycl/stl_wrappers + // ../include + SmallString<128> IncludePath(D.Dir); + llvm::sys::path::append(IncludePath, ".."); llvm::sys::path::append(IncludePath, "include"); // This is used to provide our wrappers around STL headers that provide // additional functions/template specializations when the user includes those @@ -227,18 +207,6 @@ void SYCLInstallationDetector::addSYCLIncludeArgs( CC1Args.push_back(DriverArgs.MakeArgString(STLWrappersPath)); CC1Args.push_back("-internal-isystem"); CC1Args.push_back(DriverArgs.MakeArgString(IncludePath)); - // The wrapper headers (e.g. ) are - // installed into the versioned DPC++ include directory - // (lib/dpcpp-N/include) so they don't pollute the top-level include/. Add - // that directory too so those relative includes resolve. In the build tree - // the headers still live under /include, which is already on the - // search path above; a nonexistent path here is harmless. - SmallString<128> VersionedIncludePath(InstallRoot); - llvm::sys::path::append(VersionedIncludePath, CLANG_INSTALL_LIBDIR_BASENAME, - "dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR), - "include"); - CC1Args.push_back("-internal-isystem"); - CC1Args.push_back(DriverArgs.MakeArgString(VersionedIncludePath)); } void SYCLInstallationDetector::print(llvm::raw_ostream &OS) const { @@ -326,11 +294,8 @@ void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA, for (auto &Arg : InputCommand->getArguments()) ForeachArgs.push_back(Arg); - // Resolve llvm-foreach via the program search path so it is found in the - // versioned tools directory (lib/dpcpp-N/bin/) rather than assuming it sits - // right next to the driver, which is not the case for a Windows driver copy - // invoked from bin/. - std::string ForeachPath = T->getToolChain().GetProgramPath("llvm-foreach"); + SmallString<128> ForeachPath(C.getDriver().Dir); + llvm::sys::path::append(ForeachPath, "llvm-foreach"); const char *Foreach = C.getArgs().MakeArgString(ForeachPath); auto Cmd = std::make_unique(JA, *T, ResponseFileSupport::None(), @@ -985,12 +950,9 @@ const char *SYCL::Linker::constructLLVMLinkCommand( Objs.push_back( C.getArgs().MakeArgString(getToolChain().getInputFilename(II))); - // Get llvm-link path. Use GetProgramPath rather than assuming the tool sits - // next to the driver: with the dpclang layout the real companion tools live - // in lib/dpcpp-N/bin/ while a Windows driver copy is invoked from bin/, so - // the program search path (seeded in ToolChain's constructor) is what points - // at the versioned tools directory. - std::string ExecPath = getToolChain().GetProgramPath("llvm-link"); + // Get llvm-link path. + SmallString<128> ExecPath(C.getDriver().Dir); + llvm::sys::path::append(ExecPath, "llvm-link"); const char *Exec = C.getArgs().MakeArgString(ExecPath); auto AddLinkCommand = [this, &C, &JA, Exec](const char *Output, diff --git a/clang/lib/Options/OptionUtils.cpp b/clang/lib/Options/OptionUtils.cpp index 7fd81080a8500..e5aefa012f679 100644 --- a/clang/lib/Options/OptionUtils.cpp +++ b/clang/lib/Options/OptionUtils.cpp @@ -230,31 +230,6 @@ std::string clang::GetResourcesPath(StringRef BinaryPath) { // path of the embedding binary, which for LLVM binaries will be in bin/. // ../lib gets us to lib/ in both cases. P = llvm::sys::path::parent_path(Dir); - - // In the dpclang install layout the real tools live in - // /lib/dpcpp-N/bin, and the resources are installed alongside them - // in /lib/dpcpp-N/lib/clang/N (see get_clang_resource_dir() in - // cmake/Modules/GetClangResourceDir.cmake). On Linux the public dpclang* - // drivers are symlinks resolved into that versioned bin dir, so the plain - // ../lib formula above already lands in /lib/dpcpp-N/lib. On Windows - // the drivers are real copies that live in /bin, so ../lib lands in - // /lib and misses the versioned subdirectory. Detect that case (the - // binary sits directly in a "bin" dir whose sibling versioned lib exists) - // and redirect into lib/dpcpp-N/lib so the resource dir matches where the - // files were actually installed. - // The final append below adds "/clang/N", so P must be the - // directory that contains the versioned libdir, i.e. /lib/dpcpp-N. - if (llvm::sys::path::filename(Dir) == "bin") { - SmallString<128> Versioned(P); - llvm::sys::path::append( - Versioned, CLANG_INSTALL_LIBDIR_BASENAME, - ("dpcpp-" + llvm::Twine(DPCPP_VERSION_MAJOR)).str()); - SmallString<128> VersionedLib(Versioned); - llvm::sys::path::append(VersionedLib, CLANG_INSTALL_LIBDIR_BASENAME); - if (llvm::sys::fs::is_directory(VersionedLib)) - P = Versioned; - } - // This search path is also created in the COFF driver of lld, so any // changes here also needs to happen in lld/COFF/Driver.cpp llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang", diff --git a/clang/test/Driver/sycl-device-old-model.cpp b/clang/test/Driver/sycl-device-old-model.cpp index 6353e787127ab..8fc8bfb86f929 100644 --- a/clang/test/Driver/sycl-device-old-model.cpp +++ b/clang/test/Driver/sycl-device-old-model.cpp @@ -6,7 +6,7 @@ /// Check "-fsycl-is-device" is passed when compiling for device: // RUN: %clang -### -fsycl-device-only --no-offload-new-driver %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s -// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{[^"]*}}include" +// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{[^"]*}}bin{{[/\\]+}}..{{[/\\]+}}include" /// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl" /// or "-fsycl-device-only" or both: diff --git a/clang/test/Driver/sycl-device.cpp b/clang/test/Driver/sycl-device.cpp index 3098bb8603bc0..8013b64d7386f 100644 --- a/clang/test/Driver/sycl-device.cpp +++ b/clang/test/Driver/sycl-device.cpp @@ -8,7 +8,7 @@ // RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s // RUN: %clang -### --config=%S/Inputs/empty.cfg -fsycl-device-only %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s -// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{.*}}include" +// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" /// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl" /// or "-fsycl-device-only" or both: diff --git a/clang/test/Driver/sycl-host-compiler-old-model.cpp b/clang/test/Driver/sycl-host-compiler-old-model.cpp index 9c318d0dfc2f1..fb9af06364295 100644 --- a/clang/test/Driver/sycl-host-compiler-old-model.cpp +++ b/clang/test/Driver/sycl-host-compiler-old-model.cpp @@ -6,9 +6,9 @@ // HOST_COMPILER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}" // HOST_COMPILER: g++{{.*}} "-c" "-include" "[[INTHEADER]]" // HOST_COMPILER-SAME: "-iquote" -// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl" -// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" // HOST_COMPILER-SAME: "-o" "[[HOSTOBJ:.+\.o]]" // HOST_COMPILER: ld{{.*}} "[[HOSTOBJ]]" @@ -17,9 +17,9 @@ // HOST_COMPILER_CL: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer={{.*}}" // HOST_COMPILER_CL: cl{{.*}} "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]" // HOST_COMPILER_CL-SAME: "/external:W0" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" // HOST_COMPILER_CL: link{{.*}} "[[HOSTOBJ]]" /// check for additional host options diff --git a/clang/test/Driver/sycl-host-compiler.cpp b/clang/test/Driver/sycl-host-compiler.cpp index 90fa034e08190..477ee562864cc 100644 --- a/clang/test/Driver/sycl-host-compiler.cpp +++ b/clang/test/Driver/sycl-host-compiler.cpp @@ -12,9 +12,9 @@ // HOST_COMPILER: g++{{.*}} "[[APPENDFILESRC]]" // HOST_COMPILER-SAME: "-c" "-include" "[[INTHEADER]]" // HOST_COMPILER-SAME: "-iquote" -// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl" -// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER-SAME: "-isystem" "{{.*[/\\]}}include" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER-SAME: "-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" // HOST_COMPILER-SAME: "-o" "[[HOSTOBJ:.+\.o]]" // HOST_COMPILER: clang-offload-bundler{{.*}} "-output=[[BUNDLEOBJ:.+\.o]]" "-input=[[DEVICEBC]]" "-input=[[HOSTOBJ]]" // HOST_COMPILER: clang-linker-wrapper{{.*}} "[[BUNDLEOBJ]]" @@ -29,9 +29,9 @@ // HOST_COMPILER_CL: cl{{.*}} "[[APPENDFILESRC]]" // HOST_COMPILER_CL-SAME: "-c" "-Fo[[HOSTOBJ:.+\.obj]]" "-FI" "[[INTHEADER]]" // HOST_COMPILER_CL-SAME: "/external:W0" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" -// HOST_COMPILER_CL-SAME: "/external:I" "{{.*[/\\]}}include" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// HOST_COMPILER_CL-SAME: "/external:I" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" // HOST_COMPILER_CL: clang-offload-bundler{{.*}} "-output=[[BUNDLEOBJ:.+\.obj]]" "-input=[[DEVICEBC]]" "-input=[[HOSTOBJ]]" // HOST_COMPILER_CL: clang-linker-wrapper{{.*}} "[[BUNDLEOBJ]]" diff --git a/clang/test/Driver/sycl-offload-header-check.cpp b/clang/test/Driver/sycl-offload-header-check.cpp index bc80b7a1af9b5..43f03d56a064e 100644 --- a/clang/test/Driver/sycl-offload-header-check.cpp +++ b/clang/test/Driver/sycl-offload-header-check.cpp @@ -10,6 +10,6 @@ // RUN: %clang -### -fsycl %s 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-HEADER %s // CHECK-HEADER: clang{{.*}} "-fsycl-int-header=[[HEADER:.+\.h]]" -// CHECK-HEADER: {{.*}} "-internal-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER: {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-NOT: clang{{.*}} "-include-internal-header" "[[HEADER]]" // CHECK-HEADER: clang{{.*}} "-include-internal-header" "{{.*}}_dirname{{.+}}.h" diff --git a/clang/test/Driver/sycl-offload-jit.cpp b/clang/test/Driver/sycl-offload-jit.cpp index cffe31f3045f1..3466ee711f5b9 100644 --- a/clang/test/Driver/sycl-offload-jit.cpp +++ b/clang/test/Driver/sycl-offload-jit.cpp @@ -33,8 +33,8 @@ // The test also checks if SYCL header include paths are added to the SYCL host and device compilation. // INTEL-RUN: %clang --offload-new-driver --sysroot=%S/Inputs/SYCL -### --target=x86_64-unknown-linux-gnu -fsycl %s 2>&1 \ // RUN: | FileCheck -check-prefixes=CHECK-LSYCL,CHECK-SYCL-HEADERS-HOST,CHECK-SYCL-HEADERS-DEVICE %s -// CHECK-SYCL-HEADERS-DEVICE: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}include" -// CHECK-SYCL-HEADERS-HOST: "-fsycl-is-host"{{.*}} "-internal-isystem" "{{.*}}include" +// CHECK-SYCL-HEADERS-DEVICE: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" +// CHECK-SYCL-HEADERS-HOST: "-fsycl-is-host"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" // CHECK-LSYCL: clang-linker-wrapper{{.*}} "{{.*}}libsycl.so" // Check that -fsycl -fno-sycl does not pass libsycl.so to the linker. // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fsycl -fno-sycl %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload-nvptx.cpp b/clang/test/Driver/sycl-offload-nvptx.cpp index c3d063468ffeb..4a976d391f64f 100644 --- a/clang/test/Driver/sycl-offload-nvptx.cpp +++ b/clang/test/Driver/sycl-offload-nvptx.cpp @@ -15,7 +15,7 @@ // RUN: -resource-dir %{resource_dir} %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-ACTIONS-WIN %s -// CHK-ACTIONS: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l64.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} "-std=c++17"{{.*}} +// CHK-ACTIONS: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l64.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} "-std=c++17"{{.*}} // CHK-ACTIONS: sycl-post-link // CHK-ACTIONS-NOT: -split // CHK-ACTIONS-SAME: -o @@ -27,7 +27,7 @@ // CHK-ACTIONS-NOT: "-mllvm -sycl-opt" // CHK-ACTIONS: clang-offload-wrapper"{{.*}} "-host=x86_64-unknown-linux-gnu" "-target=nvptx64" "-kind=sycl"{{.*}} -// CHK-ACTIONS-WIN: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-pc-windows-msvc"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l32.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} +// CHK-ACTIONS-WIN: "-cc1" "-triple" "nvptx64-nvidia-cuda" "-aux-triple" "x86_64-pc-windows-msvc"{{.*}} "-fsycl-is-device"{{.*}} "-Wno-sycl-strict"{{.*}} "-sycl-std=2020" {{.*}} "-emit-llvm-bc" {{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libspirv.l32.signed_char.bc"{{.*}} "-mlink-builtin-bitcode" "{{.*}}libdevice{{.*}}.10.bc"{{.*}} "-target-sdk-version=[[CUDA_VERSION:[0-9.]+]]"{{.*}} "-target-cpu" "sm_75"{{.*}} "-target-feature" "+ptx63"{{.*}} // CHK-ACTIONS-WIN: sycl-post-link // CHK-ACTIONS-WIN-NOT: -split // CHK-ACTIONS-WIN-SAME: -o diff --git a/clang/test/Driver/sycl-offload-old-model.cpp b/clang/test/Driver/sycl-offload-old-model.cpp index 0ba5072d45e05..edd69cc9aae40 100644 --- a/clang/test/Driver/sycl-offload-old-model.cpp +++ b/clang/test/Driver/sycl-offload-old-model.cpp @@ -856,13 +856,13 @@ // RUN: %clang -### -fsycl --no-offload-new-driver %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // RUN: %clang_cl -### -fsycl --no-offload-new-driver %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-device" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-host" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" /// Check for option incompatibility with -fsycl // RUN: not %clang -### -fsycl --no-offload-new-driver -ffreestanding %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload.cpp b/clang/test/Driver/sycl-offload.cpp index d0fc782201603..44cf684999acc 100644 --- a/clang/test/Driver/sycl-offload.cpp +++ b/clang/test/Driver/sycl-offload.cpp @@ -544,13 +544,13 @@ // RUN: %clang -### -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // RUN: %clang_cl -### -fsycl --offload-new-driver /clang:--sysroot=%S/Inputs/SYCL %s 2>&1 | FileCheck %s -check-prefixes=CHECK-HEADER-DIR // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-device" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT:[^"]*]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" // CHECK-HEADER-DIR: clang{{.*}} "-fsycl-is-host" -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // CHECK-HEADER-DIR-NOT: -internal-isystem -// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]include" +// CHECK-HEADER-DIR-SAME: "-internal-isystem" "[[ROOT]]bin{{[/\\]+}}..{{[/\\]+}}include" /// Check for option incompatibility with -fsycl // RUN: not %clang -### -fsycl --offload-new-driver --sysroot=%S/Inputs/SYCL -ffreestanding %s 2>&1 \ diff --git a/clang/test/Driver/sycl.cpp b/clang/test/Driver/sycl.cpp index 3e76d89ba6a52..abf549dea1714 100644 --- a/clang/test/Driver/sycl.cpp +++ b/clang/test/Driver/sycl.cpp @@ -13,7 +13,7 @@ // ENABLED: "-cc1"{{.*}} "-fsycl-is-device" // ENABLED-SAME: "-sycl-std={{[-.sycl0-9]+}}" -// ENABLED-SAME: "-internal-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// ENABLED-SAME: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // NOT_ENABLED-NOT: "-fsycl-is-device" // NOT_ENABLED-NOT: "-fsycl-std-layout-kernel-params" @@ -44,7 +44,7 @@ // RUN: %clang_cl -### --target=i386-pc-windows-msvc -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT -DSPIRARCH=spir // DEFAULT: "-triple" "[[SPIRARCH]]-unknown-{{.*}}"{{.*}} "-fsycl-is-device"{{.*}} "-sycl-std=2020"{{.*}} "-emit-llvm-bc" -// DEFAULT: "-internal-isystem" "{{.*[/\\]}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" +// DEFAULT: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl{{[/\\]+}}stl_wrappers" // DEFAULT: "-internal-isystem" "{{.*lib.*clang.*include}}" // DEFAULT: "-std=c++17" // DEFAULT-NOT: "{{.*}}llvm-spirv"{{.*}} @@ -87,7 +87,7 @@ // RUN: %clangxx -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=HEADER-ORDER // RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=HEADER-ORDER // HEADER-ORDER-NOT: clang{{.*}} "/usr/include" -// HEADER-ORDER: "-internal-isystem" "{{.*[/\\]}}include" +// HEADER-ORDER: "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include" /// Verify -fsycl-device-only phases // RUN: %clang -### -ccc-print-phases -target x86_64-unknown-linux-gnu -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT-PHASES diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt index c495858a550a6..fd074e226ddaf 100644 --- a/clang/tools/CMakeLists.txt +++ b/clang/tools/CMakeLists.txt @@ -2,6 +2,7 @@ create_subdirectory_options(CLANG TOOL) add_clang_subdirectory(diagtool) add_clang_subdirectory(driver) +add_clang_subdirectory(dpllvm) if(CLANG_ENABLE_CIR) add_clang_subdirectory(cir-opt) add_clang_subdirectory(cir-translate) diff --git a/clang/tools/dpllvm/CMakeLists.txt b/clang/tools/dpllvm/CMakeLists.txt new file mode 100644 index 0000000000000..d71e7b84f739a --- /dev/null +++ b/clang/tools/dpllvm/CMakeLists.txt @@ -0,0 +1,48 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + +# dpllvm is the entry-point shim for the DPC++ toolchain. It is installed into +# bin/ next to the real tools; the public "dp"-prefixed names are symlinks +# (copies on Windows, which lacks first-class symlinks) to it. At runtime +# dpllvm strips the "dp" prefix from argv[0] and execs the sibling real binary +# (dpclang -> clang, dpclang++ -> clang++, dpsycl-ls -> sycl-ls, ...). +# +# These names must not collide with a system LLVM/Clang on PATH, hence the +# prefix; the real binaries keep their original names because the clang driver +# re-invokes itself by name and expects to find "clang"/"clang++". +add_clang_tool(dpllvm + dpllvm.cpp + ) + +# The public entry-points. Each is a symlink/copy to dpllvm; the stripped name +# (after removing "dp") must match a real binary installed next to dpllvm. +# dpclang* -> clang, clang++, clang-cl, clang-cpp (this project) +# dpsycl-ls -> sycl-ls (sycl/tools/sycl-ls) +# dpsyclbin-dump -> syclbin-dump (sycl/tools/syclbin-dump) +# dpsycl-prof -> sycl-prof (sycl/tools/sycl-prof, UNIX + XPTI only) +# dpsycl-sanitize -> sycl-sanitize (sycl/tools/sycl-sanitize, UNIX + XPTI) +# dpsycl-trace -> sycl-trace (sycl/tools/sycl-trace, UNIX + XPTI) +# +# add_clang_symlink creates both the build-tree link (POST_BUILD of dpllvm, so +# it lands in the same build bin/ as every real tool) and the install rule +# (component "dpllvm"). The sycl-* entry-points are created here rather than in +# their own tool directories so that all symlink creation lives in one place and +# ships as a single component that deploy-sycl-toolchain pulls in; a symlink +# whose target tool is not built on a given platform simply errors at runtime, +# which is the same behavior as a missing tool. +set(DPCPP_ENTRY_POINTS + dpclang + dpclang++ + dpclang-cl + dpclang-cpp + dpsycl-ls + dpsyclbin-dump + dpsycl-prof + dpsycl-sanitize + dpsycl-trace + ) + +foreach(link ${DPCPP_ENTRY_POINTS}) + add_clang_symlink(${link} dpllvm) +endforeach() diff --git a/clang/tools/dpllvm/dpllvm.cpp b/clang/tools/dpllvm/dpllvm.cpp new file mode 100644 index 0000000000000..5bc54ac7f47c6 --- /dev/null +++ b/clang/tools/dpllvm/dpllvm.cpp @@ -0,0 +1,73 @@ +//===-- dpllvm.cpp - DPC++ tool entry-point shim --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// The DPC++ toolchain ships public entry-points whose names are prefixed with +// "dp" (dpclang, dpclang++, dpclang-cl, dpclang-cpp, dpsycl-ls, ...) so they +// don't collide with the identically-named tools of a system LLVM/Clang +// installation that may be on PATH. Those entry-points are symlinks (real +// copies on Windows, which has no first-class symlinks) that resolve to this +// tool. +// +// dpllvm looks at how it was invoked (argv[0]), strips the leading "dp", and +// re-executes the correspondingly-named real binary that lives next to it in +// the same directory -- e.g. invoking "dpclang++" runs "clang++". The real +// binary keeps its original name ("clang++", not "dpclang++") because the +// clang driver re-invokes itself by name (for -cc1, offloading sub-jobs, etc.) +// and must find a binary called "clang"/"clang++". +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/Error.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" + +int main(int argc, char *argv[]) { + using namespace llvm; + using namespace llvm::sys; + + StringRef Executable = argv[0]; + StringRef Alias = path::filename(Executable); + + // On Windows the entry-points are ".exe" copies of this tool; drop the + // extension so the "dp" prefix check and the real-tool name are correct. + StringRef Stem = path::stem(Alias); + + ExitOnError Exit((Alias + ": ").str()); + + if (!Stem.consume_front("dp")) + Exit(createStringError("binary '" + Alias + "' not prefixed by 'dp'.")); + + // Locate the directory this tool was installed into so we can find the real + // binary sitting next to it, regardless of the current working directory or + // how the tool was found on PATH. + void *MainAddr = reinterpret_cast(main); + std::string DpllvmPath = fs::getMainExecutable(argv[0], MainAddr); + if (DpllvmPath.empty()) + Exit(createStringError( + "couldn't determine the path to the DPC++ bin/ directory.")); + + StringRef BinaryDir = path::parent_path(DpllvmPath); + + SmallString<256> BinaryPath(BinaryDir); + path::append(BinaryPath, Stem); + + if (!fs::exists(BinaryPath)) + Exit(createStringError("binary '" + BinaryPath + "' does not exist.")); + + SmallVector Args = {BinaryPath}; + Args.append(argv + 1, argv + argc); + + std::string ErrMsg; + int Result = ExecuteAndWait(BinaryPath, Args, /*Env=*/std::nullopt, + /*Redirects=*/{}, /*SecondsToWait=*/0, + /*MemoryLimit=*/0, &ErrMsg); + if (!ErrMsg.empty()) + Exit(createStringError("failed to execute '" + BinaryPath + + "': " + ErrMsg)); + return Result; +} diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt index 2994d6d500d6f..d3bd17785e26d 100644 --- a/clang/tools/driver/CMakeLists.txt +++ b/clang/tools/driver/CMakeLists.txt @@ -93,73 +93,6 @@ foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK}) add_clang_symlink(${link} clang) endforeach() -# Create dpclang* build-tree symlinks/copies so tests can use them without -# installing. Use llvm_add_tool_symlink (not add_clang_symlink) to suppress -# install rules — these must NOT be installed into lib/dpcpp-N/bin/. -foreach(_link dpclang dpclang-${DPCPP_VERSION_MAJOR} dpclang++ dpclang-cl dpclang-cpp) - llvm_add_tool_symlink(CLANG ${_link} clang ALWAYS_GENERATE) -endforeach() - -# Install public dpclang* symlinks in ${CMAKE_INSTALL_BINDIR}. -# These versioned names avoid conflicts with a system LLVM installation while -# the real binaries live in ${DPCPP_INSTALL_INTERNAL_BINDIR} alongside all companion -# tools so that the driver can find them via its own executable path. -if(CLANG_BUILD_TOOLS) - # Locate LLVM's install_symlink() helper script. LLVMInstallSymlink.cmake - # lives in llvm/cmake/modules for an in-tree build but in - # /lib/cmake/llvm for a standalone clang build. Both candidate - # directories are on CMAKE_MODULE_PATH, so search it (and only it) for - # whichever one actually exists rather than hardcoding a path that only works - # for one build layout. - find_file(INSTALL_SYMLINK LLVMInstallSymlink.cmake - PATHS ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH) - - # Both Linux and Windows relocate the real tools into lib/dpcpp-N/bin/ so - # they don't collide with a system LLVM. The public dpclang* entry-points go - # into ${CMAKE_INSTALL_BINDIR}; no real binaries install there directly, so - # make sure the directory exists. - install(DIRECTORY DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT clang) - - # ${CMAKE_EXECUTABLE_SUFFIX} is empty on Linux and ".exe" on Windows, so the - # same code produces dpclang / dpclang-N / ... on Linux and dpclang.exe / - # dpclang-N.exe / ... on Windows. - set(_exe "${CMAKE_EXECUTABLE_SUFFIX}") - - # dpclang-N points at clang++ inside the versioned tools dir; the remaining - # names chain to dpclang-N. install_symlink resolves a relative source - # against ${CMAKE_INSTALL_BINDIR}, so use a path relative to bin/. - set(_abs_bindir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}") - set(_abs_toolsdir "${CMAKE_INSTALL_PREFIX}/${DPCPP_INSTALL_INTERNAL_BINDIR}") - file(RELATIVE_PATH _dpclang_primary_target - "${_abs_bindir}" "${_abs_toolsdir}/clang++${_exe}") - - if(LLVM_USE_SYMLINKS) - # Linux default: relative symlinks. Resolving the symlink at startup lands - # the driver inside the versioned tools dir where its companion tools live. - set(_dpclang_link_or_copy create_symlink) - else() - # Windows default (LLVM_USE_SYMLINKS defaults to OFF on non-UNIX hosts): - # real copies. A copied executable is not a symlink, so the driver can't - # discover its companion tools by walking up from its own location; the - # base ToolChain constructor seeds lib/dpcpp-N/bin/ into the program - # search path (see clang/lib/Driver/ToolChain.cpp) to compensate. - set(_dpclang_link_or_copy copy) - endif() - - # dpclang-MAJOR → clang++ (in lib/dpcpp-N/bin/); dpclang/dpclang++/etc → dpclang-MAJOR - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"dpclang-${DPCPP_VERSION_MAJOR}${_exe}\" \"${_dpclang_primary_target}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"dpclang${_exe}\" \"dpclang-${DPCPP_VERSION_MAJOR}${_exe}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) - foreach(_link dpclang++ dpclang-cl dpclang-cpp) - install(SCRIPT ${INSTALL_SYMLINK} - CODE "install_symlink(\"${_link}${_exe}\" \"dpclang-${DPCPP_VERSION_MAJOR}${_exe}\" \"${CMAKE_INSTALL_BINDIR}\" \"${_dpclang_link_or_copy}\")" - COMPONENT clang) - endforeach() -endif() - # Configure plist creation for OS X. set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name") if (APPLE) diff --git a/cmake/Modules/GetClangResourceDir.cmake b/cmake/Modules/GetClangResourceDir.cmake index 976bf0fd311aa..518220188f96d 100644 --- a/cmake/Modules/GetClangResourceDir.cmake +++ b/cmake/Modules/GetClangResourceDir.cmake @@ -17,18 +17,6 @@ function(get_clang_resource_dir out_var) string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION}) endif() set(ret_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}) - # When the compiler tools are relocated into a versioned DPC++ libdir - # (e.g. lib/dpcpp-N/bin), the driver resolves its resource dir relative to - # the executable as /lib/clang/N. For install destinations - # (callers that pass no PREFIX) mirror that layout so the resource headers - # and libraries are installed where the driver actually looks, instead of - # the top-level lib/clang which would otherwise require a bridging symlink. - if(NOT ARG_PREFIX AND DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) - cmake_path(GET DPCPP_INSTALL_INTERNAL_BINDIR PARENT_PATH _dpcpp_parent) - if(_dpcpp_parent) - set(ret_dir ${_dpcpp_parent}/${ret_dir}) - endif() - endif() endif() if(ARG_PREFIX) diff --git a/devops/actions/run-tests/benchmark/action.yml b/devops/actions/run-tests/benchmark/action.yml index 3e64a3270d586..126b47b32c825 100644 --- a/devops/actions/run-tests/benchmark/action.yml +++ b/devops/actions/run-tests/benchmark/action.yml @@ -143,9 +143,9 @@ runs: else echo "INFO: SYCL directory '$SYCL_DIR' does not exist or is missing libsycl.so" echo "Checking if SYCL is installed in the system..." - which sycl-ls - sycl-ls - export CMPLR_ROOT="$(dirname $(dirname $(which sycl-ls)))" + which dpsycl-ls + dpsycl-ls + export CMPLR_ROOT="$(dirname $(dirname $(which dpsycl-ls)))" echo "CMPLR_ROOT=$CMPLR_ROOT" >> $GITHUB_ENV fi echo "Using SYCL from: $CMPLR_ROOT" @@ -277,11 +277,11 @@ runs: pip install --user --break-system-packages -r ./devops/scripts/benchmarks/requirements.txt echo "::endgroup::" - - name: Run sycl-ls + - name: Run dpsycl-ls shell: bash run: | - # Run sycl-ls - sycl-ls --verbose + # Run dpsycl-ls + dpsycl-ls --verbose - name: Build and run benchmarks shell: bash env: diff --git a/devops/scripts/benchmarks/utils/utils.py b/devops/scripts/benchmarks/utils/utils.py index a9995e5a08f9f..2ab8177f97ea2 100644 --- a/devops/scripts/benchmarks/utils/utils.py +++ b/devops/scripts/benchmarks/utils/utils.py @@ -211,7 +211,7 @@ def download(dir, url, file, untar=False, unzip=False, checksum=""): def get_device_architecture(additional_env_vars): sycl_ls_output = run( - ["sycl-ls", "--verbose"], add_sycl=True, env_vars=additional_env_vars + ["dpsycl-ls", "--verbose"], add_sycl=True, env_vars=additional_env_vars ).stdout.decode() architectures = set() @@ -234,7 +234,7 @@ def warn_if_level_zero_is_not_found(additional_env_vars) -> bool: sycl_ls_found_l0 = False sycl_ls_output = run( - ["sycl-ls"], add_sycl=True, env_vars=additional_env_vars + ["dpsycl-ls"], add_sycl=True, env_vars=additional_env_vars ).stdout.decode() for line in sycl_ls_output.splitlines(): diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index 756ed2fa61a75..3f70fc78e0ddc 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -87,29 +87,11 @@ else() # Setup the paths where libclc runtimes should be stored. By default, in an # in-tree build we place the libraries in clang's resource driectory. include(GetClangResourceDir) - # The trailing library component must match what the driver appends when it - # searches for libspirv: CLANG_INSTALL_LIBDIR_BASENAME (i.e. - # lib${LLVM_LIBDIR_SUFFIX}, e.g. lib64). CLANG_INSTALL_LIBDIR_BASENAME itself - # is defined in clang/CMakeLists.txt and is not in scope in this (runtimes) - # sub-build, so spell out its expansion, which is also what - # get_clang_resource_dir() uses for the leading library component. - set( LIBCLC_LIBDIR_BASENAME "lib${LLVM_LIBDIR_SUFFIX}" ) - - # Install into the clang resource directory that the *installed* driver - # searches. With no PREFIX, get_clang_resource_dir() applies the versioned - # dpclang layout (lib/dpcpp-N/lib/clang/N) used by the install tree. get_clang_resource_dir( LIBCLC_INSTALL_DIR ) - cmake_path( APPEND LIBCLC_INSTALL_DIR ${LIBCLC_LIBDIR_BASENAME} ) - - # For the in-tree build output, mirror the *build-tree* driver's resource - # directory instead. That driver resolves its resource dir relative to its - # own location as /lib/clang/N with no dpcpp-N versioning, so use the - # PREFIX form, which is never version-prefixed. Reusing LIBCLC_INSTALL_DIR - # here would emit the libraries into a versioned directory the build-tree - # driver does not search (breaking in-tree check-sycl/libclc tests). + cmake_path( APPEND LIBCLC_INSTALL_DIR "lib" ) + cmake_path( GET LLVM_LIBRARY_OUTPUT_INTDIR PARENT_PATH LIBCLC_OUTPUT_LIBRARY_DIR ) - get_clang_resource_dir( LIBCLC_OUTPUT_LIBRARY_DIR PREFIX ${LIBCLC_OUTPUT_LIBRARY_DIR} ) - cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_LIBDIR_BASENAME} ) + cmake_path( APPEND LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_INSTALL_DIR} ) endif() if( NOT LIBCLC_USE_SPIRV_BACKEND ) diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake index 28c45cb8c977e..37f73afa915f4 100644 --- a/lld/cmake/modules/AddLLD.cmake +++ b/lld/cmake/modules/AddLLD.cmake @@ -52,24 +52,14 @@ macro(add_lld_tool name) add_lld_executable(${name} ${ARGN}) if (LLD_BUILD_TOOLS) - # Install the real lld binary into the versioned DPC++ tools dir (e.g. - # lib/dpcpp-N/bin) so it doesn't conflict with a system LLVM, matching - # add_clang_tool. The public ld.lld/ld64.lld/lld-link/wasm-ld entry-points - # are symlinks/copies created via LLD_TOOLS_INSTALL_DIR, which is also - # redirected there (see llvm/CMakeLists.txt). - if(DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) - set(_lld_runtime_dest "${DPCPP_INSTALL_INTERNAL_BINDIR}") - else() - set(_lld_runtime_dest "${CMAKE_INSTALL_BINDIR}") - endif() get_target_export_arg(${name} LLD export_to_lldtargets) install(TARGETS ${name} ${export_to_lldtargets} - RUNTIME DESTINATION "${_lld_runtime_dest}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name}) if (LLVM_ENABLE_PDB) - install(FILES $ DESTINATION "${_lld_runtime_dest}" COMPONENT ${name} OPTIONAL) + install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL) endif() if(NOT CMAKE_CONFIGURATION_TYPES) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index a4359fb386df3..c1de2dfc3f876 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -534,27 +534,8 @@ include(GNUInstallPackageDir) set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')") -# Redirect all compiler tools into the versioned DPC++ library directory so -# they don't conflict with a system LLVM installation. The public dpclang* -# entry-points in ${CMAKE_INSTALL_BINDIR} are added by clang/tools/driver. -# This block must be after project() so that CMAKE_SYSTEM_NAME is defined. -set(DPCPP_INSTALL_INTERNAL_BINDIR "lib/dpcpp-${DPCPP_VERSION_MAJOR}/bin") -set(LLVM_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE STRING - "Path for binary subdirectory (defaults to '${DPCPP_INSTALL_INTERNAL_BINDIR}')" FORCE) -set(CLANG_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) -# lld resolves its own install dir via LLD_TOOLS_INSTALL_DIR (used for its -# ld.lld/ld64.lld/lld-link/wasm-ld symlinks); redirect it too so the linkers -# don't collide with a system LLVM. The real lld binary destination is patched -# separately in lld/cmake/modules/AddLLD.cmake, mirroring add_clang_tool. -set(LLD_TOOLS_INSTALL_DIR "${DPCPP_INSTALL_INTERNAL_BINDIR}" CACHE PATH "" FORCE) - -# The default resource-dir formula is: dirname(binary)/../lib/clang/VERSION. -# For binaries installed in lib/dpcpp-N/bin/ this resolves inside lib/dpcpp-N/ -# (i.e. lib/dpcpp-N/lib/clang/VERSION) rather than the install root. The -# resource files are installed directly there by get_clang_resource_dir() -# (see cmake/Modules/GetClangResourceDir.cmake), so no bridging symlink from -# the top-level lib/clang is needed. - +set(LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING + "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')") mark_as_advanced(LLVM_TOOLS_INSTALL_DIR) set(LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index b65c5f4dbb652..f4a73d1fc8943 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -2693,26 +2693,7 @@ function(llvm_setup_rpath name) set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) elseif(UNIX) set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir}) - # For executables installed in DPCPP_INSTALL_INTERNAL_BINDIR (Linux only), - # compute the relative path from that directory to the lib directory so - # the dynamic linker can find the shared libraries at runtime. - get_target_property(_target_type ${name} TYPE) - if(_target_type STREQUAL "EXECUTABLE" AND - CMAKE_SYSTEM_NAME STREQUAL "Linux" AND - DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) - cmake_path(SET _internal_bin_abs NORMALIZE - "/${DPCPP_INSTALL_INTERNAL_BINDIR}") - cmake_path(SET _lib_abs NORMALIZE "/lib${LLVM_LIBDIR_SUFFIX}") - cmake_path(RELATIVE_PATH _lib_abs BASE_DIRECTORY "${_internal_bin_abs}" - OUTPUT_VARIABLE _rpath_to_lib) - set(_install_rpath "\$ORIGIN/${_rpath_to_lib}") - unset(_rpath_to_lib) - unset(_internal_bin_abs) - unset(_lib_abs) - else() - set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") - endif() - unset(_target_type) + set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}") if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) list(APPEND _build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}") list(APPEND _install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}") diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index 7b5aa09721533..707451408f091 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -4,17 +4,6 @@ # the two files. set(COMMON_CMAKE_ARGS "-DHAVE_LLVM_LIT=ON;-DCLANG_RESOURCE_DIR=${CLANG_RESOURCE_DIR}") -# Forward the versioned DPC++ binary directory into the runtimes sub-builds. -# It is defined in the top-level llvm/CMakeLists.txt but the runtimes are -# configured as a separate CMake invocation that does not inherit it. libclc -# relies on it in get_clang_resource_dir() to install libspirv into the same -# versioned resource directory (lib/dpcpp-N/lib/clang/N) the driver searches; -# without it libclc would fall back to the non-versioned lib/clang/N and the -# driver would fail to find libspirv.*.bc. -if(DEFINED DPCPP_INSTALL_INTERNAL_BINDIR) - list(APPEND COMMON_CMAKE_ARGS - "-DDPCPP_INSTALL_INTERNAL_BINDIR=${DPCPP_INSTALL_INTERNAL_BINDIR}") -endif() if(APPLE AND CMAKE_OSX_SYSROOT AND (LLVM_TARGET_TRIPLE STREQUAL LLVM_HOST_TRIPLE)) # Only propagate the host sysroot for native runtimes builds. list(APPEND RUNTIMES_CMAKE_ARGS "-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}") diff --git a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp index e11e41758b987..5c44068413c5a 100644 --- a/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp +++ b/sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp @@ -177,17 +177,6 @@ std::string getLibPathSuffix() { DPCPP_VERSION_MAJOR); #endif } - -// Location of the internal `clang++` binary relative to the toolchain root. -// The real toolchain relocates the driver into a versioned libdir on Linux -// (mirroring DPCPP_INSTALL_INTERNAL_BINDIR in llvm/CMakeLists.txt); the JIT's -// virtual toolchain must use the same layout so that clang's GetResourcesPath() -// derives the same (versioned) resource directory the bundled resource headers -// and libraries are installed into. -std::string getInternalBinSubPath() { - return llvm::formatv("/{0}/dpcpp-{1}/bin/clang++", - CLANG_INSTALL_LIBDIR_BASENAME, DPCPP_VERSION_MAJOR); -} class SYCLToolchain { static auto &getToolchainFS() { // TODO: For some reason, removing `thread_local` results in data races @@ -642,9 +631,8 @@ class SYCLToolchain { clang::IgnoringDiagConsumer IgnoreDiag; std::string_view Prefix{jit_compiler::resource::ToolchainPrefix.S, jit_compiler::resource::ToolchainPrefix.Size}; - std::string ClangXXExe = (Prefix + getInternalBinSubPath()).str(); - std::string LibclcDir = - GetResourcesPath(ClangXXExe) + "/" + CLANG_INSTALL_LIBDIR_BASENAME + "/"; + std::string ClangXXExe = (Prefix + "/bin/clang++").str(); + std::string LibclcDir = GetResourcesPath(ClangXXExe) + "/lib/"; PrecompiledPreambles Preambles; }; diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 2a7e6a7184247..c4d08a480867a 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -156,14 +156,6 @@ set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION set(SYCL_INCLUDE_DIR "include") set(SYCL_INCLUDE_BUILD_DIR ${LLVM_BINARY_DIR}/${SYCL_INCLUDE_DIR}) -# The wrapper headers (e.g. ) are -# relocated into the versioned DPC++ include directory so the top-level -# include/ isn't polluted with a "std" directory that could shadow or conflict -# with a system toolchain. The compiler driver adds this directory to the -# SYCL header search path (see addSYCLIncludeArgs in -# clang/lib/Driver/ToolChains/SYCL.cpp). -set(SYCL_STD_INCLUDE_DIR "lib${LLVM_LIBDIR_SUFFIX}/dpcpp-${DPCPP_VERSION_MAJOR}/include") - if(NOT SYCL_HEADERS_ONLY) add_llvm_external_project(opencl) list(FIND LLVM_ENABLE_PROJECTS opencl OPENCL_PROJ_FOUND) @@ -316,7 +308,7 @@ add_custom_command( # Copy SYCL headers from source to install directory install(DIRECTORY "${sycl_inc_dir}/sycl" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers) install(DIRECTORY "${sycl_inc_dir}/CL" DESTINATION ${SYCL_INCLUDE_DIR}/ COMPONENT sycl-headers) -install(DIRECTORY "${sycl_inc_dir}/std" DESTINATION ${SYCL_STD_INCLUDE_DIR} COMPONENT sycl-headers) +install(DIRECTORY "${sycl_inc_dir}/std" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers) install(DIRECTORY "${UNIFIED_RUNTIME_INCLUDE_DIR}/unified-runtime" DESTINATION ${SYCL_INCLUDE_DIR} COMPONENT sycl-headers) if (WIN32) @@ -433,6 +425,7 @@ endif() add_custom_target(sycl-compiler DEPENDS append-file clang + dpllvm clang-offload-wrapper clang-offload-bundler clang-offload-deps @@ -517,6 +510,7 @@ get_property(SYCL_TOOLCHAIN_DEPS GLOBAL PROPERTY SYCL_TOOLCHAIN_INSTALL_COMPONEN set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS append-file clang + dpllvm clang-offload-wrapper clang-offload-bundler clang-offload-deps diff --git a/sycl/test-e2e/CMakeLists.txt b/sycl/test-e2e/CMakeLists.txt index 67f7eff3e8b26..2ee613f148a87 100644 --- a/sycl/test-e2e/CMakeLists.txt +++ b/sycl/test-e2e/CMakeLists.txt @@ -104,26 +104,13 @@ endif() get_filename_component(DPCPP_ROOT_DIR ${SYCL_CXX_COMPILER} DIRECTORY) if(SYCL_TEST_E2E_STANDALONE) - # llvm-config is not necessarily next to the compiler driver: with the - # dpclang layout the real tools live in lib/dpcpp-/bin/ while the - # public driver is in bin/. Ask the compiler where llvm-config is instead - # of assuming it sits alongside the driver. execute_process( - COMMAND ${SYCL_CXX_COMPILER} -print-prog-name=llvm-config${CMAKE_EXECUTABLE_SUFFIX} + COMMAND ${DPCPP_ROOT_DIR}/llvm-config${CMAKE_EXECUTABLE_SUFFIX} --libdir WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE CMPLR_CONFIG_RESULT - OUTPUT_VARIABLE CMPLR_CONFIG_PATH + RESULT_VARIABLE CMPLR_LIBS_RESULT + OUTPUT_VARIABLE CMPLR_LIBS_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) - if(CMPLR_CONFIG_RESULT EQUAL 0 AND EXISTS "${CMPLR_CONFIG_PATH}") - execute_process( - COMMAND ${CMPLR_CONFIG_PATH} --libdir - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE CMPLR_LIBS_RESULT - OUTPUT_VARIABLE CMPLR_LIBS_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endif() if(NOT CMPLR_LIBS_RESULT EQUAL 0 OR NOT CMPLR_LIBS_DIR) message(FATAL_ERROR "Failed to determine SYCL library directory") endif() diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index 2444b12d7927d..5ae02752917b1 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -14,14 +14,12 @@ config.dpcpp_bin_dir = os.path.join(config.dpcpp_root_dir, 'bin') def get_dpcpp_tool_path(name): try: - return subprocess.check_output([config.dpcpp_compiler, "-print-prog-name=" + name], text=True).strip() + return subprocess.check_output([config.dpcpp_compiler, "-print-prog-name=" + name], text=True) except subprocess.CalledProcessError: return os.path.join(config.dpcpp_bin_dir, name) config.llvm_main_include_dir = "@LLVM_MAIN_INCLUDE_DIR@" -# Use llvm-link (always in SYCL_TOOLCHAIN_DEPLOY_COMPONENTS) to find the -# internal tools directory. llvm-config is not always deployed there. -config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-link")) +config.llvm_tools_dir = os.path.dirname(get_dpcpp_tool_path("llvm-config")) config.lit_tools_dir = os.path.dirname("@TEST_SUITE_LIT@") config.dump_ir_supported = lit_config.params.get("dump_ir", ("@DUMP_IR_SUPPORTED@" if "@DUMP_IR_SUPPORTED@" else False)) config.sycl_tools_dir = config.llvm_tools_dir diff --git a/sycl/tools/syclbin-dump/CMakeLists.txt b/sycl/tools/syclbin-dump/CMakeLists.txt index 9bf370bdcbe4e..d1eb71823f646 100644 --- a/sycl/tools/syclbin-dump/CMakeLists.txt +++ b/sycl/tools/syclbin-dump/CMakeLists.txt @@ -22,4 +22,4 @@ endif() add_dependencies(sycl-toolchain syclbin-dump) install(TARGETS syclbin-dump - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT syclbin-dump) + RUNTIME DESTINATION "bin" COMPONENT syclbin-dump) From 26b9b59e7fa6045a1027160c2b9968488ee6380c Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 10 Jul 2026 17:44:11 +0200 Subject: [PATCH 45/48] Fix clang-format --- clang/tools/dpllvm/dpllvm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/tools/dpllvm/dpllvm.cpp b/clang/tools/dpllvm/dpllvm.cpp index 5bc54ac7f47c6..105d4c6c32511 100644 --- a/clang/tools/dpllvm/dpllvm.cpp +++ b/clang/tools/dpllvm/dpllvm.cpp @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { /*Redirects=*/{}, /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg); if (!ErrMsg.empty()) - Exit(createStringError("failed to execute '" + BinaryPath + - "': " + ErrMsg)); + Exit( + createStringError("failed to execute '" + BinaryPath + "': " + ErrMsg)); return Result; } From d0d0167e4f91e08a2ecbab3abae8da6d39ed6261 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 10 Jul 2026 18:18:27 +0200 Subject: [PATCH 46/48] Fix for Windows --- clang/tools/dpllvm/dpllvm.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/clang/tools/dpllvm/dpllvm.cpp b/clang/tools/dpllvm/dpllvm.cpp index 105d4c6c32511..2d479789b779c 100644 --- a/clang/tools/dpllvm/dpllvm.cpp +++ b/clang/tools/dpllvm/dpllvm.cpp @@ -33,13 +33,14 @@ int main(int argc, char *argv[]) { StringRef Executable = argv[0]; StringRef Alias = path::filename(Executable); - // On Windows the entry-points are ".exe" copies of this tool; drop the - // extension so the "dp" prefix check and the real-tool name are correct. - StringRef Stem = path::stem(Alias); - ExitOnError Exit((Alias + ": ").str()); - if (!Stem.consume_front("dp")) + // Strip the "dp" prefix off the full filename to get the real tool's name. + // Keep any extension: on Windows the entry-points are "dpclang++.exe" copies + // of this tool and the real binary is "clang++.exe", so the extension must + // be preserved for the sibling lookup (and for ExecuteAndWait) to succeed. + StringRef RealName = Alias; + if (!RealName.consume_front("dp")) Exit(createStringError("binary '" + Alias + "' not prefixed by 'dp'.")); // Locate the directory this tool was installed into so we can find the real @@ -54,7 +55,7 @@ int main(int argc, char *argv[]) { StringRef BinaryDir = path::parent_path(DpllvmPath); SmallString<256> BinaryPath(BinaryDir); - path::append(BinaryPath, Stem); + path::append(BinaryPath, RealName); if (!fs::exists(BinaryPath)) Exit(createStringError("binary '" + BinaryPath + "' does not exist.")); From 8da7edf3eac4d775b7c42a9ea48f083769013608 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 10 Jul 2026 18:49:19 +0200 Subject: [PATCH 47/48] Fix for Windows in-tree tests --- clang/tools/dpllvm/dpllvm.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/clang/tools/dpllvm/dpllvm.cpp b/clang/tools/dpllvm/dpllvm.cpp index 2d479789b779c..2f304edecd8cb 100644 --- a/clang/tools/dpllvm/dpllvm.cpp +++ b/clang/tools/dpllvm/dpllvm.cpp @@ -35,11 +35,13 @@ int main(int argc, char *argv[]) { ExitOnError Exit((Alias + ": ").str()); - // Strip the "dp" prefix off the full filename to get the real tool's name. - // Keep any extension: on Windows the entry-points are "dpclang++.exe" copies - // of this tool and the real binary is "clang++.exe", so the extension must - // be preserved for the sibling lookup (and for ExecuteAndWait) to succeed. - StringRef RealName = Alias; + // Derive the real tool's base name by dropping any executable extension and + // stripping the "dp" prefix (e.g. "dpclang++" / "dpclang++.exe" -> "clang++"). + // The extension is intentionally not carried over: how it appears in argv[0] + // is inconsistent across platforms (a Windows invocation may or may not + // include ".exe"), so it is left to findProgramByName below to append the + // right suffix when locating the real binary. + StringRef RealName = path::stem(Alias); if (!RealName.consume_front("dp")) Exit(createStringError("binary '" + Alias + "' not prefixed by 'dp'.")); @@ -54,11 +56,15 @@ int main(int argc, char *argv[]) { StringRef BinaryDir = path::parent_path(DpllvmPath); - SmallString<256> BinaryPath(BinaryDir); - path::append(BinaryPath, RealName); - - if (!fs::exists(BinaryPath)) - Exit(createStringError("binary '" + BinaryPath + "' does not exist.")); + // findProgramByName searches the given directory and appends the platform + // executable suffix (".exe" on Windows), so this resolves the sibling real + // binary whether or not the invoking name carried an extension. + ErrorOr BinaryPathOrErr = + findProgramByName(RealName, {BinaryDir}); + if (!BinaryPathOrErr) + Exit(createStringError("binary '" + RealName + "' not found next to '" + + DpllvmPath + "'.")); + StringRef BinaryPath = *BinaryPathOrErr; SmallVector Args = {BinaryPath}; Args.append(argv + 1, argv + argc); From 45c68d1de336095a021941c23ad5a7c49b043979 Mon Sep 17 00:00:00 2001 From: Dmitry Vodopyanov Date: Fri, 10 Jul 2026 18:55:24 +0200 Subject: [PATCH 48/48] Fix clang-format --- clang/tools/dpllvm/dpllvm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/tools/dpllvm/dpllvm.cpp b/clang/tools/dpllvm/dpllvm.cpp index 2f304edecd8cb..d6883486918e8 100644 --- a/clang/tools/dpllvm/dpllvm.cpp +++ b/clang/tools/dpllvm/dpllvm.cpp @@ -36,11 +36,11 @@ int main(int argc, char *argv[]) { ExitOnError Exit((Alias + ": ").str()); // Derive the real tool's base name by dropping any executable extension and - // stripping the "dp" prefix (e.g. "dpclang++" / "dpclang++.exe" -> "clang++"). - // The extension is intentionally not carried over: how it appears in argv[0] - // is inconsistent across platforms (a Windows invocation may or may not - // include ".exe"), so it is left to findProgramByName below to append the - // right suffix when locating the real binary. + // stripping the "dp" prefix (e.g. "dpclang++" / "dpclang++.exe" -> + // "clang++"). The extension is intentionally not carried over: how it appears + // in argv[0] is inconsistent across platforms (a Windows invocation may or + // may not include ".exe"), so it is left to findProgramByName below to append + // the right suffix when locating the real binary. StringRef RealName = path::stem(Alias); if (!RealName.consume_front("dp")) Exit(createStringError("binary '" + Alias + "' not prefixed by 'dp'."));