From 6e4caca1dacd62b86967c0aa9f5a64e95f356e39 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 17 Dec 2025 09:56:02 -0800 Subject: interpreter: validate that a target is linkable in link_whole check This catches the addition of un-linkable targets at the interpreter level rather than requiring the build layer to handle this. In turn, this gives the end user a better error message. --- mesonbuild/interpreter/type_checking.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 259b55f75..2d9f2a11e 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -449,10 +449,12 @@ LINK_WITH_KW: KwargInfo[T.List[T.Union[BothLibraries, SharedLibrary, StaticLibra extra_types={Dependency: lambda _: _LINK_WITH_ERROR} ) -def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, CustomTargetIndex, Dependency]]) -> T.Optional[str]: +def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, CustomTargetIndex]]) -> T.Optional[str]: for l in values: if isinstance(l, (CustomTarget, CustomTargetIndex)) and l.links_dynamically(): return f'{type(l).__name__} returning a shared library is not allowed' + if not l.is_linkable_target(): + return f'Link target "{l!s}" is not linkable' return None LINK_WHOLE_KW: KwargInfo[T.List[T.Union[BothLibraries, StaticLibrary, CustomTarget, CustomTargetIndex]]] = KwargInfo( -- cgit v1.2.3