From c458e985affe020edf79c4e47f2156b0a1b7a308 Mon Sep 17 00:00:00 2001 From: Stephen Nicholas Swatman Date: Wed, 10 Jul 2024 14:50:07 +0200 Subject: Set `LD_LIBRARY_PATH` for OneAPI compiler (#45059) While trying to build packages with the OneAPI compiler version 2024.1 I ran into the following error, indicating that the compiler is unable to find some necessary libraries: ``` /storage/Software/oneapi/2024.1/compiler/2024.1/bin/sycl-post-link: error while loading shared libraries: libonnxruntime.1.12.22.721.so: cannot open shared object file: No such file or directory icpx: error: unable to execute command: No such file or directory icpx: error: sycl-post-link command failed due to signal (use -v to see invocation) ``` Indeed, `libonnxruntime.1.12.22.721.so` does come bundled with the OneAPI compiler, but it is not available in the build environment by default. In this commit, I update the custom environment created by OneAPI to include the `lib/` directory in which these libraries reside in the `LD_LIBRARY_PATH` environment variable. --- lib/spack/spack/compilers/oneapi.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/compilers/oneapi.py b/lib/spack/spack/compilers/oneapi.py index ecba99081a..1baac83826 100644 --- a/lib/spack/spack/compilers/oneapi.py +++ b/lib/spack/spack/compilers/oneapi.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import os -from os.path import dirname +from os.path import dirname, join from llnl.util import tty @@ -135,8 +135,12 @@ class Oneapi(Compiler): # It is located in the same directory as the driver. Error message: # clang++: error: unable to execute command: # Executable "sycl-post-link" doesn't exist! - if self.cxx: + # also ensures that shared objects and libraries required by the compiler, + # e.g. libonnx, can be found succesfully + # due to a fix, this is no longer required for OneAPI versions >= 2024.2 + if self.cxx and pkg.spec.satisfies("%oneapi@:2024.1"): env.prepend_path("PATH", dirname(self.cxx)) + env.prepend_path("LD_LIBRARY_PATH", join(dirname(dirname(self.cxx)), "lib")) # 2024 release bumped the libsycl version because of an ABI # change, 2024 compilers are required. You will see this -- cgit v1.2.3-70-g09d2