diff options
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 24 | ||||
-rw-r--r-- | mesonbuild/compilers/c.py | 47 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/fortran.py | 3 | ||||
-rw-r--r-- | mesonbuild/compilers/objc.py | 2 | ||||
-rw-r--r-- | mesonbuild/compilers/objcpp.py | 5 | ||||
-rw-r--r-- | mesonbuild/compilers/swift.py | 3 | ||||
-rw-r--r-- | mesonbuild/compilers/vala.py | 7 |
8 files changed, 30 insertions, 69 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 1df5f81..b005b77 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -350,11 +350,6 @@ int dummy; if isinstance(parameters, CompilerArgs): parameters = parameters.to_native(copy=True) parameters = comp.compute_parameters_with_absolute_paths(parameters, self.build_dir) - if target.is_cross: - extra_parameters = comp.get_cross_extra_flags(self.environment, False) - if isinstance(parameters, CompilerArgs): - extra_parameters = extra_parameters.to_native(copy=True) - parameters = extra_parameters + parameters # The new entry src_block = { 'language': lang, @@ -1597,12 +1592,11 @@ rule FORTRAN_DEP_HACK%s if compiler.can_linker_accept_rsp(): command_template = ' command = {executable} @$out.rsp\n' \ ' rspfile = $out.rsp\n' \ - ' rspfile_content = $ARGS {cross_args} {output_args} {compile_only_args} $in\n' + ' rspfile_content = $ARGS {output_args} {compile_only_args} $in\n' else: - command_template = ' command = {executable} $ARGS {cross_args} {output_args} {compile_only_args} $in\n' + command_template = ' command = {executable} $ARGS {output_args} {compile_only_args} $in\n' command = command_template.format( executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]), - cross_args=' '.join([quote_func(i) for i in compiler.get_cross_extra_flags(self.environment, False)]) if is_cross else '', output_args=' '.join(compiler.get_output_args('$out')), compile_only_args=' '.join(compiler.get_compile_only_args()) ) @@ -1647,20 +1641,15 @@ rule FORTRAN_DEP_HACK%s d = quote_func(d) quoted_depargs.append(d) - if is_cross: - cross_args = compiler.get_cross_extra_flags(self.environment, False) - else: - cross_args = '' if compiler.can_linker_accept_rsp(): command_template = ''' command = {executable} @$out.rsp rspfile = $out.rsp - rspfile_content = $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in + rspfile_content = $ARGS {dep_args} {output_args} {compile_only_args} $in ''' else: - command_template = ' command = {executable} $ARGS {cross_args} {dep_args} {output_args} {compile_only_args} $in\n' + command_template = ' command = {executable} $ARGS {dep_args} {output_args} {compile_only_args} $in\n' command = command_template.format( executable=' '.join([ninja_quote(i) for i in compiler.get_exelist()]), - cross_args=' '.join([quote_func(i) for i in cross_args]), dep_args=' '.join(quoted_depargs), output_args=' '.join(compiler.get_output_args('$out')), compile_only_args=' '.join(compiler.get_compile_only_args()) @@ -1687,11 +1676,6 @@ rule FORTRAN_DEP_HACK%s rule = 'rule %s%s_PCH\n' % (langname, crstr) depargs = compiler.get_dependency_gen_args('$out', '$DEPFILE') cross_args = [] - if is_cross: - try: - cross_args = compiler.get_cross_extra_flags(self.environment, False) - except KeyError: - pass quoted_depargs = [] for d in depargs: diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index b47be7d..a1a8fb9 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -321,10 +321,7 @@ class CCompiler(Compiler): # on OSX the compiler binary is the same but you need # a ton of compiler flags to differentiate between # arm and x86_64. So just compile. - extra_flags += self.get_cross_extra_flags(environment, link=False) extra_flags += self.get_compile_only_args() - else: - extra_flags += self.get_cross_extra_flags(environment, link=True) # Is a valid executable output for all toolchains and platforms binname += '.exe' # Write binary check source @@ -424,28 +421,25 @@ class CCompiler(Compiler): # Select a CRT if needed since we're linking if mode == 'link': args += self.get_linker_debug_crt_args() - # Read c_args/cpp_args/etc from the cross-info file (if needed) - args += self.get_cross_extra_flags(env, link=(mode == 'link')) - if not self.is_cross: - if env.is_cross_build() and not self.is_cross: - for_machine = MachineChoice.BUILD - else: - for_machine = MachineChoice.HOST - if mode == 'preprocess': - # Add CPPFLAGS from the env. - args += env.coredata.get_external_preprocess_args(for_machine, self.language) - elif mode == 'compile': - # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env - sys_args = env.coredata.get_external_args(for_machine, self.language) - # Apparently it is a thing to inject linker flags both - # via CFLAGS _and_ LDFLAGS, even though the former are - # also used during linking. These flags can break - # argument checks. Thanks, Autotools. - cleaned_sys_args = self.remove_linkerlike_args(sys_args) - args += cleaned_sys_args - elif mode == 'link': - # Add LDFLAGS from the env - args += env.coredata.get_external_link_args(for_machine, self.language) + if env.is_cross_build() and not self.is_cross: + for_machine = MachineChoice.BUILD + else: + for_machine = MachineChoice.HOST + if mode == 'preprocess': + # Add CPPFLAGS from the env. + args += env.coredata.get_external_preprocess_args(for_machine, self.language) + elif mode == 'compile': + # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env + sys_args = env.coredata.get_external_args(for_machine, self.language) + # Apparently it is a thing to inject linker flags both + # via CFLAGS _and_ LDFLAGS, even though the former are + # also used during linking. These flags can break + # argument checks. Thanks, Autotools. + cleaned_sys_args = self.remove_linkerlike_args(sys_args) + args += cleaned_sys_args + elif mode == 'link': + # Add LDFLAGS from the env + args += env.coredata.get_external_link_args(for_machine, self.language) args += self.get_compiler_check_args() # extra_args must override all other arguments, so we add them last args += extra_args @@ -875,8 +869,7 @@ class CCompiler(Compiler): } #endif ''' - args = self.get_cross_extra_flags(env, link=False) - args += self.get_compiler_check_args() + args = self.get_compiler_check_args() n = 'symbols_have_underscore_prefix' with self.compile(code, args, 'compile', want_output=True) as p: if p.returncode != 0: diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 64249fb..65df0e7 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1084,14 +1084,6 @@ class Compiler: 'Language {} does not support has_multi_link_arguments.'.format( self.get_display_language())) - def get_cross_extra_flags(self, environment, link): - extra_flags = [] - if self.is_cross and environment: - extra_flags += environment.coredata.get_external_args(MachineChoice.HOST, self.language) - if link: - extra_flags += environment.coredata.get_external_link_args(MachineChoice.HOST, self.language) - return extra_flags - def _get_compile_output(self, dirname, mode): # In pre-processor mode, the output is sent to stdout and discarded if mode == 'preprocess': diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 1290c07..59c4214 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -78,8 +78,7 @@ class FortranCompiler(Compiler): binary_name = os.path.join(work_dir, 'sanitycheckf') with open(source_name, 'w') as ofile: ofile.write('print *, "Fortran compilation is working."; end') - extra_flags = self.get_cross_extra_flags(environment, link=True) - pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name]) + pc = subprocess.Popen(self.exelist + [source_name, '-o', binary_name]) pc.wait() if pc.returncode != 0: raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string()) diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index 5b2b517..cf58ffb 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -31,7 +31,7 @@ class ObjCCompiler(CCompiler): # TODO try to use sanity_check_impl instead of duplicated code source_name = os.path.join(work_dir, 'sanitycheckobjc.m') binary_name = os.path.join(work_dir, 'sanitycheckobjc') - extra_flags = self.get_cross_extra_flags(environment, link=False) + extra_flags = [] if self.is_cross: extra_flags += self.get_compile_only_args() with open(source_name, 'w') as ofile: diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index e1b7a7d..add888f 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -31,14 +31,11 @@ class ObjCPPCompiler(CPPCompiler): # TODO try to use sanity_check_impl instead of duplicated code source_name = os.path.join(work_dir, 'sanitycheckobjcpp.mm') binary_name = os.path.join(work_dir, 'sanitycheckobjcpp') - extra_flags = self.get_cross_extra_flags(environment, link=False) - if self.is_cross: - extra_flags += self.get_compile_only_args() with open(source_name, 'w') as ofile: ofile.write('#import<stdio.h>\n' 'class MyClass;' 'int main(int argc, char **argv) { return 0; }\n') - pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name]) + pc = subprocess.Popen(self.exelist + [source_name, '-o', binary_name]) pc.wait() if pc.returncode != 0: raise EnvironmentException('ObjC++ compiler %s can not compile programs.' % self.name_string()) diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index eb58d11..94e6736 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -105,8 +105,7 @@ class SwiftCompiler(Compiler): with open(source_name, 'w') as ofile: ofile.write('''print("Swift compilation is working.") ''') - extra_flags = self.get_cross_extra_flags(environment, link=True) - pc = subprocess.Popen(self.exelist + extra_flags + ['-emit-executable', '-o', output_name, src], cwd=work_dir) + pc = subprocess.Popen(self.exelist + ['-emit-executable', '-o', output_name, src], cwd=work_dir) pc.wait() if pc.returncode != 0: raise EnvironmentException('Swift compiler %s can not compile programs.' % self.name_string()) diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py index 5303298..1ee46fe 100644 --- a/mesonbuild/compilers/vala.py +++ b/mesonbuild/compilers/vala.py @@ -87,8 +87,7 @@ class ValaCompiler(Compiler): def sanity_check(self, work_dir, environment): code = 'class MesonSanityCheck : Object { }' - args = self.get_cross_extra_flags(environment, link=False) - with self.compile(code, args, 'compile') as p: + with self.compile(code, [], 'compile') as p: if p.returncode != 0: msg = 'Vala compiler {!r} can not compile programs' \ ''.format(self.name_string()) @@ -107,9 +106,7 @@ class ValaCompiler(Compiler): if not extra_dirs: code = 'class MesonFindLibrary : Object { }' vapi_args = ['--pkg', libname] - args = self.get_cross_extra_flags(env, link=False) - args += vapi_args - with self.compile(code, args, 'compile') as p: + with self.compile(code, vapi_args, 'compile') as p: if p.returncode == 0: return vapi_args # Not found? Try to find the vapi file itself. |