diff options
author | Sean Koyama <skoyama@anl.gov> | 2024-10-18 08:50:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-18 11:50:12 -0400 |
commit | c006cb573ac9f7f15fd4d2d483dbcdc81f62c03a (patch) | |
tree | 667c8866cd95d22372930a86a8778d114ae44a0a /lib | |
parent | d8d41e9b0e6efd698b38b021962be24c8d022174 (diff) | |
download | spack-c006cb573ac9f7f15fd4d2d483dbcdc81f62c03a.tar.gz spack-c006cb573ac9f7f15fd4d2d483dbcdc81f62c03a.tar.bz2 spack-c006cb573ac9f7f15fd4d2d483dbcdc81f62c03a.tar.xz spack-c006cb573ac9f7f15fd4d2d483dbcdc81f62c03a.zip |
implement prefix property for OneAPI compiler (#47066)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/compilers/oneapi.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/spack/spack/compilers/oneapi.py b/lib/spack/spack/compilers/oneapi.py index ee279433c3..b0cfadc505 100644 --- a/lib/spack/spack/compilers/oneapi.py +++ b/lib/spack/spack/compilers/oneapi.py @@ -7,7 +7,9 @@ import os from os.path import dirname, join from llnl.util import tty +from llnl.util.filesystem import ancestor +import spack.util.executable from spack.compiler import Compiler from spack.version import Version @@ -116,6 +118,24 @@ class Oneapi(Compiler): def stdcxx_libs(self): return ("-cxxlib",) + @property + def prefix(self): + # OneAPI reports its install prefix when running ``--version`` + # on the line ``InstalledDir: <prefix>/bin/compiler``. + cc = spack.util.executable.Executable(self.cc) + with self.compiler_environment(): + oneapi_output = cc("--version", output=str, error=str) + + for line in oneapi_output.splitlines(): + if line.startswith("InstalledDir:"): + oneapi_prefix = line.split(":")[1].strip() + # Go from <prefix>/bin/compiler to <prefix> + return ancestor(oneapi_prefix, 2) + + raise RuntimeError( + "could not find install prefix of OneAPI from output:\n\t{}".format(oneapi_output) + ) + 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: |