summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCongee <congeec@qq.com>2022-02-15 16:26:12 -0500
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2022-02-18 12:06:49 +0000
commit0c570aab0a8b87d8e0679eceafedc9f2032a1522 (patch)
treeb96359ec02fe365a6140ae55350d8ef9d7da56c2
parentMerge pull request #160169 from NixOS/backport-158826-to-release-21.11 (diff)
downloadnixpkgs-origin/backport-160222-to-release-21.11.tar.gz
racket: support aarch64-darwinorigin/backport-160222-to-release-21.11
According to https://reviews.llvm.org/D96164, aarch64-darwin executables require at least an ad hoc signature. The build tool from the racket repo tries to sign $out/bin/racket but errors out, because that binary already has a signature. It is not clear yet at which stage the signature was introduced. This patch removes the existing signature always before calling add-ad-hoc-signature to circumvent that error. (cherry picked from commit 152b59855d2a7de9cbd0ad8051a85fa0e44de619)
-rw-r--r--pkgs/development/interpreters/racket/default.nix35
-rw-r--r--pkgs/development/interpreters/racket/force-remove-codesign-then-add.patch11
-rw-r--r--pkgs/development/interpreters/racket/minimal.nix2
3 files changed, 45 insertions, 3 deletions
diff --git a/pkgs/development/interpreters/racket/default.nix b/pkgs/development/interpreters/racket/default.nix
index 73ce0c1bc81b..f2d65b7eb5a2 100644
--- a/pkgs/development/interpreters/racket/default.nix
+++ b/pkgs/development/interpreters/racket/default.nix
@@ -77,6 +77,13 @@ stdenv.mkDerivation rec {
# fail to detect its variant at runtime.
# See: https://github.com/NixOS/nixpkgs/issues/114993#issuecomment-812951247
./force-cs-variant.patch
+
+ # The entry point binary $out/bin/racket is codesigned at least once. The
+ # following error is triggered as a result.
+ # (error 'add-ad-hoc-signature "file already has a signature")
+ # We always remove the existing signature then call add-ad-hoc-signature to
+ # circumvent this error.
+ ./force-remove-codesign-then-add.patch
];
preConfigure = ''
@@ -89,10 +96,34 @@ stdenv.mkDerivation rec {
--replace /bin/rm ${coreutils}/bin/rm \
--replace /bin/true ${coreutils}/bin/true
done
+
+ # The configure script forces using `libtool -o` as AR on Darwin. But, the
+ # `-o` option is only available from Apple libtool. GNU ar works here.
+ substituteInPlace src/ChezScheme/zlib/configure \
+ --replace 'ARFLAGS="-o"' 'AR=ar; ARFLAGS="rc"'
+
mkdir src/build
cd src/build
- gappsWrapperArgs+=("--prefix" "LD_LIBRARY_PATH" ":" ${LD_LIBRARY_PATH})
+ '' + lib.optionalString stdenv.isLinux ''
+ gappsWrapperArgs+=("--prefix" "LD_LIBRARY_PATH" ":" ${libPath})
+ '' + lib.optionalString stdenv.isDarwin ''
+ gappsWrapperArgs+=("--prefix" "DYLD_LIBRARY_PATH" ":" ${libPath})
+ ''
+ ;
+
+ preBuild = lib.optionalString stdenv.isDarwin ''
+ # Cannot set DYLD_LIBRARY_PATH as an attr of this drv, becasue dynamic
+ # linker environment variables like this are purged.
+ # See: https://apple.stackexchange.com/a/212954/167199
+
+ # Make builders feed it to dlopen(...). Do not expose all of $libPath to
+ # DYLD_LIBRARY_PATH as the order of looking up symbols like
+ # `__cg_jpeg_resync_to_restart` will be messed up. Our libJPEG.dyllib
+ # expects it from our libTIFF.dylib, but instead it could not be found from
+ # the system `libTIFF.dylib`. DYLD_FALLBACK_LIBRARY_PATH has its own problem
+ # , too.
+ export DYLD_FALLBACK_LIBRARY_PATH="${libPath}"
'';
shared = if stdenv.isDarwin then "dylib" else "shared";
@@ -118,6 +149,6 @@ stdenv.mkDerivation rec {
homepage = "https://racket-lang.org/";
license = with licenses; [ asl20 /* or */ mit ];
maintainers = with maintainers; [ kkallio henrytill vrthra ];
- platforms = [ "x86_64-darwin" "x86_64-linux" "aarch64-linux" ];
+ platforms = [ "x86_64-darwin" "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
};
}
diff --git a/pkgs/development/interpreters/racket/force-remove-codesign-then-add.patch b/pkgs/development/interpreters/racket/force-remove-codesign-then-add.patch
new file mode 100644
index 000000000000..c34457ceb950
--- /dev/null
+++ b/pkgs/development/interpreters/racket/force-remove-codesign-then-add.patch
@@ -0,0 +1,11 @@
+--- old/src/mac/codesign.rkt 2022-01-08 18:25:53.000000000 -0500
++++ new/src/mac/codesign.rkt 2022-02-15 15:49:51.000000000 -0500
+@@ -17,6 +17,5 @@
+ #:args (file)
+ file))
+
+-(if remove?
+- (remove-signature file)
+- (add-ad-hoc-signature file))
++(remove-signature file)
++(add-ad-hoc-signature file)
diff --git a/pkgs/development/interpreters/racket/minimal.nix b/pkgs/development/interpreters/racket/minimal.nix
index c7defc8bfa6b..8af31b28ebf4 100644
--- a/pkgs/development/interpreters/racket/minimal.nix
+++ b/pkgs/development/interpreters/racket/minimal.nix
@@ -14,7 +14,7 @@ racket.overrideAttrs (oldAttrs: rec {
as well as libraries that live in collections. In particular, raco
and the pkg library are still bundled.
'';
- platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
+ platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
broken = false; # Minimal build does not require working FFI
};
})