diff --git a/lnt/testing/util/compilers.py b/lnt/testing/util/compilers.py index a232632a..574f4ffc 100644 --- a/lnt/testing/util/compilers.py +++ b/lnt/testing/util/compilers.py @@ -76,7 +76,8 @@ def get_cc_info(path, cc_flags=[]): logger.error("unable to find compiler version: %r: %r" % (cc, cc_version)) else: - m = re.match(r'(.*) version ([^ ]*) +(\([^(]*\))(.*)', version_ln) + m = re.match(r'(.*) version ([^ ]*) (?:[0-9]+ )?+(\([^(]*\))(.*)', + version_ln) if m is not None: cc_name, cc_version_num, cc_build_string, cc_extra = m.groups() else: @@ -104,15 +105,17 @@ def get_cc_info(path, cc_flags=[]): cc_src_tag = cc_version_num elif cc_name == 'gcc' and (cc_extra == '' or + cc_extra == '(GCC)' or re.match(r' \(dot [0-9]+\)', cc_extra)): cc_norm_name = 'gcc' m = re.match(r'\(Apple Inc. build ([0-9]*)\)', cc_build_string) if m: cc_build = 'PROD' cc_src_tag, = m.groups() + elif 'experimental' in cc_build_string: + cc_build = 'DEV' else: - logger.error('unable to determine gcc build version: %r' % - cc_build_string) + cc_build = 'PROD' elif (cc_name in ('clang', 'LLVM', 'Debian clang', 'Apple clang', 'Apple LLVM') and (cc_extra == '' or 'based on LLVM' in cc_extra or diff --git a/tests/SharedInputs/FakeCompilers/fakecompiler.py b/tests/SharedInputs/FakeCompilers/fakecompiler.py index 1df93baa..5fe1970f 100755 --- a/tests/SharedInputs/FakeCompilers/fakecompiler.py +++ b/tests/SharedInputs/FakeCompilers/fakecompiler.py @@ -178,6 +178,28 @@ def print_verbose_info(self): "%s" "-cc1" "-E" ... more boring stuff here ...""" % ( g_program,), file=sys.stderr) +class GCCDebian(FakeCompiler): + compiler_name = "gcc-debian" + + def print_verbose_info(self): + print("""\ +Target: x86_64-linux-gnu +gcc version 12.2.0 (Debian 12.2.0-14+deb12u1)""", file=sys.stderr) + + def print_dumpmachine(self): + print("x86_64-linux-gnu") + +class GCCTrunk(FakeCompiler): + compiler_name = "gcc-trunk" + + def print_verbose_info(self): + print("""\ +Target: x86_64-linux-gnu +gcc version 16.0.0 20250807 (experimental) (GCC)""", file=sys.stderr) + + def print_dumpmachine(self): + print("x86_64-linux-gnu") + fake_compilers = dict((value.compiler_name, value) for key, value in locals().items() diff --git a/tests/SharedInputs/FakeCompilers/gcc-debian b/tests/SharedInputs/FakeCompilers/gcc-debian new file mode 120000 index 00000000..1b836b13 --- /dev/null +++ b/tests/SharedInputs/FakeCompilers/gcc-debian @@ -0,0 +1 @@ +fakecompiler.py \ No newline at end of file diff --git a/tests/SharedInputs/FakeCompilers/gcc-trunk b/tests/SharedInputs/FakeCompilers/gcc-trunk new file mode 120000 index 00000000..1b836b13 --- /dev/null +++ b/tests/SharedInputs/FakeCompilers/gcc-trunk @@ -0,0 +1 @@ +fakecompiler.py \ No newline at end of file diff --git a/tests/testing/Compilers.py b/tests/testing/Compilers.py index 901c4a02..6aacc667 100644 --- a/tests/testing/Compilers.py +++ b/tests/testing/Compilers.py @@ -66,3 +66,19 @@ def get_info(name): pprint.pprint(info) assert info['cc_name'] == 'clang' assert info['cc_version_number'] == '3.2' + +# Check a GCC packaged from Debian. +info = get_info("gcc-debian") +pprint.pprint(info) +assert info['cc_name'] == 'gcc' +assert info['cc_build'] == 'PROD' +assert info['cc_version_number'] == '12.2.0' +assert info['cc_target'] == 'x86_64-linux-gnu' + +# Check a GCC built from trunk. +info = get_info("gcc-trunk") +pprint.pprint(info) +assert info['cc_name'] == 'gcc' +assert info['cc_build'] == 'DEV' +assert info['cc_version_number'] == '16.0.0' +assert info['cc_target'] == 'x86_64-linux-gnu'