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
This commit is contained in:
parent
9120856c01
commit
6b0c775448
3 changed files with 11 additions and 7 deletions
|
@ -159,11 +159,11 @@ def extract_version_from_output(cls, output):
|
||||||
|
|
||||||
match = re.search(
|
match = re.search(
|
||||||
# Normal clang compiler versions are left as-is
|
# 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
|
# Don't include hyphenated patch numbers in the version
|
||||||
# (see https://github.com/spack/spack/pull/14365 for details)
|
# (see https://github.com/spack/spack/pull/14365 for details)
|
||||||
r'clang version ([^ )]+?)-[~.\w\d-]*|'
|
r'clang version ([^ )\n]+?)-[~.\w\d-]*|'
|
||||||
r'clang version ([^ )]+)',
|
r'clang version ([^ )\n]+)',
|
||||||
output
|
output
|
||||||
)
|
)
|
||||||
if match:
|
if match:
|
||||||
|
|
|
@ -96,7 +96,11 @@ def test_apple_clang_version_detection(
|
||||||
('clang version 8.0.0-3 (tags/RELEASE_800/final)\n'
|
('clang version 8.0.0-3 (tags/RELEASE_800/final)\n'
|
||||||
'Target: aarch64-unknown-linux-gnu\n'
|
'Target: aarch64-unknown-linux-gnu\n'
|
||||||
'Thread model: posix\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):
|
def test_clang_version_detection(version_str, expected_version):
|
||||||
version = spack.compilers.clang.Clang.extract_version_from_output(
|
version = spack.compilers.clang.Clang.extract_version_from_output(
|
||||||
|
|
|
@ -244,11 +244,11 @@ def filter_detected_exes(cls, prefix, exes_in_prefix):
|
||||||
def determine_version(cls, exe):
|
def determine_version(cls, exe):
|
||||||
version_regex = re.compile(
|
version_regex = re.compile(
|
||||||
# Normal clang compiler versions are left as-is
|
# 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
|
# Don't include hyphenated patch numbers in the version
|
||||||
# (see https://github.com/spack/spack/pull/14365 for details)
|
# (see https://github.com/spack/spack/pull/14365 for details)
|
||||||
r'clang version ([^ )]+?)-[~.\w\d-]*|'
|
r'clang version ([^ )\n]+?)-[~.\w\d-]*|'
|
||||||
r'clang version ([^ )]+)|'
|
r'clang version ([^ )\n]+)|'
|
||||||
# LLDB
|
# LLDB
|
||||||
r'lldb version ([^ )\n]+)|'
|
r'lldb version ([^ )\n]+)|'
|
||||||
# LLD
|
# LLD
|
||||||
|
|
Loading…
Reference in a new issue