Skip to content

Commit

Permalink
Compilers: pass -Werror to the linker with b_lto
Browse files Browse the repository at this point in the history
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: mesonbuild#7360
Signed-off-by: Sam James <sam@gentoo.org>
  • Loading branch information
thesamesam committed Jan 18, 2024
1 parent 92f638e commit a29600d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'), '')
Expand Down

0 comments on commit a29600d

Please sign in to comment.