git.iko.soy/typeable/nixpkgs
on master help sign in
meson: Fix linking ObjC objects on Darwin
2f4e167Jan Tojnar
pkgs/development/tools/build-managers/meson/default.nix+7
@@ -44,6 +44,13 @@ python3Packages.buildPythonApplication rec {
44 src = ./fix-rpath.patch;
44 src = ./fix-rpath.patch;
45 inherit (builtins) storeDir;
45 inherit (builtins) storeDir;
46 })
46 })
47+ ] ++ lib.optionals stdenv.isDarwin [
48+ # We use custom Clang, which makes Meson think *not Apple*, while still
49+ # relying on system linker. When it detects standard Clang, Meson will
50+ # pass it `-Wl,-O1` flag but optimizations are not recognized by
51+ # Mac linker.
52+ # https://github.com/mesonbuild/meson/issues/4784
53+ ./fix-objc-linking.patch
47 ];
54 ];
48
55
49 setupHook = ./setup-hook.sh;
56 setupHook = ./setup-hook.sh;
pkgs/development/tools/build-managers/meson/fix-objc-linking.patchnew file+20
@@ -0,0 +1,20 @@
1+--- a/mesonbuild/environment.py
2++++ b/mesonbuild/environment.py
3+@@ -795,7 +795,7 @@
4+ compiler_type = self.get_gnu_compiler_type(defines)
5+ version = self.get_gnu_version_from_defines(defines)
6+ return GnuObjCCompiler(ccache + compiler, version, compiler_type, is_cross, exe_wrap, defines)
7+- if out.startswith('Apple LLVM'):
8++ if out.startswith('Apple LLVM') or mesonlib.for_darwin(want_cross, self):
9+ return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, is_cross, exe_wrap)
10+ if out.startswith('clang'):
11+ return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_STANDARD, is_cross, exe_wrap)
12+@@ -822,7 +822,7 @@
13+ compiler_type = self.get_gnu_compiler_type(defines)
14+ version = self.get_gnu_version_from_defines(defines)
15+ return GnuObjCPPCompiler(ccache + compiler, version, compiler_type, is_cross, exe_wrap, defines)
16+- if out.startswith('Apple LLVM'):
17++ if out.startswith('Apple LLVM') or mesonlib.for_darwin(want_cross, self):
18+ return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, is_cross, exe_wrap)
19+ if out.startswith('clang'):
20+ return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_STANDARD, is_cross, exe_wrap)