llvm-doe: add +flang variant (#21610)
This commit is contained in:
parent
6e18188d43
commit
e2c16bfe22
1 changed files with 39 additions and 1 deletions
|
@ -36,6 +36,11 @@ class LlvmDoe(CMakePackage, CudaPackage):
|
|||
default=True,
|
||||
description="Build the LLVM C/C++/Objective-C compiler frontend",
|
||||
)
|
||||
variant(
|
||||
"flang",
|
||||
default=False,
|
||||
description="Build the LLVM Fortran compiler frontend",
|
||||
)
|
||||
variant(
|
||||
"omp_debug",
|
||||
default=False,
|
||||
|
@ -154,6 +159,8 @@ class LlvmDoe(CMakePackage, CudaPackage):
|
|||
|
||||
conflicts("+mlir")
|
||||
|
||||
conflicts("+flang", when="~clang")
|
||||
|
||||
# code signing is only necessary on macOS",
|
||||
conflicts('+code_signing', when='platform=linux')
|
||||
conflicts('+code_signing', when='platform=cray')
|
||||
|
@ -189,7 +196,7 @@ class LlvmDoe(CMakePackage, CudaPackage):
|
|||
# detection for LLVM. See:
|
||||
#
|
||||
# https://spack.readthedocs.io/en/latest/packaging_guide.html#making-a-package-discoverable-with-spack-external-find
|
||||
executables = ['clang', 'ld.lld', 'lldb']
|
||||
executables = ['clang', 'flang', 'ld.lld', 'lldb']
|
||||
|
||||
@classmethod
|
||||
def filter_detected_exes(cls, prefix, exes_in_prefix):
|
||||
|
@ -242,6 +249,10 @@ def determine_variants(cls, exes, version_str):
|
|||
compilers['cxx'] = exe
|
||||
elif 'clang' in exe:
|
||||
compilers['c'] = exe
|
||||
elif 'flang' in exe:
|
||||
variants.append('+flang')
|
||||
compiler['fc'] = exe
|
||||
compilers['f77'] = exe
|
||||
elif 'ld.lld' in exe:
|
||||
lld_found = True
|
||||
compilers['ld'] = exe
|
||||
|
@ -287,6 +298,28 @@ def cxx(self):
|
|||
result = os.path.join(self.spec.prefix.bin, 'clang++')
|
||||
return result
|
||||
|
||||
@property
|
||||
def fc(self):
|
||||
msg = "cannot retrieve Fortran compiler [spec is not concrete]"
|
||||
assert self.spec.concrete, msg
|
||||
if self.spec.external:
|
||||
return self.spec.extra_attributes['compilers'].get('fc', None)
|
||||
result = None
|
||||
if '+flang' in self.spec:
|
||||
result = os.path.join(self.spec.prefix.bin, 'flang')
|
||||
return result
|
||||
|
||||
@property
|
||||
def f77(self):
|
||||
msg = "cannot retrieve Fortran 77 compiler [spec is not concrete]"
|
||||
assert self.spec.concrete, msg
|
||||
if self.spec.external:
|
||||
return self.spec.extra_attributes['compilers'].get('f77', None)
|
||||
result = None
|
||||
if '+flang' in self.spec:
|
||||
result = os.path.join(self.spec.prefix.bin, 'flang')
|
||||
return result
|
||||
|
||||
@run_before('cmake')
|
||||
def codesign_check(self):
|
||||
if self.spec.satisfies("+code_signing"):
|
||||
|
@ -320,6 +353,9 @@ def setup_run_environment(self, env):
|
|||
if "+clang" in self.spec:
|
||||
env.set("CC", join_path(self.spec.prefix.bin, "clang"))
|
||||
env.set("CXX", join_path(self.spec.prefix.bin, "clang++"))
|
||||
if "+flang" in self.spec:
|
||||
env.set("FC", join_path(self.spec.prefix.bin, "flang"))
|
||||
env.set("F77", join_path(self.spec.prefix.bin, "flang"))
|
||||
|
||||
root_cmakelists_dir = "llvm"
|
||||
|
||||
|
@ -390,6 +426,8 @@ def cmake_args(self):
|
|||
projects.append("clang")
|
||||
projects.append("clang-tools-extra")
|
||||
projects.append("openmp")
|
||||
if "+flang" in spec:
|
||||
projects.append("flang")
|
||||
if "+lldb" in spec:
|
||||
projects.append("lldb")
|
||||
if "+lld" in spec:
|
||||
|
|
Loading…
Reference in a new issue