summary refs log tree commit diff
path: root/pkgs/development/compilers/ponyc
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-09-18 14:38:25 +0200
committerWeijia Wang <9713184+wegank@users.noreply.github.com>2023-09-18 14:38:25 +0200
commit2ea050d3787d5f000fc1eb374061dd315d083c5a (patch)
treee52673ab3b9d5192753831c3116041b3440957ab /pkgs/development/compilers/ponyc
parent6fb1efb2d718bd1403090bd3226ade13e25dd283 (diff)
downloadnixpkgs-2ea050d3787d5f000fc1eb374061dd315d083c5a.tar
nixpkgs-2ea050d3787d5f000fc1eb374061dd315d083c5a.tar.gz
nixpkgs-2ea050d3787d5f000fc1eb374061dd315d083c5a.tar.bz2
nixpkgs-2ea050d3787d5f000fc1eb374061dd315d083c5a.tar.lz
nixpkgs-2ea050d3787d5f000fc1eb374061dd315d083c5a.tar.xz
nixpkgs-2ea050d3787d5f000fc1eb374061dd315d083c5a.tar.zst
nixpkgs-2ea050d3787d5f000fc1eb374061dd315d083c5a.zip
ponyc: fix build on darwin
Diffstat (limited to 'pkgs/development/compilers/ponyc')
-rw-r--r--pkgs/development/compilers/ponyc/default.nix14
-rw-r--r--pkgs/development/compilers/ponyc/fix-darwin-build.patch22
2 files changed, 33 insertions, 3 deletions
diff --git a/pkgs/development/compilers/ponyc/default.nix b/pkgs/development/compilers/ponyc/default.nix
index f22fb6fece1..c7008ec22a8 100644
--- a/pkgs/development/compilers/ponyc/default.nix
+++ b/pkgs/development/compilers/ponyc/default.nix
@@ -13,6 +13,7 @@
 , substituteAll
 , which
 , z3
+, darwin
 }:
 
 stdenv.mkDerivation (rec {
@@ -34,7 +35,8 @@ stdenv.mkDerivation (rec {
     hash = "sha256-pUW9YVaujs/y00/SiPqDgK4wvVsaM7QUp/65k0t7Yr0=";
   };
 
-  nativeBuildInputs = [ cmake makeWrapper which python3 ];
+  nativeBuildInputs = [ cmake makeWrapper which python3 ]
+    ++ lib.optionals (stdenv.isDarwin) [ darwin.cctools ];
   buildInputs = [ libxml2 z3 ];
 
   # Sandbox disallows network access, so disabling problematic networking tests
@@ -50,6 +52,11 @@ stdenv.mkDerivation (rec {
         hash = "sha256-/FWBSxZESwj/QvdNK5BI2EfonT64DP1eGBZR4O8uJww=";
       };
     })
+  ] ++ lib.optionals stdenv.isDarwin [
+    (substituteAll {
+      src = ./fix-darwin-build.patch;
+      libSystem = darwin.Libsystem;
+    })
   ];
 
   postUnpack = ''
@@ -81,7 +88,8 @@ stdenv.mkDerivation (rec {
 
   env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=redundant-move" "-Wno-error=implicit-fallthrough" ];
 
-  doCheck = true;
+  # make: *** [Makefile:222: test-full-programs-release] Killed: 9
+  doCheck = !stdenv.isDarwin;
 
   installPhase = "make config=release prefix=$out "
     + lib.optionalString stdenv.isDarwin ("bits=64 " + (lib.optionalString (!lto) "lto=no "))
@@ -102,6 +110,6 @@ stdenv.mkDerivation (rec {
     homepage = "https://www.ponylang.org";
     license = licenses.bsd2;
     maintainers = with maintainers; [ kamilchm patternspandemic redvers ];
-    platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
+    platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
   };
 })
diff --git a/pkgs/development/compilers/ponyc/fix-darwin-build.patch b/pkgs/development/compilers/ponyc/fix-darwin-build.patch
new file mode 100644
index 00000000000..2570145da8d
--- /dev/null
+++ b/pkgs/development/compilers/ponyc/fix-darwin-build.patch
@@ -0,0 +1,22 @@
+diff --git a/src/libponyc/codegen/genexe.c b/src/libponyc/codegen/genexe.c
+index 42a68251..b37958ab 100644
+--- a/src/libponyc/codegen/genexe.c
++++ b/src/libponyc/codegen/genexe.c
+@@ -296,13 +296,13 @@ static bool link_exe(compile_t* c, ast_t* program,
+ 
+   snprintf(ld_cmd, ld_len,
+ #if defined(PLATFORM_IS_ARM)
+-    "%s -execute -arch %.*s "
++    "%s -execute "
+ #else
+-    "%s -execute -no_pie -arch %.*s "
++    "%s -execute -no_pie "
+ #endif
+     "-o %s %s %s %s "
+-    "-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lSystem %s",
+-           linker, (int)arch_len, c->opt->triple, file_exe, file_o,
++    "-L@libSystem@/lib -lSystem %s",
++           linker, file_exe, file_o,
+            lib_args, ponyrt, sanitizer_arg
+     );
+