diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index f7ba6468a..0f738f7ff 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1871,7 +1871,7 @@ class NinjaBackend(backends.Backend): base_proxy = target.get_options() args = rustc.compiler_args() # Compiler args for compiling this target - args += compilers.get_base_compile_args(base_proxy, rustc) + args += compilers.get_base_compile_args(base_proxy, rustc, self.environment) self.generate_generator_list_rules(target) # dependencies need to cause a relink, they're not just for ordering @@ -2757,7 +2757,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) compiler = get_compiler_for_source(target.compilers.values(), src) commands = compiler.compiler_args() # Compiler args for compiling this target - commands += compilers.get_base_compile_args(base_proxy, compiler) + commands += compilers.get_base_compile_args(base_proxy, compiler, self.environment) if isinstance(src, File): if src.is_built: src_filename = os.path.join(src.subdir, src.fname) @@ -2822,7 +2822,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485''')) # options passed on the command-line, in default_options, etc. # These have the lowest priority. commands += compilers.get_base_compile_args(base_proxy, - compiler) + compiler, self.environment) return commands @lru_cache(maxsize=None) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index c7b5bb53a..a2ece96a3 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -984,7 +984,7 @@ class Vs2010Backend(backends.Backend): for l, comp in target.compilers.items(): if l in file_args: file_args[l] += compilers.get_base_compile_args( - target.get_options(), comp) + target.get_options(), comp, self.environment) file_args[l] += comp.get_option_compile_args( target.get_options()) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 5854c9e60..58941b70d 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -283,7 +283,7 @@ def are_asserts_disabled(options: KeyedOptionDictType) -> bool: options[OptionKey('buildtype')].value in {'release', 'plain'})) -def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler') -> T.List[str]: +def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler', env: 'Environment') -> T.List[str]: args: T.List[str] = [] try: if options[OptionKey('b_lto')].value: @@ -314,7 +314,7 @@ def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler') except KeyError: pass try: - args += compiler.get_assert_args(are_asserts_disabled(options)) + args += compiler.get_assert_args(are_asserts_disabled(options), env) except KeyError: pass # This does not need a try...except @@ -1060,7 +1060,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def get_coverage_link_args(self) -> T.List[str]: return self.linker.get_coverage_args() - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: """Get arguments to enable or disable assertion. :param disable: Whether to disable assertions diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 2a2f7615d..c26def9fc 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -307,7 +307,7 @@ class ClangCPPCompiler(_StdCPPLibMixin, ClangCompiler, CPPCompiler): return libs return [] - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: args: T.List[str] = [] if disable: return ['-DNDEBUG'] @@ -502,7 +502,7 @@ class GnuCPPCompiler(_StdCPPLibMixin, GnuCompiler, CPPCompiler): return libs return [] - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: if disable: return ['-DNDEBUG'] diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index ab4810798..7f7ad7495 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -802,5 +802,5 @@ class CudaCompiler(Compiler): def get_profile_use_args(self) -> T.List[str]: return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_use_args()] - def get_assert_args(self, disable: bool) -> T.List[str]: - return self.host_compiler.get_assert_args(disable) + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: + return self.host_compiler.get_assert_args(disable, env) diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 78ce2bc23..de344c057 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -696,7 +696,7 @@ class GnuDCompiler(GnuCompiler, DCompiler): return args return args + ['-shared-libphobos'] - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: if disable: return ['-frelease'] return [] @@ -766,7 +766,7 @@ class LLVMDCompiler(DmdLikeCompilerMixin, DCompiler): return args return args + ['-link-defaultlib-shared'] - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: if disable: return ['--release'] return [] @@ -852,7 +852,7 @@ class DmdDCompiler(DmdLikeCompilerMixin, DCompiler): return args return args + ['-defaultlib=phobos2', '-debuglib=phobos2'] - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: if disable: return ['-release'] return [] diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 09bd43881..b58b163a6 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1309,7 +1309,7 @@ class CLikeCompiler(Compiler): return self.compiles(self.attribute_check_func(name), env, extra_args=self.get_has_func_attribute_extra_args(name)) - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: if disable: return ['-DNDEBUG'] return [] diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 05e8b2b27..0dc65bf33 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -215,7 +215,7 @@ class RustCompiler(Compiler): # pic is on by rustc return [] - def get_assert_args(self, disable: bool) -> T.List[str]: + def get_assert_args(self, disable: bool, env: 'Environment') -> T.List[str]: action = "no" if disable else "yes" return ['-C', f'debug-assertions={action}', '-C', 'overflow-checks=no']