Skip to content

universal.py: search_version: make the version regex a bit more robust#15970

Open
jmarcoscosta wants to merge 1 commit into
mesonbuild:masterfrom
jmarcoscosta:v1-fix-regex-clang
Open

universal.py: search_version: make the version regex a bit more robust#15970
jmarcoscosta wants to merge 1 commit into
mesonbuild:masterfrom
jmarcoscosta:v1-fix-regex-clang

Conversation

@jmarcoscosta

Copy link
Copy Markdown

This change basically adds another check: the version number should not be followed by something other than a space.

As an example, this is the output of 'clang --version' in a custom LLVM toolchain:

(FooBar LLVM-Linux 5.0.0) clang version 21.9.0
Target: riscv64-unknown-linux-gnu
Thread model: posix
(...)

where "5.0.0" is an internal tag, unrelated to clang's version itself.

With the current regex, meson detects that clang's version is "5.0.0", and this breaks the build of some packages (e.g., appstream):

| ../sources/AppStream-1.0.6/meson.build:1:0: ERROR: None of values ['gnu17'] are supported by the C compiler. Possible values for option "c_std" are ['none', 'c89', 'c99', 'c11', 'gnu89', 'gnu99', 'gnu11']

While I understand the root cause is this spurious internal version number being present left to clang's version, I belive the current regex would be more robust if it also checks what comes next after the 'X.Y.Z' pattern.

This change basically adds another check: the version number should not
be followed by something other than a space.

As an example, this is the output of 'clang --version' in a custom LLVM
toolchain:

(FooBar LLVM-Linux 5.0.0) clang version 21.9.0
Target: riscv64-unknown-linux-gnu
Thread model: posix
(...)

where "5.0.0" is an internal tag, unrelated to clang's version itself.

With the current regex, meson detects that clang's version is "5.0.0",
and this breaks the build of some packages (e.g., appstream):

| ../sources/AppStream-1.0.6/meson.build:1:0: ERROR: None of values ['gnu17']
are supported by the C compiler. Possible values for option "c_std" are
['none', 'c89', 'c99', 'c11', 'gnu89', 'gnu99', 'gnu11']

While I understand the root cause is this spurious internal version
number being present left to clang's version, I belive the current regex
would be more robust if it also checks what comes next after the 'X.Y.Z'
pattern.

Signed-off-by: João Marcos Costa <joaomarcos.costa@bootlin.com>
@jmarcoscosta jmarcoscosta requested a review from jpakkane as a code owner July 2, 2026 09:19
@dcbaker

dcbaker commented Jul 6, 2026

Copy link
Copy Markdown
Member

There's a test in case in internaltests.py called test_version_number(), it should be updated for this case.

@bonzini bonzini added this to the 1.11.3 milestone Jul 7, 2026
@bonzini bonzini added the needs-test PR is missing a testcase label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-test PR is missing a testcase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants