From c006cb573ac9f7f15fd4d2d483dbcdc81f62c03a Mon Sep 17 00:00:00 2001 From: Sean Koyama Date: Fri, 18 Oct 2024 08:50:12 -0700 Subject: implement prefix property for OneAPI compiler (#47066) --- lib/spack/spack/compilers/oneapi.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib') 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: /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 /bin/compiler to + 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: -- cgit v1.2.3-70-g09d2