From 2f4e167156b8e9f5852010f63e0a4067c7237d39 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 16 Jan 2019 05:44:58 +0100 Subject: [PATCH] meson: Fix linking ObjC objects on Darwin https://github.com/NixOS/nixpkgs/pull/54007#issuecomment-454693658 --- .../tools/build-managers/meson/default.nix | 7 +++++++ .../meson/fix-objc-linking.patch | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 pkgs/development/tools/build-managers/meson/fix-objc-linking.patch diff --git a/pkgs/development/tools/build-managers/meson/default.nix b/pkgs/development/tools/build-managers/meson/default.nix index 17938ab47b3..96e04407325 100644 --- a/pkgs/development/tools/build-managers/meson/default.nix +++ b/pkgs/development/tools/build-managers/meson/default.nix @@ -44,6 +44,13 @@ python3Packages.buildPythonApplication rec { src = ./fix-rpath.patch; inherit (builtins) storeDir; }) + ] ++ lib.optionals stdenv.isDarwin [ + # We use custom Clang, which makes Meson think *not Apple*, while still + # relying on system linker. When it detects standard Clang, Meson will + # pass it `-Wl,-O1` flag but optimizations are not recognized by + # Mac linker. + # https://github.com/mesonbuild/meson/issues/4784 + ./fix-objc-linking.patch ]; setupHook = ./setup-hook.sh; diff --git a/pkgs/development/tools/build-managers/meson/fix-objc-linking.patch b/pkgs/development/tools/build-managers/meson/fix-objc-linking.patch new file mode 100644 index 00000000000..60a205828f5 --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/fix-objc-linking.patch @@ -0,0 +1,20 @@ +--- a/mesonbuild/environment.py ++++ b/mesonbuild/environment.py +@@ -795,7 +795,7 @@ + compiler_type = self.get_gnu_compiler_type(defines) + version = self.get_gnu_version_from_defines(defines) + return GnuObjCCompiler(ccache + compiler, version, compiler_type, is_cross, exe_wrap, defines) +- if out.startswith('Apple LLVM'): ++ if out.startswith('Apple LLVM') or mesonlib.for_darwin(want_cross, self): + return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, is_cross, exe_wrap) + if out.startswith('clang'): + return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_STANDARD, is_cross, exe_wrap) +@@ -822,7 +822,7 @@ + compiler_type = self.get_gnu_compiler_type(defines) + version = self.get_gnu_version_from_defines(defines) + return GnuObjCPPCompiler(ccache + compiler, version, compiler_type, is_cross, exe_wrap, defines) +- if out.startswith('Apple LLVM'): ++ if out.startswith('Apple LLVM') or mesonlib.for_darwin(want_cross, self): + return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, is_cross, exe_wrap) + if out.startswith('clang'): + return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_STANDARD, is_cross, exe_wrap)