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,
|
default=True,
|
||||||
description="Build the LLVM C/C++/Objective-C compiler frontend",
|
description="Build the LLVM C/C++/Objective-C compiler frontend",
|
||||||
)
|
)
|
||||||
|
variant(
|
||||||
|
"flang",
|
||||||
|
default=False,
|
||||||
|
description="Build the LLVM Fortran compiler frontend",
|
||||||
|
)
|
||||||
variant(
|
variant(
|
||||||
"omp_debug",
|
"omp_debug",
|
||||||
default=False,
|
default=False,
|
||||||
|
@ -154,6 +159,8 @@ class LlvmDoe(CMakePackage, CudaPackage):
|
||||||
|
|
||||||
conflicts("+mlir")
|
conflicts("+mlir")
|
||||||
|
|
||||||
|
conflicts("+flang", when="~clang")
|
||||||
|
|
||||||
# code signing is only necessary on macOS",
|
# code signing is only necessary on macOS",
|
||||||
conflicts('+code_signing', when='platform=linux')
|
conflicts('+code_signing', when='platform=linux')
|
||||||
conflicts('+code_signing', when='platform=cray')
|
conflicts('+code_signing', when='platform=cray')
|
||||||
|
@ -189,7 +196,7 @@ class LlvmDoe(CMakePackage, CudaPackage):
|
||||||
# detection for LLVM. See:
|
# detection for LLVM. See:
|
||||||
#
|
#
|
||||||
# https://spack.readthedocs.io/en/latest/packaging_guide.html#making-a-package-discoverable-with-spack-external-find
|
# 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
|
@classmethod
|
||||||
def filter_detected_exes(cls, prefix, exes_in_prefix):
|
def filter_detected_exes(cls, prefix, exes_in_prefix):
|
||||||
|
@ -242,6 +249,10 @@ def determine_variants(cls, exes, version_str):
|
||||||
compilers['cxx'] = exe
|
compilers['cxx'] = exe
|
||||||
elif 'clang' in exe:
|
elif 'clang' in exe:
|
||||||
compilers['c'] = exe
|
compilers['c'] = exe
|
||||||
|
elif 'flang' in exe:
|
||||||
|
variants.append('+flang')
|
||||||
|
compiler['fc'] = exe
|
||||||
|
compilers['f77'] = exe
|
||||||
elif 'ld.lld' in exe:
|
elif 'ld.lld' in exe:
|
||||||
lld_found = True
|
lld_found = True
|
||||||
compilers['ld'] = exe
|
compilers['ld'] = exe
|
||||||
|
@ -287,6 +298,28 @@ def cxx(self):
|
||||||
result = os.path.join(self.spec.prefix.bin, 'clang++')
|
result = os.path.join(self.spec.prefix.bin, 'clang++')
|
||||||
return result
|
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')
|
@run_before('cmake')
|
||||||
def codesign_check(self):
|
def codesign_check(self):
|
||||||
if self.spec.satisfies("+code_signing"):
|
if self.spec.satisfies("+code_signing"):
|
||||||
|
@ -320,6 +353,9 @@ def setup_run_environment(self, env):
|
||||||
if "+clang" in self.spec:
|
if "+clang" in self.spec:
|
||||||
env.set("CC", join_path(self.spec.prefix.bin, "clang"))
|
env.set("CC", join_path(self.spec.prefix.bin, "clang"))
|
||||||
env.set("CXX", 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"
|
root_cmakelists_dir = "llvm"
|
||||||
|
|
||||||
|
@ -390,6 +426,8 @@ def cmake_args(self):
|
||||||
projects.append("clang")
|
projects.append("clang")
|
||||||
projects.append("clang-tools-extra")
|
projects.append("clang-tools-extra")
|
||||||
projects.append("openmp")
|
projects.append("openmp")
|
||||||
|
if "+flang" in spec:
|
||||||
|
projects.append("flang")
|
||||||
if "+lldb" in spec:
|
if "+lldb" in spec:
|
||||||
projects.append("lldb")
|
projects.append("lldb")
|
||||||
if "+lld" in spec:
|
if "+lld" in spec:
|
||||||
|
|
Loading…
Reference in a new issue