Skip to content

Commit

Permalink
Basic support for TI ARM-CLANG toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
William Toohey authored and soumyaDghosh committed Jun 4, 2024
1 parent 0e46d51 commit 04604b3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/markdown/snippets/ti_armclang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Basic support for TI Arm Clang (tiarmclang)

Support for TI's newer [Clang-based ARM toolchain](https://www.ti.com/tool/ARM-CGT).
2 changes: 1 addition & 1 deletion mesonbuild/linkers/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def guess_nix_linker(env: 'Environment', compiler: T.List[str], comp_class: T.Ty

v = search_version(o + e)
linker: DynamicLinker
if 'LLD' in o.split('\n', maxsplit=1)[0]:
if 'LLD' in o.split('\n', maxsplit=1)[0] or 'tiarmlnk' in e:
if isinstance(comp_class.LINKER_PREFIX, str):
cmd = compiler + override + [comp_class.LINKER_PREFIX + '-v'] + extra_args
else:
Expand Down
27 changes: 24 additions & 3 deletions mesonbuild/linkers/linkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,15 +885,36 @@ def __init__(self, exelist: T.List[str],
super().__init__(exelist, for_machine, prefix_arg, always_args, version=version)

# Some targets don't seem to support this argument (windows, wasm, ...)
_, _, e = mesonlib.Popen_safe(self.exelist + always_args + self._apply_prefix('--allow-shlib-undefined'))
# Versions < 9 do not have a quoted argument
self.has_allow_shlib_undefined = ('unknown argument: --allow-shlib-undefined' not in e) and ("unknown argument: '--allow-shlib-undefined'" not in e)
self.has_allow_shlib_undefined = self._supports_flag('--allow-shlib-undefined', always_args)
# These aren't supported by TI Arm Clang
self.has_as_needed = self._supports_flag('--as-needed', always_args)
self.has_no_undefined = self._supports_flag('--no-undefined', always_args)

def _supports_flag(self, flag: str, always_args: T.List[str]) -> bool:
_, _, e = mesonlib.Popen_safe(self.exelist + always_args + self._apply_prefix(flag))
return (
# Versions < 9 do not have a quoted argument
(f'unknown argument: {flag}' not in e) and
(f"unknown argument: '{flag}'" not in e) and
# TI Arm Clang uses a different message
(f'invalid option: {flag}' not in e)
)

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

def get_asneeded_args(self) -> T.List[str]:
if self.has_as_needed:
return self._apply_prefix('--as-needed')
return []

def no_undefined_args(self) -> T.List[str]:
if self.has_no_undefined:
return self._apply_prefix('--no-undefined')
return []

def get_thinlto_cache_args(self, path: str) -> T.List[str]:
return ['-Wl,--thinlto-cache-dir=' + path]

Expand Down

0 comments on commit 04604b3

Please sign in to comment.