Skip to content

Commit 7bfffff

Browse files
committed
fix search path for sycl-jit-toolchain
1 parent b2ef5a2 commit 7bfffff

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -831,21 +831,22 @@ Error jit_compiler::linkDeviceLibraries(llvm::Module &Module,
831831
DiagnosticsEngine Diags(DiagID, DiagOpts, Wrapper.consumer(),
832832
/* ShouldOwnClient=*/false);
833833

834+
Triple T{Module.getTargetTriple()};
835+
Driver D{(SYCLToolchain::instance().getPrefix() + "/bin/clang++").str(),
836+
T.getTriple(), Diags};
837+
834838
SmallVector<std::string> LibNames;
835839
getDeviceLibraries(UserArgList, LibNames, Format);
836840
const bool IsCudaHIP =
837841
Format == BinaryFormat::PTX || Format == BinaryFormat::AMDGCN;
838842
if (IsCudaHIP) {
839843
// Based on the OS and the format decide on the version of libspirv.
840844
// NOTE: this will be problematic if cross-compiling between OSes.
841-
std::string Libclc{"clc/"};
842-
Libclc.append(
843845
#ifdef _WIN32
844-
"remangled-l32-signed_char.libspirv-"
846+
std::string Libclc = "remangled-l32-signed_char.libspirv-";
845847
#else
846-
"remangled-l64-signed_char.libspirv-"
848+
std::string Libclc = "remangled-l64-signed_char.libspirv-";
847849
#endif
848-
);
849850
Libclc.append(Format == BinaryFormat::PTX ? "nvptx64-nvidia-cuda.bc"
850851
: "amdgcn-amd-amdhsa.bc");
851852
LibNames.push_back(Libclc);
@@ -855,6 +856,11 @@ Error jit_compiler::linkDeviceLibraries(llvm::Module &Module,
855856
for (const std::string &LibName : LibNames) {
856857
std::string LibPath =
857858
(SYCLToolchain::instance().getPrefix() + "/lib/" + LibName).str();
859+
if (LibName.find("libspirv") != std::string::npos) {
860+
SmallString<256> LibraryPath(D.GetResourcesPath(LibPath));
861+
sys::path::append(LibraryPath, "lib", "libclc", LibName);
862+
LibPath = LibraryPath.str().str();
863+
}
858864

859865
ModuleUPtr LibModule;
860866
if (auto Error = SYCLToolchain::instance()
@@ -872,9 +878,6 @@ Error jit_compiler::linkDeviceLibraries(llvm::Module &Module,
872878

873879
// For GPU targets we need to link against vendor provided libdevice.
874880
if (IsCudaHIP) {
875-
Triple T{Module.getTargetTriple()};
876-
Driver D{(SYCLToolchain::instance().getPrefix() + "/bin/clang++").str(),
877-
T.getTriple(), Diags};
878881
auto [CPU, Features] =
879882
Translator::getTargetCPUAndFeatureAttrs(&Module, "", Format);
880883
(void)Features;

0 commit comments

Comments
 (0)