git.iko.soy/typeable/nixpkgs
on master help sign in
chicken: support darwin platform (#103748)

Darwin was not included as a supported platform for chicken. However, it compiled and worked fine after bypassing unsupported platforms. We make two changes to chicken's derivation. First, we add darwin as a supported platform. Second, we set some envvars that force the build to use nix-supplied build tools. Chicken's Makefile for macOS hardcodes paths to gcc and other build tools (see https://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=blob;f=Makefile.macosx;h=5d4d9b0aa1bb4c95e1ba7a55f9586fa86ee5034f;hb=317468e4994e6245d787400359726a9fb97d5d60#l31). We override these envvars to use the wrapped $CC and bintools provided by nix to make the build pure.

commit79b78663e52de262f662e8a2ee472209e07f0b63 authorMark Hudnall <me@markhudnall.com> dateSun 15 Nov 2020, 06:11 (6 years ago) parent069f183
2 files changed+30−15
pkgs/development/compilers/chicken/4/chicken.nix+17−9 pkgs/development/compilers/chicken/5/chicken.nix+13−6
pkgs/development/compilers/chicken/4/chicken.nix+17−9
@@ -1,4 +1,4 @@
1−{ stdenv, fetchurl, makeWrapper, bootstrap-chicken ? null }:
1+{ stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
22
33let
44 version = "4.13.0";
@@ -21,31 +21,39 @@ stdenv.mkDerivation {
2121 sha256 = "0hvckhi5gfny3mlva6d7y9pmx7cbwvq0r7mk11k3sdiik9hlkmdd";
2222 };
2323
24− setupHook = lib.ifEnable (bootstrap-chicken != null) ./setup-hook.sh;
24+ setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
2525
26− buildFlags = [ "PLATFORM=${platform}" "PREFIX=$(out)" "VARDIR=$(out)/var/lib" ];
27− installFlags = [ "PLATFORM=${platform}" "PREFIX=$(out)" "VARDIR=$(out)/var/lib" ];
26+ # -fno-strict-overflow is not a supported argument in clang on darwin
27+ hardeningDisable = lib.optionals stdenv.isDarwin ["strictoverflow"];
28+
29+ makeFlags = [
30+ "PLATFORM=${platform}" "PREFIX=$(out)"
31+ "VARDIR=$(out)/var/lib"
32+ ] ++ (lib.optionals stdenv.isDarwin [
33+ "XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
34+ "C_COMPILER=$(CC)"
35+ ]);
2836
2937 # We need a bootstrap-chicken to regenerate the c-files after
3038 # applying a patch to add support for CHICKEN_REPOSITORY_EXTRA
31− patches = lib.ifEnable (bootstrap-chicken != null) [
39+ patches = lib.optionals (bootstrap-chicken != null) [
3240 ./0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch
3341 ];
3442
3543 buildInputs = [
3644 makeWrapper
37− ] ++ (lib.ifEnable (bootstrap-chicken != null) [
45+ ] ++ (lib.optionals (bootstrap-chicken != null) [
3846 bootstrap-chicken
3947 ]);
4048
41− preBuild = lib.ifEnable (bootstrap-chicken != null) ''
49+ preBuild = lib.optionalString (bootstrap-chicken != null) ''
4250 # Backup the build* files - those are generated from hostname,
4351 # git-tag, etc. and we don't need/want that
4452 mkdir -p build-backup
4553 mv buildid buildbranch buildtag.h build-backup
4654
4755 # Regenerate eval.c after the patch
48− make spotless $buildFlags
56+ make spotless $makeFlags
4957
5058 mv build-backup/* .
5159 '';
@@ -64,7 +72,7 @@ stdenv.mkDerivation {
6472 homepage = "http://www.call-cc.org/";
6573 license = stdenv.lib.licenses.bsd3;
6674 maintainers = with stdenv.lib.maintainers; [ corngood ];
67− platforms = stdenv.lib.platforms.linux; # Maybe other non-darwin Unix
75+ platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; # Maybe other Unix
6876 description = "A portable compiler for the Scheme programming language";
6977 longDescription = ''
7078 CHICKEN is a compiler for the Scheme programming language.
pkgs/development/compilers/chicken/5/chicken.nix+13−6
@@ -1,4 +1,4 @@
1−{ stdenv, fetchurl, makeWrapper, bootstrap-chicken ? null }:
1+{ stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
22
33let
44 version = "5.2.0";
@@ -21,14 +21,21 @@ stdenv.mkDerivation {
2121 sha256 = "1yl0hxm9cirgcp8jgxp6vv29lpswfvaw3zfkh6rsj0vkrv44k4c1";
2222 };
2323
24− setupHook = lib.ifEnable (bootstrap-chicken != null) ./setup-hook.sh;
24+ setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
2525
26− buildFlags = [ "PLATFORM=${platform}" "PREFIX=$(out)" ];
27− installFlags = [ "PLATFORM=${platform}" "PREFIX=$(out)" ];
26+ # -fno-strict-overflow is not a supported argument in clang on darwin
27+ hardeningDisable = lib.optionals stdenv.isDarwin ["strictoverflow"];
28+
29+ makeFlags = [
30+ "PLATFORM=${platform}" "PREFIX=$(out)"
31+ ] ++ (lib.optionals stdenv.isDarwin [
32+ "XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
33+ "C_COMPILER=$(CC)"
34+ ]);
2835
2936 buildInputs = [
3037 makeWrapper
31− ] ++ (lib.ifEnable (bootstrap-chicken != null) [
38+ ] ++ (lib.optionals (bootstrap-chicken != null) [
3239 bootstrap-chicken
3340 ]);
3441
@@ -46,7 +53,7 @@ stdenv.mkDerivation {
4653 homepage = "http://www.call-cc.org/";
4754 license = stdenv.lib.licenses.bsd3;
4855 maintainers = with stdenv.lib.maintainers; [ corngood ];
49− platforms = stdenv.lib.platforms.linux; # Maybe other non-darwin Unix
56+ platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; # Maybe other Unix
5057 description = "A portable compiler for the Scheme programming language";
5158 longDescription = ''
5259 CHICKEN is a compiler for the Scheme programming language.