summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kuhn <michael.kuhn@ovgu.de>2020-11-19 11:06:45 +0100
committerGitHub <noreply@github.com>2020-11-19 11:06:45 +0100
commit1b7a5e53a628e67e5d728a87f41b3b2612877522 (patch)
treec26726c768e021b5ad8cafa397af1545804e7d0f
parentdd54cb4c7a245abb6d5be2570a8fc4ceffdf22f4 (diff)
downloadspack-1b7a5e53a628e67e5d728a87f41b3b2612877522.tar.gz
spack-1b7a5e53a628e67e5d728a87f41b3b2612877522.tar.bz2
spack-1b7a5e53a628e67e5d728a87f41b3b2612877522.tar.xz
spack-1b7a5e53a628e67e5d728a87f41b3b2612877522.zip
clang/llvm: fix version detection (#19978)
This PR fixes two problems with clang/llvm's version detection. clang's version output looks like this: ``` clang version 11.0.0 Target: x86_64-unknown-linux-gnu ``` This caused clang's version to be misdetected as: ``` clang@11.0.0 Target: ``` This resulted in errors when trying to actually use it as a compiler. When using `spack external find`, we couldn't determine the compiler version, resulting in errors like this: ``` ==> Warning: "llvm@11.0.0+clang+lld+lldb" has been detected on the system but will not be added to packages.yaml [reason=c compiler not found for llvm@11.0.0+clang+lld+lldb] ``` Changing the regex to only match until the end of the line fixes these problems. Fixes: #19473
-rw-r--r--lib/spack/spack/compilers/clang.py6
-rw-r--r--lib/spack/spack/test/compilers/detection.py6
-rw-r--r--var/spack/repos/builtin/packages/llvm/package.py6
3 files changed, 11 insertions, 7 deletions
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index 5eb08cbf0a..63aefdda72 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -159,11 +159,11 @@ class Clang(Compiler):
match = re.search(
# Normal clang compiler versions are left as-is
- r'clang version ([^ )]+)-svn[~.\w\d-]*|'
+ r'clang version ([^ )\n]+)-svn[~.\w\d-]*|'
# Don't include hyphenated patch numbers in the version
# (see https://github.com/spack/spack/pull/14365 for details)
- r'clang version ([^ )]+?)-[~.\w\d-]*|'
- r'clang version ([^ )]+)',
+ r'clang version ([^ )\n]+?)-[~.\w\d-]*|'
+ r'clang version ([^ )\n]+)',
output
)
if match:
diff --git a/lib/spack/spack/test/compilers/detection.py b/lib/spack/spack/test/compilers/detection.py
index a74c4c201a..1e72dc2391 100644
--- a/lib/spack/spack/test/compilers/detection.py
+++ b/lib/spack/spack/test/compilers/detection.py
@@ -96,7 +96,11 @@ def test_apple_clang_version_detection(
('clang version 8.0.0-3 (tags/RELEASE_800/final)\n'
'Target: aarch64-unknown-linux-gnu\n'
'Thread model: posix\n'
- 'InstalledDir: /usr/bin\n', '8.0.0')
+ 'InstalledDir: /usr/bin\n', '8.0.0'),
+ ('clang version 11.0.0\n'
+ 'Target: aarch64-unknown-linux-gnu\n'
+ 'Thread model: posix\n'
+ 'InstalledDir: /usr/bin\n', '11.0.0')
])
def test_clang_version_detection(version_str, expected_version):
version = spack.compilers.clang.Clang.extract_version_from_output(
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
index 9c4cc444f5..f368cd72f9 100644
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -243,11 +243,11 @@ class Llvm(CMakePackage, CudaPackage):
def determine_version(cls, exe):
version_regex = re.compile(
# Normal clang compiler versions are left as-is
- r'clang version ([^ )]+)-svn[~.\w\d-]*|'
+ r'clang version ([^ )\n]+)-svn[~.\w\d-]*|'
# Don't include hyphenated patch numbers in the version
# (see https://github.com/spack/spack/pull/14365 for details)
- r'clang version ([^ )]+?)-[~.\w\d-]*|'
- r'clang version ([^ )]+)|'
+ r'clang version ([^ )\n]+?)-[~.\w\d-]*|'
+ r'clang version ([^ )\n]+)|'
# LLDB
r'lldb version ([^ )\n]+)|'
# LLD