summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py51
1 files changed, 30 insertions, 21 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 47c222d56..352c49ee8 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -145,8 +145,8 @@ arm_buildtype_args = {'plain': [],
msvc_buildtype_args = {'plain': [],
'debug': ["/ZI", "/Ob0", "/Od", "/RTC1"],
'debugoptimized': ["/Zi", "/Ob1"],
- 'release': ["/Ob2"],
- 'minsize': ["/Zi", "/Ob1"],
+ 'release': ["/Ob2", "/Gw"],
+ 'minsize': ["/Zi", "/Gw"],
}
apple_buildtype_linker_args = {'plain': [],
@@ -267,7 +267,7 @@ msvc_optimization_args = {'0': [],
'1': ['/O1'],
'2': ['/O2'],
'3': ['/O3'],
- 's': ['/Os'],
+ 's': ['/O1'], # Implies /Os.
}
clike_debug_args = {False: [],
@@ -611,27 +611,32 @@ class CompilerArgs(list):
return True
return False
- def to_native(self):
+ def to_native(self, copy=False):
# Check if we need to add --start/end-group for circular dependencies
# between static libraries, and for recursively searching for symbols
# needed by static libraries that are provided by object files or
# shared libraries.
+ if copy:
+ new = self.copy()
+ else:
+ new = self
if get_compiler_uses_gnuld(self.compiler):
global soregex
group_start = -1
- for each in self:
+ group_end = -1
+ for i, each in enumerate(new):
if not each.startswith('-l') and not each.endswith('.a') and \
not soregex.match(each):
continue
- i = self.index(each)
+ group_end = i
if group_start < 0:
# First occurrence of a library
group_start = i
if group_start >= 0:
# Last occurrence of a library
- self.insert(i + 1, '-Wl,--end-group')
- self.insert(group_start, '-Wl,--start-group')
- return self.compiler.unix_args_to_native(self)
+ new.insert(group_end + 1, '-Wl,--end-group')
+ new.insert(group_start, '-Wl,--start-group')
+ return self.compiler.unix_args_to_native(new)
def append_direct(self, arg):
'''
@@ -867,11 +872,11 @@ class Compiler:
self.language + '_args': coredata.UserArrayOption(
self.language + '_args',
description + ' compiler',
- compile_args, shlex_split=True, user_input=True),
+ compile_args, shlex_split=True, user_input=True, allow_dups=True),
self.language + '_link_args': coredata.UserArrayOption(
self.language + '_link_args',
description + ' linker',
- link_args, shlex_split=True, user_input=True),
+ link_args, shlex_split=True, user_input=True, allow_dups=True),
})
return opts
@@ -917,7 +922,7 @@ class Compiler:
def find_library(self, *args, **kwargs):
raise EnvironmentException('Language {} does not support library finding.'.format(self.get_display_language()))
- def get_library_dirs(self):
+ def get_library_dirs(self, *args, **kwargs):
return []
def has_multi_arguments(self, args, env):
@@ -1004,7 +1009,9 @@ class Compiler:
mlog.debug('Working directory: ', tmpdirname)
mlog.debug('Command line: ', ' '.join(commands), '\n')
mlog.debug('Code:\n', code)
- p, p.stdo, p.stde = Popen_safe(commands, cwd=tmpdirname)
+ os_env = os.environ.copy()
+ os_env['LC_ALL'] = 'C'
+ p, p.stdo, p.stde = Popen_safe(commands, cwd=tmpdirname, env=os_env)
mlog.debug('Compiler stdout:\n', p.stdo)
mlog.debug('Compiler stderr:\n', p.stde)
p.commands = commands
@@ -1362,10 +1369,12 @@ class ElbrusCompiler(GnuCompiler):
'b_ndebug', 'b_staticpic',
'b_lundef', 'b_asneeded']
- def get_library_dirs(self):
- env = os.environ.copy()
- env['LC_ALL'] = 'C'
- stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=env)[1]
+ # FIXME: use _build_wrapper to call this so that linker flags from the env
+ # get applied
+ def get_library_dirs(self, env):
+ os_env = os.environ.copy()
+ os_env['LC_ALL'] = 'C'
+ stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1]
paths = []
for line in stdo.split('\n'):
if line.startswith('libraries:'):
@@ -1375,10 +1384,10 @@ class ElbrusCompiler(GnuCompiler):
break
return paths
- def get_program_dirs(self):
- env = os.environ.copy()
- env['LC_ALL'] = 'C'
- stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=env)[1]
+ def get_program_dirs(self, env):
+ os_env = os.environ.copy()
+ os_env['LC_ALL'] = 'C'
+ stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1]
paths = []
for line in stdo.split('\n'):
if line.startswith('programs:'):