summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2024-08-19 17:28:37 +0200
committerGitHub <noreply@github.com>2024-08-19 09:28:37 -0600
commit15413c725863209f6f2d00d3186d6eb11dc2cfec (patch)
treeef2f260eeb4f6860c7282fd256040a61bf9b307f
parentde754c7a4749297557120c8ff51ab1464e7a4b3a (diff)
downloadspack-15413c725863209f6f2d00d3186d6eb11dc2cfec.tar.gz
spack-15413c725863209f6f2d00d3186d6eb11dc2cfec.tar.bz2
spack-15413c725863209f6f2d00d3186d6eb11dc2cfec.tar.xz
spack-15413c725863209f6f2d00d3186d6eb11dc2cfec.zip
llvm based compilers: filter out non-compilers (#45805)
-rw-r--r--var/spack/repos/builtin/packages/aocc/package.py6
-rw-r--r--var/spack/repos/builtin/packages/apple-clang/package.py7
-rw-r--r--var/spack/repos/builtin/packages/llvm/package.py39
3 files changed, 25 insertions, 27 deletions
diff --git a/var/spack/repos/builtin/packages/aocc/package.py b/var/spack/repos/builtin/packages/aocc/package.py
index 09ca523fff..d3d16c0fc6 100644
--- a/var/spack/repos/builtin/packages/aocc/package.py
+++ b/var/spack/repos/builtin/packages/aocc/package.py
@@ -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 @@ class Aocc(Package, CompilerPackage):
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"]
diff --git a/var/spack/repos/builtin/packages/apple-clang/package.py b/var/spack/repos/builtin/packages/apple-clang/package.py
index 95c3eb54c0..ba87604cd2 100644
--- a/var/spack/repos/builtin/packages/apple-clang/package.py
+++ b/var/spack/repos/builtin/packages/apple-clang/package.py
@@ -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):
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
index 8ece089a50..cc75f8019a 100644
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -13,9 +13,29 @@ from llnl.util.lang import classproperty
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 @@ class Llvm(CMakePackage, CudaPackage, CompilerPackage):
# 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
@@ -635,19 +651,6 @@ class Llvm(CMakePackage, CudaPackage, CompilerPackage):
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:
compiler = Executable(exe)