implement prefix property for OneAPI compiler (#47066)
This commit is contained in:
parent
d8d41e9b0e
commit
c006cb573a
@ -7,7 +7,9 @@
|
|||||||
from os.path import dirname, join
|
from os.path import dirname, join
|
||||||
|
|
||||||
from llnl.util import tty
|
from llnl.util import tty
|
||||||
|
from llnl.util.filesystem import ancestor
|
||||||
|
|
||||||
|
import spack.util.executable
|
||||||
from spack.compiler import Compiler
|
from spack.compiler import Compiler
|
||||||
from spack.version import Version
|
from spack.version import Version
|
||||||
|
|
||||||
@ -116,6 +118,24 @@ def fc_pic_flag(self):
|
|||||||
def stdcxx_libs(self):
|
def stdcxx_libs(self):
|
||||||
return ("-cxxlib",)
|
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):
|
def setup_custom_environment(self, pkg, env):
|
||||||
# workaround bug in icpx driver where it requires sycl-post-link is on the PATH
|
# 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:
|
# It is located in the same directory as the driver. Error message:
|
||||||
|
Loading…
Reference in New Issue
Block a user