Skip to content

Commit f24307e

Browse files
authored
Merge pull request mesonbuild#11421 from mon/ti-armclang
Basic support for TI Arm Clang toolchain
2 parents bfb9ca0 + 456d879 commit f24307e

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Basic support for TI Arm Clang (tiarmclang)
2+
3+
Support for TI's newer [Clang-based ARM toolchain](https://www.ti.com/tool/ARM-CGT).

mesonbuild/compilers/detect.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,13 @@ def detect_static_linker(env: 'Environment', compiler: Compiler) -> StaticLinker
224224
return linkers.CcrxLinker(linker)
225225
if out.startswith('GNU ar') and 'xc16-ar' in linker_name:
226226
return linkers.Xc16Linker(linker)
227-
if "--> error: bad option 'e'" in err: # TI
227+
if 'Texas Instruments Incorporated' in out:
228228
if 'ar2000' in linker_name:
229229
return linkers.C2000Linker(linker)
230+
elif 'ar6000' in linker_name:
231+
return linkers.C6000Linker(linker)
230232
else:
231233
return linkers.TILinker(linker)
232-
if 'Texas Instruments Incorporated' in out:
233-
if 'ar6000' in linker_name:
234-
return linkers.C6000Linker(linker)
235234
if out.startswith('The CompCert'):
236235
return linkers.CompCertLinker(linker)
237236
if out.strip().startswith('Metrowerks') or out.strip().startswith('Freescale'):
@@ -437,8 +436,8 @@ def sanitize(p: T.Optional[str]) -> T.Optional[str]:
437436
'TI ARM C/C++ Compiler': (c.TICCompiler, cpp.TICPPCompiler, linkers.TIDynamicLinker),
438437
'MSP430 C/C++': (c.TICCompiler, cpp.TICPPCompiler, linkers.TIDynamicLinker)
439438
}
440-
for indentifier, compiler_classes in ti_compilers.items():
441-
if indentifier in out:
439+
for identifier, compiler_classes in ti_compilers.items():
440+
if identifier in out:
442441
cls = compiler_classes[0] if lang == 'c' else compiler_classes[1]
443442
lnk = compiler_classes[2]
444443
env.coredata.add_lang_args(cls.language, cls, for_machine, env)

mesonbuild/linkers/detect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty
141141

142142
v = search_version(o + e)
143143
linker: DynamicLinker
144-
if 'LLD' in o.split('\n', maxsplit=1)[0]:
144+
if 'LLD' in o.split('\n', maxsplit=1)[0] or 'tiarmlnk' in e:
145145
if isinstance(comp_class.LINKER_PREFIX, str):
146146
cmd = compiler + override + [comp_class.LINKER_PREFIX + '-v'] + extra_args
147147
else:

mesonbuild/linkers/linkers.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,15 +885,36 @@ def __init__(self, exelist: T.List[str],
885885
super().__init__(exelist, for_machine, prefix_arg, always_args, version=version)
886886

887887
# Some targets don't seem to support this argument (windows, wasm, ...)
888-
_, _, e = mesonlib.Popen_safe(self.exelist + always_args + self._apply_prefix('--allow-shlib-undefined'))
889-
# Versions < 9 do not have a quoted argument
890-
self.has_allow_shlib_undefined = ('unknown argument: --allow-shlib-undefined' not in e) and ("unknown argument: '--allow-shlib-undefined'" not in e)
888+
self.has_allow_shlib_undefined = self._supports_flag('--allow-shlib-undefined', always_args)
889+
# These aren't supported by TI Arm Clang
890+
self.has_as_needed = self._supports_flag('--as-needed', always_args)
891+
self.has_no_undefined = self._supports_flag('--no-undefined', always_args)
892+
893+
def _supports_flag(self, flag: str, always_args: T.List[str]) -> bool:
894+
_, _, e = mesonlib.Popen_safe(self.exelist + always_args + self._apply_prefix(flag))
895+
return (
896+
# Versions < 9 do not have a quoted argument
897+
(f'unknown argument: {flag}' not in e) and
898+
(f"unknown argument: '{flag}'" not in e) and
899+
# TI Arm Clang uses a different message
900+
(f'invalid option: {flag}' not in e)
901+
)
891902

892903
def get_allow_undefined_args(self) -> T.List[str]:
893904
if self.has_allow_shlib_undefined:
894905
return self._apply_prefix('--allow-shlib-undefined')
895906
return []
896907

908+
def get_asneeded_args(self) -> T.List[str]:
909+
if self.has_as_needed:
910+
return self._apply_prefix('--as-needed')
911+
return []
912+
913+
def no_undefined_args(self) -> T.List[str]:
914+
if self.has_no_undefined:
915+
return self._apply_prefix('--no-undefined')
916+
return []
917+
897918
def get_thinlto_cache_args(self, path: str) -> T.List[str]:
898919
return ['-Wl,--thinlto-cache-dir=' + path]
899920

0 commit comments

Comments
 (0)