[clang] [llvm] [libsycl][Driver] Move and rename the SYCL shared library (PR #188770)

Alexey Bader via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 10:07:01 PDT 2026


================
@@ -19,15 +19,30 @@ SYCLInstallationDetector::SYCLInstallationDetector(
     const Driver &D, const llvm::Triple &HostTriple,
     const llvm::opt::ArgList &Args)
     : D(D) {
-  // Detect the presence of the SYCL runtime library (libsycl.so) in the
+  // Detect the presence of the SYCL runtime library in the
   // filesystem. This is used to determine whether a usable SYCL installation
   // is available for the current driver invocation.
   StringRef SysRoot = D.SysRoot;
   SmallString<128> DriverDir(D.Dir);
+  SmallString<128> LibPath(DriverDir);
+  llvm::sys::path::append(LibPath, "..", "lib", HostTriple.str(),
+                          "libLLVMSYCL.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", "libLLVMSYCL.so");
+
   if (DriverDir.starts_with(SysRoot) &&
-      (Args.hasArg(options::OPT_fsycl) ||
-       D.getVFS().exists(DriverDir + "/../lib/libsycl.so"))) {
-    llvm::sys::path::append(DriverDir, "..", "lib");
+      Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) {
+    if (D.getVFS().exists(LibPath))
+      // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in lib/<triple>/
+      llvm::sys::path::append(DriverDir, "..", "lib", HostTriple.str());
+    else if (D.getVFS().exists(FlatLibPath))
+      // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF: library is in lib/
+      llvm::sys::path::append(DriverDir, "..", "lib");
+    else
+      // Neither path exists — broken install, leave SYCLRTLibPath unset
+      return;
----------------
bader wrote:

```suggestion
     // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON: library is in lib/<triple>/
     if (D.getVFS().exists(LibPath))
       llvm::sys::path::append(DriverDir, "..", "lib", HostTriple.str());
     // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF: library is in lib/
     else if (D.getVFS().exists(FlatLibPath))
       llvm::sys::path::append(DriverDir, "..", "lib");
     else
       return; // broken install; SYCLRTLibPath left unset
```
Let's move comments before `if/else` statements.

https://github.com/llvm/llvm-project/pull/188770


More information about the cfe-commits mailing list