summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/detect.py
diff options
context:
space:
mode:
authorLiza Chevalier <lizalc@pm.me>2025-10-29 11:17:00 -0500
committerDylan Baker <dylan@pnwbakers.com>2025-10-29 12:35:55 -0700
commitba860d72a96932608bb2b13a2f32ebda0087905a (patch)
treed40fb1da7ea242673c6f7896c70be6ed12d6416e /mesonbuild/compilers/detect.py
parente9d255de1580235fff96e110001ce4293006caaa (diff)
downloadmeson-ba860d72a96932608bb2b13a2f32ebda0087905a.tar.gz
compilers: add Microchip XC32 compiler
The Microchip XC32 compiler is a GCC-based compiler implemented using existing GNU compiler classes. As the XC32 version and GCC version do not match mixins have been implemented to override versions used in versions checks where applicable.
Diffstat (limited to 'mesonbuild/compilers/detect.py')
-rw-r--r--mesonbuild/compilers/detect.py44
1 files changed, 34 insertions, 10 deletions
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 979b9ce60..0a5f55ddd 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -227,8 +227,11 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
return linkers.DLinker(linker, compiler.arch)
if err.startswith('Renesas') and 'rlink' in linker_name:
return linkers.CcrxLinker(linker)
- if out.startswith('GNU ar') and 'xc16-ar' in linker_name:
- return linkers.Xc16Linker(linker)
+ if out.startswith('GNU ar'):
+ if 'xc16-ar' in linker_name:
+ return linkers.Xc16Linker(linker)
+ elif 'xc32-ar' in linker_name:
+ return linkers.Xc32ArLinker(compiler.for_machine, linker)
if 'Texas Instruments Incorporated' in out:
if 'ar2000' in linker_name:
return linkers.C2000Linker(linker)
@@ -343,7 +346,7 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin
guess_gcc_or_lcc = 'gcc'
if 'e2k' in out and 'lcc' in out:
guess_gcc_or_lcc = 'lcc'
- if 'Microchip Technology' in out:
+ if 'Microchip' in out:
# this output has "Free Software Foundation" in its version
guess_gcc_or_lcc = None
@@ -567,13 +570,34 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin
ccache, compiler, version, for_machine, is_cross, info,
full_version=full_version, linker=linker)
- if 'Microchip Technology' in out:
- cls = c.Xc16CCompiler
- env.add_lang_args(cls.language, cls, for_machine)
- linker = linkers.Xc16DynamicLinker(for_machine, version=version)
- return cls(
- ccache, compiler, version, for_machine, is_cross, info,
- full_version=full_version, linker=linker)
+ if 'Microchip' in out:
+ if 'XC32' in out:
+ # XC32 versions always have the form 'vMAJOR.MINOR'
+ match = re.search(r'XC32.*v(\d+\.\d+)', out)
+ if match:
+ version = match.group(1)
+ else:
+ raise EnvironmentException(f'Failed to detect XC32 compiler version: full version was\n{full_version}')
+
+ cls = c.Xc32CCompiler if lang == 'c' else cpp.Xc32CPPCompiler
+ defines = _get_gnu_compiler_defines(compiler, lang)
+ cls.gcc_version = _get_gnu_version_from_defines(defines)
+
+ env.add_lang_args(cls.language, cls, for_machine)
+ linker = linkers.Xc32DynamicLinker(compiler, for_machine, cls.LINKER_PREFIX, [], version=version)
+
+ return cls(
+ ccache, compiler, version, for_machine, is_cross,
+ info, defines=defines, full_version=full_version,
+ linker=linker)
+ else:
+ cls = c.Xc16CCompiler
+ env.add_lang_args(cls.language, cls, for_machine)
+ linker = linkers.Xc16DynamicLinker(for_machine, version=version)
+
+ return cls(
+ ccache, compiler, version, for_machine, is_cross, info,
+ full_version=full_version, linker=linker)
if 'CompCert' in out:
cls = c.CompCertCCompiler