@@ -305,7 +305,14 @@ def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler',
305
305
except (KeyError , AttributeError ):
306
306
pass
307
307
try :
308
- args += compiler .sanitizer_compile_args (options .get_value (OptionKey ('b_sanitize' )))
308
+ sani_opt = options .get_value (OptionKey ('b_sanitize' ))
309
+ assert isinstance (sani_opt , str ), 'for mypy'
310
+ sani_args = compiler .sanitizer_compile_args (sani_opt )
311
+ # We consider that if there are no sanitizer arguments returned, then the language doesn't support them
312
+ if sani_args :
313
+ if not compiler .has_multi_arguments (sani_args , env )[0 ]:
314
+ raise MesonException (f'Compiler { compiler .name_string ()} does not support sanitizer arguments { sani_args } ' )
315
+ args .extend (sani_args )
309
316
except (KeyError , AttributeError ):
310
317
pass
311
318
try :
@@ -340,7 +347,7 @@ def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler',
340
347
return args
341
348
342
349
def get_base_link_args (options : 'KeyedOptionDictType' , linker : 'Compiler' ,
343
- is_shared_module : bool , build_dir : str ) -> T .List [str ]:
350
+ is_shared_module : bool , env : Environment ) -> T .List [str ]:
344
351
args : T .List [str ] = []
345
352
try :
346
353
if options .get_value ('b_lto' ):
@@ -351,15 +358,21 @@ def get_base_link_args(options: 'KeyedOptionDictType', linker: 'Compiler',
351
358
if get_option_value (options , OptionKey ('b_thinlto_cache' ), False ):
352
359
thinlto_cache_dir = get_option_value (options , OptionKey ('b_thinlto_cache_dir' ), '' )
353
360
if thinlto_cache_dir == '' :
354
- thinlto_cache_dir = os .path .join (build_dir , 'meson-private' , 'thinlto-cache' )
361
+ thinlto_cache_dir = os .path .join (env . get_build_dir () , 'meson-private' , 'thinlto-cache' )
355
362
args .extend (linker .get_lto_link_args (
356
363
threads = get_option_value (options , OptionKey ('b_lto_threads' ), 0 ),
357
364
mode = get_option_value (options , OptionKey ('b_lto_mode' ), 'default' ),
358
365
thinlto_cache_dir = thinlto_cache_dir ))
359
366
except (KeyError , AttributeError ):
360
367
pass
361
368
try :
362
- args += linker .sanitizer_link_args (options .get_value ('b_sanitize' ))
369
+ sani_opt = options .get_value (OptionKey ('b_sanitize' ))
370
+ sani_args = linker .sanitizer_link_args (sani_opt )
371
+ # We consider that if there are no sanitizer arguments returned, then the language doesn't support them
372
+ if sani_args :
373
+ if not linker .has_multi_link_arguments (sani_args , env )[0 ]:
374
+ raise MesonException (f'Linker { linker .name_string ()} does not support sanitizer arguments { sani_args } ' )
375
+ args .extend (sani_args )
363
376
except (KeyError , AttributeError ):
364
377
pass
365
378
try :
0 commit comments