From 85cfc1fafcda047fa497d1d6219a8c742523b5a6 Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 18 Jan 2024 07:03:17 +0000 Subject: [PATCH] Compilers: pass -Werror to the linker with b_lto With LTO, the linker will re-execute the compiler and various warnings may be emitted. We must therefore pass -Werror to the linker as well when -Werror is enabled to capture these. This is only required / useful with LTO. Closes: https://github.com/mesonbuild/meson/issues/7360 Signed-off-by: Sam James Signed-off-by: Eli Schwartz --- mesonbuild/compilers/compilers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index f1a2b7376413..fbe30f6f0b7b 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -324,6 +324,9 @@ def get_base_link_args(options: 'KeyedOptionDictType', linker: 'Compiler', args: T.List[str] = [] try: if options[OptionKey('b_lto')].value: + if options[OptionKey('werror')].value: + args.extend(linker.get_werror_args()) + thinlto_cache_dir = None if get_option_value(options, OptionKey('b_thinlto_cache'), False): thinlto_cache_dir = get_option_value(options, OptionKey('b_thinlto_cache_dir'), '')