From 98b8d3474bffdf42b178fad2bc4f804f1227f118 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 4 Nov 2023 01:43:16 -0400 Subject: [PATCH 1/4] stdenvAdapters.overrideSDK: special case the 10.12 Libsystem The 10.12 Libsystem is not located as a sub-attribute of `darwin.apple_sdk_10_12`. This will be fixed as part of the SDK changes planned for post-23.11. In the meantime, special case it so the adapter can be used to change the deployment target. --- pkgs/stdenv/adapters.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 977ef2eef9c7..a6a2736fec11 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -262,6 +262,9 @@ rec { ) darwinMinVersion darwinSdkVersion; sdk = pkgs.darwin."apple_sdk_${lib.replaceStrings [ "." ] [ "_" ] darwinSdkVersion}"; + # TODO: Make this unconditional after #229210 has been merged, + # and the 10.12 SDK is updated to follow the new structure. + Libsystem = if darwinSdkVersion == "10.12" then pkgs.darwin.Libsystem else sdk.Libsystem; replacePropagatedFrameworks = pkg: let @@ -349,8 +352,8 @@ rec { // lib.genAttrs atBuildInputs (input: map mapRuntimeToSDK (args."${input}" or [ ])); mkCC = cc: cc.override { - bintools = cc.bintools.override { libc = sdk.Libsystem; }; - libc = sdk.Libsystem; + bintools = cc.bintools.override { libc = Libsystem; }; + libc = Libsystem; }; in # TODO: make this work across all input types and not just propagatedBuildInputs From 020240dc47ae198b126b48fce07d9fe36ee5efcd Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 30 Oct 2023 21:53:57 -0400 Subject: [PATCH 2/4] =?UTF-8?q?abseil-cpp:=20don=E2=80=99t=20propagate=20C?= =?UTF-8?q?oreFoundation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit abseil-cpp builds with the default SDK, which can break dependent packages that require a different SDK version to build. Don’t propagate the CoreFoundation framework path and rely on nixpkgs to provide it instead. The line can’t be dropped because otherwise abseil-cpp will fail to build (due to missing symbols). --- pkgs/development/libraries/abseil-cpp/202103.nix | 4 ++++ pkgs/development/libraries/abseil-cpp/202111.nix | 6 ++++++ pkgs/development/libraries/abseil-cpp/202206.nix | 6 ++++++ pkgs/development/libraries/abseil-cpp/202301.nix | 6 ++++++ pkgs/development/libraries/abseil-cpp/202308.nix | 6 ++++++ .../libraries/abseil-cpp/cmake-core-foundation.patch | 12 ++++++++++++ 6 files changed, 40 insertions(+) create mode 100644 pkgs/development/libraries/abseil-cpp/cmake-core-foundation.patch diff --git a/pkgs/development/libraries/abseil-cpp/202103.nix b/pkgs/development/libraries/abseil-cpp/202103.nix index 712f89e383ff..59294496f80a 100644 --- a/pkgs/development/libraries/abseil-cpp/202103.nix +++ b/pkgs/development/libraries/abseil-cpp/202103.nix @@ -39,6 +39,10 @@ stdenv.mkDerivation rec { url = "https://github.com/abseil/abseil-cpp/commit/808bc202fc13e85a7948db0d7fb58f0f051200b1.patch"; sha256 = "sha256-ayY/aV/xWOdEyFSDqV7B5WDGvZ0ASr/aeBeYwP5RZVc="; }) + ] ++ lib.optionals stdenv.isDarwin [ + # Don’t propagate the path to CoreFoundation. Otherwise, it’s impossible to build packages + # that require a different SDK other than the default one. + ./cmake-core-foundation.patch ]; cmakeFlags = [ diff --git a/pkgs/development/libraries/abseil-cpp/202111.nix b/pkgs/development/libraries/abseil-cpp/202111.nix index d40ca0bd4ab2..0c1a173eca44 100644 --- a/pkgs/development/libraries/abseil-cpp/202111.nix +++ b/pkgs/development/libraries/abseil-cpp/202111.nix @@ -18,6 +18,12 @@ stdenv.mkDerivation rec { sha256 = "sha256-sSXT6D4JSrk3dA7kVaxfKkzOMBpqXQb0WbMYWG+nGwk="; }; + patches = lib.optionals stdenv.isDarwin [ + # Don’t propagate the path to CoreFoundation. Otherwise, it’s impossible to build packages + # that require a different SDK other than the default one. + ./cmake-core-foundation.patch + ]; + cmakeFlags = [ "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}" ] ++ lib.optionals (cxxStandard != null) [ diff --git a/pkgs/development/libraries/abseil-cpp/202206.nix b/pkgs/development/libraries/abseil-cpp/202206.nix index 7ca25f414040..a605be3c05ed 100644 --- a/pkgs/development/libraries/abseil-cpp/202206.nix +++ b/pkgs/development/libraries/abseil-cpp/202206.nix @@ -18,6 +18,12 @@ stdenv.mkDerivation rec { hash = "sha256-Od1FZOOWEXVQsnZBwGjDIExi6LdYtomyL0STR44SsG8="; }; + patches = lib.optionals stdenv.isDarwin [ + # Don’t propagate the path to CoreFoundation. Otherwise, it’s impossible to build packages + # that require a different SDK other than the default one. + ./cmake-core-foundation.patch + ]; + cmakeFlags = [ "-DBUILD_SHARED_LIBS=${if static then "OFF" else "ON"}" ] ++ lib.optionals (cxxStandard != null) [ diff --git a/pkgs/development/libraries/abseil-cpp/202301.nix b/pkgs/development/libraries/abseil-cpp/202301.nix index da5f1fc029e1..4676264c26d7 100644 --- a/pkgs/development/libraries/abseil-cpp/202301.nix +++ b/pkgs/development/libraries/abseil-cpp/202301.nix @@ -18,6 +18,12 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-PLoI7ix+reUqkZ947kWzls8lujYqWXk9A9a55UcfahI="; }; + patches = lib.optionals stdenv.isDarwin [ + # Don’t propagate the path to CoreFoundation. Otherwise, it’s impossible to build packages + # that require a different SDK other than the default one. + ./cmake-core-foundation.patch + ]; + cmakeFlags = [ "-DABSL_BUILD_TEST_HELPERS=ON" "-DABSL_USE_EXTERNAL_GOOGLETEST=ON" diff --git a/pkgs/development/libraries/abseil-cpp/202308.nix b/pkgs/development/libraries/abseil-cpp/202308.nix index 7ec0ac8a775f..78651024ab5d 100644 --- a/pkgs/development/libraries/abseil-cpp/202308.nix +++ b/pkgs/development/libraries/abseil-cpp/202308.nix @@ -18,6 +18,12 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-uNGrTNg5G5xFGtc+BSWE389x0tQ/KxJQLHfebNWas/k="; }; + patches = lib.optionals stdenv.isDarwin [ + # Don’t propagate the path to CoreFoundation. Otherwise, it’s impossible to build packages + # that require a different SDK other than the default one. + ./cmake-core-foundation.patch + ]; + cmakeFlags = [ "-DABSL_BUILD_TEST_HELPERS=ON" "-DABSL_USE_EXTERNAL_GOOGLETEST=ON" diff --git a/pkgs/development/libraries/abseil-cpp/cmake-core-foundation.patch b/pkgs/development/libraries/abseil-cpp/cmake-core-foundation.patch new file mode 100644 index 000000000000..61b57456b3fc --- /dev/null +++ b/pkgs/development/libraries/abseil-cpp/cmake-core-foundation.patch @@ -0,0 +1,12 @@ +diff -ur a/absl/time/CMakeLists.txt b/absl/time/CMakeLists.txt +--- a/absl/time/CMakeLists.txt 1969-12-31 19:00:01.000000000 -0500 ++++ b/absl/time/CMakeLists.txt 2023-10-30 21:50:32.639061785 -0400 +@@ -55,7 +55,7 @@ + ) + + if(APPLE) +- find_library(CoreFoundation CoreFoundation) ++ set(CoreFoundation "-framework CoreFoundation") + endif() + + absl_cc_library( From 3412eb7eee1219e55779da70758e2e9232a70211 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 4 Nov 2023 01:45:30 -0400 Subject: [PATCH 3/4] abseil-cpp: set the deployment target 10.13 Setting the deployment target to 10.13 is needed apparently for compatibility with GRPC. Otherwise, several arrow-cpp tests crash. --- pkgs/top-level/all-packages.nix | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3fe321c41db6..d221fc0d3cf2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20515,10 +20515,30 @@ with pkgs; aalib = callPackage ../development/libraries/aalib { }; - abseil-cpp_202103 = callPackage ../development/libraries/abseil-cpp/202103.nix { }; - abseil-cpp_202206 = callPackage ../development/libraries/abseil-cpp/202206.nix { }; - abseil-cpp_202301 = callPackage ../development/libraries/abseil-cpp/202301.nix { }; - abseil-cpp_202308 = callPackage ../development/libraries/abseil-cpp/202308.nix { }; + abseil-cpp_202103 = callPackage ../development/libraries/abseil-cpp/202103.nix { + # If abseil-cpp doesn’t have a deployment target of 10.13+, arrow-cpp crashes in libgrpc.dylib. + stdenv = if stdenv.isDarwin && stdenv.isx86_64 + then overrideSDK stdenv { darwinMinVersion = "10.13"; } + else stdenv; + }; + abseil-cpp_202206 = callPackage ../development/libraries/abseil-cpp/202206.nix { + # If abseil-cpp doesn’t have a deployment target of 10.13+, arrow-cpp crashes in libgrpc.dylib. + stdenv = if stdenv.isDarwin && stdenv.isx86_64 + then overrideSDK stdenv { darwinMinVersion = "10.13"; } + else stdenv; + }; + abseil-cpp_202301 = callPackage ../development/libraries/abseil-cpp/202301.nix { + # If abseil-cpp doesn’t have a deployment target of 10.13+, arrow-cpp crashes in libgrpc.dylib. + stdenv = if stdenv.isDarwin && stdenv.isx86_64 + then overrideSDK stdenv { darwinMinVersion = "10.13"; } + else stdenv; + }; + abseil-cpp_202308 = callPackage ../development/libraries/abseil-cpp/202308.nix { + # If abseil-cpp doesn’t have a deployment target of 10.13+, arrow-cpp crashes in libgrpc.dylib. + stdenv = if stdenv.isDarwin && stdenv.isx86_64 + then overrideSDK stdenv { darwinMinVersion = "10.13"; } + else stdenv; + }; abseil-cpp = abseil-cpp_202301; accountsservice = callPackage ../development/libraries/accountsservice { }; From b5979d3f608dbf01165ed8d21df0978fdb3cdd62 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 4 Nov 2023 01:46:37 -0400 Subject: [PATCH 4/4] grpc: switch to overrideSDK --- pkgs/top-level/all-packages.nix | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d221fc0d3cf2..676143844fc8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21827,13 +21827,9 @@ with pkgs; grilo-plugins = callPackage ../development/libraries/grilo-plugins { }; grpc = callPackage ../development/libraries/grpc { - stdenv = if (stdenv.isDarwin && stdenv.isx86_64) then - # Work around Clang check for 10.13 when using aligned allocations with C++17. - stdenv.override (old: { - hostPlatform = old.hostPlatform // { darwinMinVersion = "10.13"; }; - buildPlatform = old.buildPlatform // { darwinMinVersion = "10.13"; }; - targetPlatform = old.targetPlatform // { darwinMinVersion = "10.13"; }; - }) + # Work around Clang check for 10.13 when using aligned allocations with C++17. + stdenv = if stdenv.isDarwin && stdenv.isx86_64 + then overrideSDK stdenv { darwinMinVersion = "10.13"; } else stdenv; };