From 39ca178d21a72a8f7560b657b517fb73f81b4a89 Mon Sep 17 00:00:00 2001 From: Andrew Udvare Date: Thu, 23 Apr 2020 12:06:08 -0400 Subject: compilers: fix type issue mesonlib.darwin_get_object_archs() only accepts a string argument so convert it. --- mesonbuild/compilers/mixins/clike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 24f4796..124c49c 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -919,7 +919,7 @@ class CLikeCompiler: for f in files: if not f.is_file(): continue - archs = mesonlib.darwin_get_object_archs(f) + archs = mesonlib.darwin_get_object_archs(str(f)) if archs and env.machines.host.cpu_family in archs: return f else: -- cgit v1.1 From d7e20b1543499b516f424ac3a831f402a884714d Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 10 May 2020 23:36:15 +0200 Subject: Fix builtin check in has_function() with GCC 10 on Windows The builtin check had a special case that if a header was provided and the function wasn't defined, it would ignore the builtin to avoid non-functional builtins (for example __builtin_posix_memalign in MSYS2). GCC 10 gained support for __has_builtin() which now skipps this check and because __has_builtin(__builtin_posix_memalign) returns true the non functional builtin is now reported as available. To get the old behaviour back move the special case in front of the actual availability check. Fixes #7113 --- mesonbuild/compilers/mixins/clike.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 124c49c..df97598 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -727,24 +727,29 @@ class CLikeCompiler: # need to look for them differently. On nice compilers like clang, we # can just directly use the __has_builtin() macro. fargs['no_includes'] = '#include' not in prefix - fargs['__builtin_'] = '' if funcname.startswith('__builtin_') else '__builtin_' + is_builtin = funcname.startswith('__builtin_') + fargs['is_builtin'] = is_builtin + fargs['__builtin_'] = '' if is_builtin else '__builtin_' t = '''{prefix} int main(void) {{ + + /* With some toolchains (MSYS2/mingw for example) the compiler + * provides various builtins which are not really implemented and + * fall back to the stdlib where they aren't provided and fail at + * build/link time. In case the user provides a header, including + * the header didn't lead to the function being defined, and the + * function we are checking isn't a builtin itself we assume the + * builtin is not functional and we just error out. */ + #if !{no_includes:d} && !defined({func}) && !{is_builtin:d} + #error "No definition for {__builtin_}{func} found in the prefix" + #endif + #ifdef __has_builtin #if !__has_builtin({__builtin_}{func}) #error "{__builtin_}{func} not found" #endif #elif ! defined({func}) - /* Check for {__builtin_}{func} only if no includes were added to the - * prefix above, which means no definition of {func} can be found. - * We would always check for this, but we get false positives on - * MSYS2 if we do. Their toolchain is broken, but we can at least - * give them a workaround. */ - #if {no_includes:d} - {__builtin_}{func}; - #else - #error "No definition for {__builtin_}{func} found in the prefix" - #endif + {__builtin_}{func}; #endif return 0; }}''' -- cgit v1.1 From c4fa0fac3dd4f4451f73a50c3c523c8f83a3a6e1 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Tue, 12 May 2020 18:55:15 +0200 Subject: Fix has_function() for clang on 64bit Windows has_function() tries to link an example program using the function to see if it is available, but with clang on 64bit Windows this example always already failed at the compile step: error: cast from pointer to smaller type 'long' loses information long b = (long) a; This is due to long!=pointer with LLP64 Change from "long" to "long long" which is min 64bit and should always fit a pointer. While "long long" is strictly a C99 feature every non super ancient compiler should still support it. --- mesonbuild/compilers/mixins/clike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index df97598..0333ffa 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -658,7 +658,7 @@ class CLikeCompiler: # is not run so we don't care what the return value is. main = '''\nint main(void) {{ void *a = (void*) &{func}; - long b = (long) a; + long long b = (long long) a; return (int) b; }}''' return head, main -- cgit v1.1 From 859dc4255aa40611d323d1b22f70bb20c09f317d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 9 Apr 2020 21:09:05 +0000 Subject: Fix outdated cross-compilation checks --- mesonbuild/compilers/mixins/clike.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 0333ffa..e7b0cd2 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -369,7 +369,8 @@ class CLikeCompiler: dependencies=dependencies, mode='link', disable_cache=disable_cache) def run(self, code: str, env, *, extra_args=None, dependencies=None): - if self.is_cross and self.exe_wrapper is None: + need_exe_wrapper = env.need_exe_wrapper(self.for_machine) + if need_exe_wrapper and self.exe_wrapper is None: raise compilers.CrossNoRunException('Can not run test applications in this cross environment.') with self._build_wrapper(code, env, extra_args, dependencies, mode='link', want_output=True) as p: if p.returncode != 0: @@ -377,7 +378,7 @@ class CLikeCompiler: p.input_name, p.returncode)) return compilers.RunResult(False) - if self.is_cross: + if need_exe_wrapper: cmdlist = self.exe_wrapper + [p.output_name] else: cmdlist = p.output_name -- cgit v1.1 From d04e2c2f1fcf35501a1fdc87524b890c5f367995 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 5 May 2020 11:53:42 -0700 Subject: compilers: Move b_ndebug into the compiler classes Right now we hardcode -DNDEBUG as the value to be added for b_ndebug. Which is a not the correct behavior for non C/C++ languages. By pushing this back into the compiler classes we can change this for other languages. --- mesonbuild/compilers/mixins/clike.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index e7b0cd2..01c984d 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1137,3 +1137,6 @@ class CLikeCompiler: return self.compiles(self.attribute_check_func(name), env, extra_args=self.get_has_func_attribute_extra_args(name)) + + def get_disable_assert_args(self) -> T.List[str]: + return ['-DNDEBUG'] -- cgit v1.1 From e2c475939eca7d49b9039be3c0a565c0e38c32ac Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" Date: Wed, 13 May 2020 01:19:11 -0400 Subject: add type anno: compilers/clike --- mesonbuild/compilers/mixins/clike.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 01c984d..0ed0baa 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -254,14 +254,14 @@ class CLikeCompiler: code = 'int main(void) { int class=0; return class; }\n' return self.sanity_check_impl(work_dir, environment, 'sanitycheckc.c', code) - def check_header(self, hname, prefix, env, *, extra_args=None, dependencies=None): + def check_header(self, hname: str, prefix: str, env, *, extra_args=None, dependencies=None): fargs = {'prefix': prefix, 'header': hname} code = '''{prefix} #include <{header}>''' return self.compiles(code.format(**fargs), env, extra_args=extra_args, dependencies=dependencies) - def has_header(self, hname, prefix, env, *, extra_args=None, dependencies=None, disable_cache=False): + def has_header(self, hname: str, prefix: str, env, *, extra_args=None, dependencies=None, disable_cache: bool = False): fargs = {'prefix': prefix, 'header': hname} code = '''{prefix} #ifdef __has_include @@ -274,7 +274,7 @@ class CLikeCompiler: return self.compiles(code.format(**fargs), env, extra_args=extra_args, dependencies=dependencies, mode='preprocess', disable_cache=disable_cache) - def has_header_symbol(self, hname, symbol, prefix, env, *, extra_args=None, dependencies=None): + def has_header_symbol(self, hname: str, symbol: str, prefix: str, env, *, extra_args=None, dependencies=None): fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol} t = '''{prefix} #include <{header}> @@ -288,7 +288,7 @@ class CLikeCompiler: return self.compiles(t.format(**fargs), env, extra_args=extra_args, dependencies=dependencies) - def _get_basic_compiler_args(self, env, mode): + def _get_basic_compiler_args(self, env, mode: str): cargs, largs = [], [] # Select a CRT if needed since we're linking if mode == 'link': @@ -354,11 +354,11 @@ class CLikeCompiler: def compiles(self, code: str, env, *, extra_args: T.Sequence[T.Union[T.Sequence[str], str]] = None, - dependencies=None, mode: str = 'compile', disable_cache=False) -> T.Tuple[bool, bool]: + dependencies=None, mode: str = 'compile', disable_cache: bool = False) -> T.Tuple[bool, bool]: with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p: return p.returncode == 0, p.cached - def _build_wrapper(self, code: str, env, extra_args, dependencies=None, mode: str = 'compile', want_output: bool = False, disable_cache: bool = False, temp_dir=None) -> T.Tuple[bool, bool]: + def _build_wrapper(self, code: str, env, extra_args, dependencies=None, mode: str = 'compile', want_output: bool = False, disable_cache: bool = False, temp_dir: str = None) -> T.Tuple[bool, bool]: args = self._get_compiler_check_args(env, extra_args, dependencies, mode) if disable_cache or want_output: return self.compile(code, extra_args=args, mode=mode, want_output=want_output, temp_dir=env.scratch_dir) @@ -916,21 +916,21 @@ class CLikeCompiler: architecture. ''' # If not building on macOS for Darwin, do a simple file check - files = [Path(f) for f in files] + paths = [Path(f) for f in files] if not env.machines.host.is_darwin() or not env.machines.build.is_darwin(): - for f in files: - if f.is_file(): - return f + for p in paths: + if p.is_file(): + return p # Run `lipo` and check if the library supports the arch we want - for f in files: - if not f.is_file(): + for p in paths: + if not p.is_file(): continue - archs = mesonlib.darwin_get_object_archs(str(f)) + archs = mesonlib.darwin_get_object_archs(str(p)) if archs and env.machines.host.cpu_family in archs: - return f + return p else: mlog.debug('Rejected {}, supports {} but need {}' - .format(f, archs, env.machines.host.cpu_family)) + .format(p, archs, env.machines.host.cpu_family)) return None @functools.lru_cache() -- cgit v1.1 From 5b3bed525d9a0857f57a6e4cc5ad5948fe46d2dd Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Sun, 31 May 2020 23:08:40 -0400 Subject: Ignore file access errors when scanning .so files in system libdirs Bug: https://bugs.gentoo.org/726524 --- mesonbuild/compilers/mixins/clike.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 0ed0baa..56a9ea6 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -152,15 +152,24 @@ class CLikeCompiler: if not files: retval.append(d) continue - file_to_check = os.path.join(d, files[0]) - with open(file_to_check, 'rb') as fd: - header = fd.read(5) - # if file is not an ELF file, it's weird, but accept dir - # if it is elf, and the class matches, accept dir - if header[1:4] != b'ELF' or int(header[4]) == elf_class: - retval.append(d) - # at this point, it's an ELF file which doesn't match the - # appropriate elf_class, so skip this one + + for f in files: + file_to_check = os.path.join(d, f) + try: + with open(file_to_check, 'rb') as fd: + header = fd.read(5) + # if file is not an ELF file, it's weird, but accept dir + # if it is elf, and the class matches, accept dir + if header[1:4] != b'ELF' or int(header[4]) == elf_class: + retval.append(d) + # at this point, it's an ELF file which doesn't match the + # appropriate elf_class, so skip this one + # stop scanning after the first sucessful read + break + except OSError: + # Skip the file if we can't read it + pass + return tuple(retval) @functools.lru_cache() -- cgit v1.1 From fd0ad977a6983a01415f103a2e3dfe53b22cb5a3 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 7 Jun 2020 20:12:17 +0300 Subject: End test code with a newline. Closes #7247. --- mesonbuild/compilers/mixins/clike.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 56a9ea6..1bbe698 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1008,7 +1008,7 @@ class CLikeCompiler: return value[:] def find_library(self, libname, env, extra_dirs, libtype: LibType = LibType.PREFER_SHARED): - code = 'int main(void) { return 0; }' + code = 'int main(void) { return 0; }\n' return self.find_library_impl(libname, env, extra_dirs, code, libtype) def find_framework_paths(self, env): @@ -1117,7 +1117,7 @@ class CLikeCompiler: # false positive. args = self.linker.fatal_warnings() + args args = self.linker_to_compiler_args(args) - code = 'int main(void) { return 0; }' + code = 'int main(void) { return 0; }\n' return self.has_arguments(args, env, code, mode='link') @staticmethod -- cgit v1.1 From 86df85d511c8a6c92da248372b47522d0a7e1aec Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 7 Jun 2020 20:27:18 +0300 Subject: Remove warnings from sample code. Closes #7248. --- mesonbuild/compilers/mixins/clike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 1bbe698..b088fde 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -1108,7 +1108,7 @@ class CLikeCompiler: 'the compiler you are using. has_link_argument or ' 'other similar method can be used instead.' .format(arg)) - code = 'int i;\n' + code = 'extern int i;\nint i;\n' return self.has_arguments(args, env, code, mode='compile') def has_multi_link_arguments(self, args, env): -- cgit v1.1 From 9d0ad66c29fccd2ff72c2b40da02cdb2b03ccba6 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 11 Jun 2020 12:06:29 -0700 Subject: compilers: Split CompilerArgs into a separate module I've also moved this out of the compilers pacakge because we're soon going to need it in linkers, and that creates some serious spagetti --- mesonbuild/compilers/mixins/clike.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index b088fde..b32ac29 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -29,9 +29,10 @@ import subprocess import typing as T from pathlib import Path +from ... import arglist from ... import mesonlib -from ...mesonlib import LibType from ... import mlog +from ...mesonlib import LibType from .. import compilers from .visualstudio import VisualStudioLikeCompiler @@ -48,7 +49,7 @@ class CLikeCompiler: program_dirs_cache = {} find_library_cache = {} find_framework_cache = {} - internal_libs = compilers.unixy_compiler_internal_libs + internal_libs = arglist.UNIXY_COMPILER_INTERNAL_LIBS def __init__(self, is_cross: bool, exe_wrapper: T.Optional[str] = None): # If a child ObjC or CPP class has already set it, don't set it ourselves @@ -338,7 +339,7 @@ class CLikeCompiler: elif not isinstance(dependencies, list): dependencies = [dependencies] # Collect compiler arguments - cargs = compilers.CompilerArgs(self) + cargs = arglist.CompilerArgs(self) largs = [] for d in dependencies: # Add compile flags needed by dependencies -- cgit v1.1 From 93c3ec7e2dd6d425baff5fd80e5a46c88d152cb0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 11 Jun 2020 12:44:53 -0700 Subject: compilers: Return CompilerArgs from compiler instance Since the CompileArgs class already needs to know about the compiler, and we really need at least per-lanaguage if not per-compiler CompilerArgs classes, let's get the CompilerArgs instance from the compiler using a method. --- mesonbuild/compilers/mixins/clike.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index b32ac29..455fbe2 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -32,6 +32,7 @@ from pathlib import Path from ... import arglist from ... import mesonlib from ... import mlog +from ...arglist import CompilerArgs from ...mesonlib import LibType from .. import compilers from .visualstudio import VisualStudioLikeCompiler @@ -40,6 +41,18 @@ if T.TYPE_CHECKING: from ...environment import Environment +class CLikeCompilerArgs(CompilerArgs): + prepend_prefixes = ('-I', '-L') + dedup2_prefixes = ('-I', '-isystem', '-L', '-D', '-U') + + # NOTE: not thorough. A list of potential corner cases can be found in + # https://github.com/mesonbuild/meson/pull/4593#pullrequestreview-182016038 + dedup1_prefixes = ('-l', '-Wl,-l', '-Wl,--export-dynamic') + dedup1_suffixes = ('.lib', '.dll', '.so', '.dylib', '.a') + + dedup1_args = ('-c', '-S', '-E', '-pipe', '-pthread') + + class CLikeCompiler: """Shared bits for the C and CPP Compilers.""" @@ -62,6 +75,9 @@ class CLikeCompiler: else: self.exe_wrapper = exe_wrapper.get_command() + def compiler_args(self, args: T.Optional[T.Iterable[str]] = None) -> CLikeCompilerArgs: + return CLikeCompilerArgs(self, args) + def needs_static_linker(self): return True # When compiling static libraries, so yes. @@ -339,7 +355,7 @@ class CLikeCompiler: elif not isinstance(dependencies, list): dependencies = [dependencies] # Collect compiler arguments - cargs = arglist.CompilerArgs(self) + cargs = self.compiler_args() largs = [] for d in dependencies: # Add compile flags needed by dependencies -- cgit v1.1 From 4f6bd29ac9c697e042a2a808344f1db3efd1d6cb Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 11 Jun 2020 14:05:14 -0700 Subject: arglist: Split the C/C++ specifics parts into a subclass for CLike This means that we don't need work arounds for D-like compilers, as the special c-like hanlding wont be used for D compilers. --- mesonbuild/compilers/mixins/clike.py | 56 ++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 455fbe2..47e97d2 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -32,7 +32,7 @@ from pathlib import Path from ... import arglist from ... import mesonlib from ... import mlog -from ...arglist import CompilerArgs +from ...linkers import GnuLikeDynamicLinkerMixin, SolarisDynamicLinker from ...mesonlib import LibType from .. import compilers from .visualstudio import VisualStudioLikeCompiler @@ -40,8 +40,9 @@ from .visualstudio import VisualStudioLikeCompiler if T.TYPE_CHECKING: from ...environment import Environment +SOREGEX = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$') -class CLikeCompilerArgs(CompilerArgs): +class CLikeCompilerArgs(arglist.CompilerArgs): prepend_prefixes = ('-I', '-L') dedup2_prefixes = ('-I', '-isystem', '-L', '-D', '-U') @@ -49,9 +50,58 @@ class CLikeCompilerArgs(CompilerArgs): # https://github.com/mesonbuild/meson/pull/4593#pullrequestreview-182016038 dedup1_prefixes = ('-l', '-Wl,-l', '-Wl,--export-dynamic') dedup1_suffixes = ('.lib', '.dll', '.so', '.dylib', '.a') - dedup1_args = ('-c', '-S', '-E', '-pipe', '-pthread') + def to_native(self, copy: bool = False) -> T.List[str]: + # 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. + self.flush_pre_post() + if copy: + new = self.copy() + else: + new = self + # This covers all ld.bfd, ld.gold, ld.gold, and xild on Linux, which + # all act like (or are) gnu ld + # TODO: this could probably be added to the DynamicLinker instead + if isinstance(self.compiler.linker, (GnuLikeDynamicLinkerMixin, SolarisDynamicLinker)): + group_start = -1 + group_end = -1 + for i, each in enumerate(new): + if not each.startswith(('-Wl,-l', '-l')) and not each.endswith('.a') and \ + not SOREGEX.match(each): + continue + group_end = i + if group_start < 0: + # First occurrence of a library + group_start = i + if group_start >= 0: + # Last occurrence of a library + new.insert(group_end + 1, '-Wl,--end-group') + new.insert(group_start, '-Wl,--start-group') + # Remove system/default include paths added with -isystem + if hasattr(self.compiler, 'get_default_include_dirs'): + default_dirs = self.compiler.get_default_include_dirs() + bad_idx_list = [] # type: T.List[int] + for i, each in enumerate(new): + # Remove the -isystem and the path if the path is a default path + if (each == '-isystem' and + i < (len(new) - 1) and + new[i + 1] in default_dirs): + bad_idx_list += [i, i + 1] + elif each.startswith('-isystem=') and each[9:] in default_dirs: + bad_idx_list += [i] + elif each.startswith('-isystem') and each[8:] in default_dirs: + bad_idx_list += [i] + for i in reversed(bad_idx_list): + new.pop(i) + return self.compiler.unix_args_to_native(new._container) + + def __repr__(self) -> str: + self.flush_pre_post() + return 'CLikeCompilerArgs({!r}, {!r})'.format(self.compiler, self._container) + class CLikeCompiler: -- cgit v1.1 From 21da2c90408746b8151a5e414930d6c637c78a57 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sat, 11 Jul 2020 23:51:56 +0530 Subject: Fix native builds on Windows ARM64 machines I made the mistake of always selecting the debug CRT for compiler checks on Windows 4 years ago: https://github.com/mesonbuild/meson/pull/543 https://github.com/mesonbuild/meson/pull/614 The idea was to always build the tests with debugging enabled so that the compiler doesn't optimize the tests away. But we stopped doing that a while ago, and also the debug CRT has no relation to that. We should select the CRT in the same way that we do for building targets: based on the options. On Windows ARM64, the debug CRT for ARM64 isn't always available, and the release CRT is available only after installing the runtime package. Without this, we will always try to pick the debug CRT even when --buildtype=debugoptimized or release. --- mesonbuild/compilers/mixins/clike.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/mixins/clike.py') diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index 47e97d2..95b9592 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -366,9 +366,17 @@ class CLikeCompiler: def _get_basic_compiler_args(self, env, mode: str): cargs, largs = [], [] - # Select a CRT if needed since we're linking if mode == 'link': - cargs += self.get_linker_debug_crt_args() + # Sometimes we need to manually select the CRT to use with MSVC. + # One example is when trying to do a compiler check that involves + # linking with static libraries since MSVC won't select a CRT for + # us in that case and will error out asking us to pick one. + try: + crt_val = env.coredata.base_options['b_vscrt'].value + buildtype = env.coredata.base_options['buildtype'].value + cargs += self.get_crt_compile_args(crt_val, buildtype) + except (KeyError, AttributeError): + pass # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS and CPPFLAGS from the env sys_args = env.coredata.get_external_args(self.for_machine, self.language) -- cgit v1.1