
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.
154 lines
4.7 KiB
Python
154 lines
4.7 KiB
Python
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
|
#
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
import os
|
|
from os.path import dirname, join
|
|
|
|
from llnl.util import tty
|
|
|
|
from spack.compiler import Compiler
|
|
|
|
|
|
class Oneapi(Compiler):
|
|
# Subclasses use possible names of C compiler
|
|
cc_names = ["icx"]
|
|
|
|
# Subclasses use possible names of C++ compiler
|
|
cxx_names = ["icpx"]
|
|
|
|
# Subclasses use possible names of Fortran 77 compiler
|
|
f77_names = ["ifx"]
|
|
|
|
# Subclasses use possible names of Fortran 90 compiler
|
|
fc_names = ["ifx"]
|
|
|
|
# Named wrapper links within build_env_path
|
|
link_paths = {
|
|
"cc": os.path.join("oneapi", "icx"),
|
|
"cxx": os.path.join("oneapi", "icpx"),
|
|
"f77": os.path.join("oneapi", "ifx"),
|
|
"fc": os.path.join("oneapi", "ifx"),
|
|
}
|
|
|
|
PrgEnv = "PrgEnv-oneapi"
|
|
PrgEnv_compiler = "oneapi"
|
|
|
|
version_argument = "--version"
|
|
version_regex = r"(?:(?:oneAPI DPC\+\+(?:\/C\+\+)? Compiler)|(?:\(IFORT\))|(?:\(IFX\))) (\S+)"
|
|
|
|
@property
|
|
def verbose_flag(self):
|
|
return "-v"
|
|
|
|
required_libs = [
|
|
"libirc",
|
|
"libifcore",
|
|
"libifcoremt",
|
|
"libirng",
|
|
"libsvml",
|
|
"libintlc",
|
|
"libimf",
|
|
"libsycl",
|
|
"libOpenCL",
|
|
]
|
|
|
|
@property
|
|
def debug_flags(self):
|
|
return ["-debug", "-g", "-g0", "-g1", "-g2", "-g3"]
|
|
|
|
@property
|
|
def opt_flags(self):
|
|
return ["-O", "-O0", "-O1", "-O2", "-O3", "-Ofast", "-Os"]
|
|
|
|
@property
|
|
def openmp_flag(self):
|
|
return "-fiopenmp"
|
|
|
|
# There may be some additional options here for offload, e.g. :
|
|
# -fopenmp-simd Emit OpenMP code only for SIMD-based constructs.
|
|
# -fopenmp-targets=<value>
|
|
# -fopenmp-version=<value>
|
|
# -fopenmp Parse OpenMP pragmas and generate parallel code.
|
|
# -qno-openmp Disable OpenMP support
|
|
# -qopenmp-link=<value> Choose whether to link with the static or
|
|
# dynamic OpenMP libraries. Default is dynamic.
|
|
# -qopenmp-simd Emit OpenMP code only for SIMD-based constructs.
|
|
# -qopenmp-stubs enables the user to compile OpenMP programs in
|
|
# sequential mode. The OpenMP directives are
|
|
# ignored and a stub OpenMP library is linked.
|
|
# -qopenmp-threadprivate=<value>
|
|
# -qopenmp Parse OpenMP pragmas and generate parallel code.
|
|
# -static-openmp Use the static host OpenMP runtime while
|
|
# linking.
|
|
# -Xopenmp-target=<triple> <arg>
|
|
# -Xopenmp-target <arg> Pass <arg> to the target offloading toolchain.
|
|
# Source: icx --help output
|
|
|
|
@property
|
|
def cxx11_flag(self):
|
|
return "-std=c++11"
|
|
|
|
@property
|
|
def cxx14_flag(self):
|
|
return "-std=c++14"
|
|
|
|
@property
|
|
def cxx17_flag(self):
|
|
return "-std=c++17"
|
|
|
|
@property
|
|
def cxx20_flag(self):
|
|
return "-std=c++20"
|
|
|
|
@property
|
|
def c99_flag(self):
|
|
return "-std=c99"
|
|
|
|
@property
|
|
def c11_flag(self):
|
|
return "-std=c1x"
|
|
|
|
@property
|
|
def cc_pic_flag(self):
|
|
return "-fPIC"
|
|
|
|
@property
|
|
def cxx_pic_flag(self):
|
|
return "-fPIC"
|
|
|
|
@property
|
|
def f77_pic_flag(self):
|
|
return "-fPIC"
|
|
|
|
@property
|
|
def fc_pic_flag(self):
|
|
return "-fPIC"
|
|
|
|
@property
|
|
def stdcxx_libs(self):
|
|
return ("-cxxlib",)
|
|
|
|
def setup_custom_environment(self, pkg, env):
|
|
# workaround bug in icpx driver where it requires sycl-post-link is on the PATH
|
|
# 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!
|
|
# 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
|
|
# error:
|
|
#
|
|
# /usr/bin/ld: warning: libsycl.so.7, needed by ...., not found
|
|
if pkg.spec.satisfies("%oneapi@:2023"):
|
|
for c in ["dnn"]:
|
|
if pkg.spec.satisfies(f"^intel-oneapi-{c}@2024:"):
|
|
tty.warn(f"intel-oneapi-{c}@2024 SYCL APIs requires %oneapi@2024:")
|