Skip to content
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e6cb663
[SYCL] Rename clang binaries to dpclang
dm-vodopyanov Mar 23, 2026
d8939da
Revert "[SYCL] Rename clang binaries to dpclang"
dm-vodopyanov May 29, 2026
0e2ecdb
Merge remote-tracking branch 'origin/sycl' into rename_clang_to_dpclang
dm-vodopyanov May 29, 2026
6b896ba
Apply CR comments
dm-vodopyanov May 29, 2026
a678dba
Move sycl-ls back to install/bin folder
dm-vodopyanov May 29, 2026
814058d
Make it only for Linux`
dm-vodopyanov May 29, 2026
e0be600
Fix regressions + add a test
dm-vodopyanov May 29, 2026
4d91d11
Small fix
dm-vodopyanov May 29, 2026
56207c8
Fix formatting
dm-vodopyanov May 29, 2026
8110571
Fix formatting
dm-vodopyanov May 29, 2026
1b19d13
Update CI
dm-vodopyanov Jun 3, 2026
1139beb
Try to fix CI for Linux
dm-vodopyanov Jun 15, 2026
fc08eb4
Fix CI on Linux
dm-vodopyanov Jun 15, 2026
417df3d
Fix CI
dm-vodopyanov Jun 15, 2026
8b44d37
Fix merge conflict`
dm-vodopyanov Jun 15, 2026
e7ab6ae
Merge branch 'sycl' into rename_clang_to_dpclang
dm-vodopyanov Jun 15, 2026
44c1954
Try to fix CI
dm-vodopyanov Jun 16, 2026
9887a91
Try to fix CI
dm-vodopyanov Jun 16, 2026
079ce50
Fix CI
dm-vodopyanov Jun 17, 2026
984b2e4
Fix CI
dm-vodopyanov Jun 17, 2026
42408f3
Update CI config
dm-vodopyanov Jun 18, 2026
0623bae
Try to fix failures on Windows
dm-vodopyanov Jun 18, 2026
a832242
Fix clang-format
dm-vodopyanov Jun 22, 2026
fea0eaf
Some improvements
dm-vodopyanov Jun 22, 2026
eeb5025
Fix Windows
dm-vodopyanov Jun 22, 2026
8b4c27e
Add missing binary
dm-vodopyanov Jun 22, 2026
8d0835a
Merge branch 'sycl' into rename_clang_to_dpclang
dm-vodopyanov Jun 22, 2026
46b01d7
Merge remote-tracking branch 'origin/sycl' into rename_clang_to_dpclang
Jun 29, 2026
0f44a04
Apply CR comments
dm-vodopyanov Jun 29, 2026
a232458
Merge branch 'rename_clang_to_dpclang' of https://github.com/dm-vodop…
dm-vodopyanov Jun 29, 2026
b0802b7
Fix CI
dm-vodopyanov Jul 1, 2026
3578f68
Fix CI
dm-vodopyanov Jul 1, 2026
9fb8f49
Fix CI
dm-vodopyanov Jul 2, 2026
de25fd1
Fix CI
dm-vodopyanov Jul 2, 2026
348ab49
Merge branch 'intel:sycl' into rename_clang_to_dpclang
dm-vodopyanov Jul 2, 2026
8f13cab
Fix CI
dm-vodopyanov Jul 2, 2026
1f78e64
Merge branch 'rename_clang_to_dpclang' of https://github.com/dm-vodop…
dm-vodopyanov Jul 2, 2026
761cc89
Fix Windows
dm-vodopyanov Jul 6, 2026
b0c0c73
Fix Windows
dm-vodopyanov Jul 6, 2026
42c7929
Fix for SYCL RTC
dm-vodopyanov Jul 6, 2026
d887130
Fix E2E
dm-vodopyanov Jul 6, 2026
75cfdcd
Try to fix CI on Windows
dm-vodopyanov Jul 6, 2026
fa3a81b
Fix CI
dm-vodopyanov Jul 6, 2026
02c10da
Fix E2E test
dm-vodopyanov Jul 6, 2026
3c066a5
Fix some paths
dm-vodopyanov Jul 6, 2026
bae507e
Apply CR comment
dm-vodopyanov Jul 7, 2026
7291c6b
Apply CR comment
dm-vodopyanov Jul 7, 2026
4efea35
Revert changing location of devicelib files
dm-vodopyanov Jul 7, 2026
b7171a2
Apply CR comments
dm-vodopyanov Jul 7, 2026
05e80f6
Apply CR comments
dm-vodopyanov Jul 7, 2026
7f5938b
Apply CR comments
dm-vodopyanov Jul 10, 2026
26b9b59
Fix clang-format
dm-vodopyanov Jul 10, 2026
d0d0167
Fix for Windows
dm-vodopyanov Jul 10, 2026
8da7edf
Fix for Windows in-tree tests
dm-vodopyanov Jul 10, 2026
45c68d1
Fix clang-format
dm-vodopyanov Jul 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/sycl-blender-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/sycl-linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/sycl-linux-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sycl-linux-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/sycl-pytorch-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sycl-yarpgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions clang/cmake/modules/AddClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<TARGET_PDB_FILE:${name}> DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT ${name} OPTIONAL)
install(FILES $<TARGET_PDB_FILE:${name}> DESTINATION "${DPCPP_INSTALL_INTERNAL_BINDIR}" COMPONENT ${name} OPTIONAL)
endif()

if(NOT LLVM_ENABLE_IDE)
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Driver/CommonArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Driver/SyclInstallationDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ 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:
Expand Down
38 changes: 20 additions & 18 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3695,13 +3695,15 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,

static bool runBundler(const SmallVectorImpl<StringRef> &InputArgs,
Compilation &C) {
// Find bundler.
StringRef ExecPath(C.getArgs().MakeArgString(C.getDriver().Dir));
llvm::ErrorOr<std::string> 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<StringRef, 6> 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.
Expand All @@ -3714,10 +3716,7 @@ static bool runBundler(const SmallVectorImpl<StringRef> &InputArgs,
llvm::errs() << A << " ";
llvm::errs() << '\n';
}
if (BundlerBinary.getError())
Comment thread
dm-vodopyanov marked this conversation as resolved.
return false;

return !llvm::sys::ExecuteAndWait(BundlerBinary.get(), BundlerArgs);
return !llvm::sys::ExecuteAndWait(BundlerBinary, BundlerArgs);
}

static SmallVector<std::string, 4> getOffloadSections(Compilation &C,
Expand All @@ -3731,15 +3730,20 @@ static SmallVector<std::string, 4> 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<std::string> 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<StringRef, 6> 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);
Expand All @@ -3751,8 +3755,6 @@ static SmallVector<std::string, 4> 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());
Expand All @@ -3763,7 +3765,7 @@ static SmallVector<std::string, 4> 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
Expand Down
33 changes: 33 additions & 0 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -105,6 +106,38 @@ 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 {
Expand Down
19 changes: 12 additions & 7 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(C.getDriver().Dir);
llvm::sys::path::append(BaseDir, "..", "include");
SmallString<128> BaseDir(findSYCLInstallRoot(C.getDriver()));
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
Expand Down Expand Up @@ -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<Command>(JA, *this, ResponseFileSupport::None(),
Expand Down Expand Up @@ -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<Command>(
JA, *this, ResponseFileSupport::None(), Foreach, ForeachArgs,
Expand Down Expand Up @@ -11947,7 +11952,7 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
// -sycl-device-library-location=<dir> 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.
Expand Down
43 changes: 43 additions & 0 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,49 @@ 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/<arch>/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-<major>/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-")) {
Comment thread
dm-vodopyanov marked this conversation as resolved.
Outdated
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))
Expand Down
19 changes: 15 additions & 4 deletions clang/lib/Driver/ToolChains/Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,21 @@ 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/), findSYCLInstallRoot walks up to
// find the root that contains <libdir>/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);
}
}

addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
Expand Down
Loading
Loading