aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2019-01-08 21:59:50 -0500
committerDylan Baker <dylan@pnwbakers.com>2019-02-15 09:17:24 -0800
commitd451a4bd97f827bb492fd0c0e357cb20b6056ed9 (patch)
treefa2b4704bb0132e81b2102ced301b5a7ac51c8de /mesonbuild/compilers
parent3e9396f2590372f484149b48bf3f1c108c9111c3 (diff)
downloadmeson-d451a4bd97f827bb492fd0c0e357cb20b6056ed9.zip
meson-d451a4bd97f827bb492fd0c0e357cb20b6056ed9.tar.gz
meson-d451a4bd97f827bb492fd0c0e357cb20b6056ed9.tar.bz2
Remove get_cross_extra_flags
This is no longer needed, we just remove conditionals around it.
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py47
-rw-r--r--mesonbuild/compilers/compilers.py8
-rw-r--r--mesonbuild/compilers/fortran.py3
-rw-r--r--mesonbuild/compilers/objc.py2
-rw-r--r--mesonbuild/compilers/objcpp.py5
-rw-r--r--mesonbuild/compilers/swift.py3
-rw-r--r--mesonbuild/compilers/vala.py7
7 files changed, 26 insertions, 49 deletions
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.