From bb31a8c1c752cff6f969e345f3a170f935f159cf Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Fri, 21 Sep 2018 17:38:46 +0100 Subject: Only add link arguments when needed in Compiler object methods Currently, ComplierHolder.determine_args() unconditionally adds the link arguments to the commmand, even if we aren't linking, because it doesn't have access to the mode (preprocess, compile, link) that _get_compiler_check_args() will use. This leads to command lines like: 'cl testfile.c /nologo /showIncludes /c /Fooutput.obj /Od kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib' which clang-cl considers invalid; MSVS cl accepts this, ignoring the unneeded libraries Change from passing extra_args down to _get_compiler_check_args(), to passing down a callback to CompilerHolder.determine_args() (with a bound kwargs argument), so it can consult mode and kwargs to determine the args to use. --- mesonbuild/compilers/d.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mesonbuild/compilers/d.py') diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 099d907..0a59e7f 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -274,6 +274,8 @@ class DCompiler(Compiler): return ['-Wl,-rpath,{}'.format(paths)] def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'): + if callable(extra_args): + extra_args = extra_args(mode) if extra_args is None: extra_args = [] elif isinstance(extra_args, str): -- cgit v1.1