[llvm] [Offload] Try to load Level Zero loader with version suffix (PR #180042)

Nick Sarnie via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 6 07:33:19 PST 2026


================
@@ -111,6 +111,24 @@ static bool loadLevelZero() {
   ODBG(OLDT_Init) << "Trying to load " << L0Library;
   auto DynlibHandle = std::make_unique<llvm::sys::DynamicLibrary>(
       llvm::sys::DynamicLibrary::getPermanentLibrary(L0Library, &ErrMsg));
+#ifndef _WIN32
+  if (!DynlibHandle->isValid()) {
+    // Try to open loader with major version number. It is repeated from the
+    // current version down to 1.
+    std::string LoaderName{LEVEL_ZERO_LIBRARY};
+    LoaderName += ".";
+    constexpr int MinZeVersion{1};
+    int CurrVersion = ZE_MAJOR_VERSION(ZE_API_VERSION_CURRENT);
+    for (int I = CurrVersion; I >= MinZeVersion && !DynlibHandle->isValid();
+         I--) {
+      std::string LoaderVer{LoaderName + std::to_string(I)};
+      ODBG(OLDT_Init) << "Trying to load " << LoaderVer;
+      DynlibHandle = std::make_unique<llvm::sys::DynamicLibrary>(
----------------
sarnex wrote:

If we care about that case then my understanding of your previous comment is that the ABI may not be compatible. Should we only try to look for versions with matching major versions to the one that was used to build the plugin?

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


More information about the llvm-commits mailing list