From a06178f58fa91293d59a63313a733ac1bb043854 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Tue, 25 Oct 2016 05:07:58 +0530 Subject: [PATCH] Add -Wl,-no_weak_imports to has_function with XCode 8 This is needed to ensure that symbol availability checks actually fail at link time (instead of at runtime) which is necessary for has_function to work correctly. --- mesonbuild/compilers.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 03fb4f240..7e736365d 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -17,7 +17,7 @@ import subprocess, os.path import tempfile from .import mesonlib from . import mlog -from .mesonlib import MesonException +from .mesonlib import MesonException, version_compare from . import coredata """This file contains the data files of all compilers Meson knows @@ -2103,6 +2103,17 @@ class ClangCompiler(): def has_argument(self, arg, env): return super().has_argument(['-Werror=unknown-warning-option', arg], env) + def has_function(self, funcname, prefix, env, extra_args=None, dependencies=None): + if extra_args is None: + extra_args = [] + # Starting with XCode 8, we need to pass this to force linker + # visibility to obey OS X and iOS minimum version targets with + # -mmacosx-version-min, -miphoneos-version-min, etc. + # https://github.com/Homebrew/homebrew-core/issues/3727 + if self.clang_type == CLANG_OSX and version_compare(self.version, '>=8.0'): + extra_args.append('-Wl,-no_weak_imports') + return super().has_function(funcname, prefix, env, extra_args, dependencies) + class ClangCCompiler(ClangCompiler, CCompiler): def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper)