llvm based compilers: filter out non-compilers (#45805)

This commit is contained in:
Massimiliano Culpo 2024-08-19 17:28:37 +02:00 committed by GitHub
parent de754c7a47
commit 15413c7258
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 27 deletions

View File

@ -6,9 +6,10 @@
from llnl.util import tty
from spack.package import *
from spack.pkg.builtin.llvm import LlvmDetection
class Aocc(Package, CompilerPackage):
class Aocc(Package, LlvmDetection, CompilerPackage):
"""
The AOCC compiler system is a high performance, production quality code
generation tool. The AOCC environment provides various options to developers
@ -107,8 +108,5 @@ def cfg_files(self):
with open(join_path(self.prefix.bin, "{}.cfg".format(compiler)), "w") as f:
f.write(compiler_options)
compiler_version_argument = "--version"
compiler_version_regex = r"AOCC_(\d+[._]\d+[._]\d+)"
c_names = ["clang"]
cxx_names = ["clang++"]
fortran_names = ["flang"]

View File

@ -3,9 +3,10 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.package import *
from spack.pkg.builtin.llvm import LlvmDetection
class AppleClang(BundlePackage, CompilerPackage):
class AppleClang(BundlePackage, LlvmDetection, CompilerPackage):
"""Apple's Clang compiler"""
homepage = "https://developer.apple.com/videos/developer-tools/compiler-and-llvm"
@ -14,11 +15,7 @@ class AppleClang(BundlePackage, CompilerPackage):
maintainers("alalazo")
compiler_languages = ["c", "cxx"]
c_names = ["clang"]
cxx_names = ["clang++"]
compiler_version_regex = r"^Apple (?:LLVM|clang) version ([^ )]+)"
compiler_version_argument = "--version"
@classmethod
def validate_detected_spec(cls, spec, extra_attributes):

View File

@ -13,9 +13,29 @@
import spack.build_environment
import spack.util.executable
from spack.package import *
from spack.package_base import PackageBase
class Llvm(CMakePackage, CudaPackage, CompilerPackage):
class LlvmDetection(PackageBase):
"""Base class to detect LLVM based compilers"""
compiler_version_argument = "--version"
c_names = ["clang"]
cxx_names = ["clang++"]
@classmethod
def filter_detected_exes(cls, prefix, exes_in_prefix):
# Executables like lldb-vscode-X are daemon listening on some port and would hang Spack
# during detection. clang-cl, clang-cpp, etc. are dev tools that we don't need to test
reject = re.compile(
r"-(vscode|cpp|cl|gpu|tidy|rename|scan-deps|format|refactor|offload|"
r"check|query|doc|move|extdef|apply|reorder|change-namespace|"
r"include-fixer|import-test)"
)
return [x for x in exes_in_prefix if not reject.search(x)]
class Llvm(CMakePackage, CudaPackage, LlvmDetection, CompilerPackage):
"""The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies. Despite its name, LLVM has little to do
with traditional virtual machines, though it does provide helpful
@ -615,10 +635,6 @@ def patch(self):
# LLD
r"LLD ([^ )\n]+) \(compatible with GNU linkers\)"
)
compiler_version_argument = "--version"
compiler_languages = ["c", "cxx", "fortran"]
c_names = ["clang"]
cxx_names = ["clang++"]
fortran_names = ["flang"]
@property
@ -634,19 +650,6 @@ def supported_languages(self):
def executables(cls):
return super().executables + ["ld.lld", "lldb"]
@classmethod
def filter_detected_exes(cls, prefix, exes_in_prefix):
result = []
for exe in exes_in_prefix:
# Executables like lldb-vscode-X are daemon listening
# on some port and would hang Spack during detection.
# clang-cl and clang-cpp are dev tools that we don't
# need to test
if any(x in exe for x in ("vscode", "cpp", "-cl", "-gpu")):
continue
result.append(exe)
return result
@classmethod
def determine_version(cls, exe):
try: