Merge pull request #255521 from wegank/ponyc-darwin

ponyc: fix build on darwin
This commit is contained in:
Weijia Wang 2023-09-18 21:49:38 +02:00 committed by GitHub
commit 98c1a15267
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View File

@ -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" ];
};
})

View File

@ -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
);