Merge pull request #105026 from thefloweringash/apple-silicon
Native support for Apple Silicon
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl }:
|
||||
{ lib, stdenv, fetchurl, autoreconfHook }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "apr-1.7.0";
|
||||
@@ -36,6 +36,10 @@ stdenv.mkDerivation rec {
|
||||
|
||||
CPPFLAGS=lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) "-DAPR_IOVEC_DEFINED";
|
||||
|
||||
nativeBuildInputs =
|
||||
# Update libtool for macOS 11 support
|
||||
lib.optional (stdenv.isDarwin && stdenv.isAarch64) [ autoreconfHook ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
meta = with lib; {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchFromGitHub, cmake }:
|
||||
{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "catch";
|
||||
@@ -14,6 +14,14 @@ stdenv.mkDerivation rec {
|
||||
nativeBuildInputs = [ cmake ];
|
||||
cmakeFlags = [ "-DUSE_CPP14=ON" ];
|
||||
|
||||
patches = [
|
||||
# https://github.com/catchorg/Catch2/pull/2151
|
||||
(fetchpatch {
|
||||
url = "https://github.com/catchorg/Catch2/commit/bb6d08323f23a39eb65dd86671e68f4f5d3f2d6c.patch";
|
||||
sha256 = "1vhbzx84nrhhf9zlbl6h5zmg3r5w5v833ihlswsysb9wp2i4isc5";
|
||||
})
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
checkTarget = "test";
|
||||
|
||||
|
||||
@@ -61,6 +61,11 @@ stdenv.mkDerivation rec {
|
||||
url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/409b37c62780728755c908991c912a6b16f2389c.patch";
|
||||
sha256 = "zJFh37QErSAINPGFkFVJyhYRP27BuIN7PIgoDl/PIwI=";
|
||||
})
|
||||
|
||||
# Combination of
|
||||
# https://gitlab.freedesktop.org/fontconfig/fontconfig/-/merge_requests/88
|
||||
# https://gitlab.freedesktop.org/fontconfig/fontconfig/-/merge_requests/131
|
||||
./macos-atomics.h
|
||||
];
|
||||
|
||||
outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
--- a/src/fcatomic.h 2020-11-27 13:23:44.000000000 +0900
|
||||
+++ b/src/fcatomic.h 2020-11-27 13:24:43.000000000 +0900
|
||||
@@ -70,24 +70,25 @@
|
||||
#elif !defined(FC_NO_MT) && defined(__APPLE__)
|
||||
|
||||
#include <libkern/OSAtomic.h>
|
||||
-#ifdef __MAC_OS_X_MIN_REQUIRED
|
||||
#include <AvailabilityMacros.h>
|
||||
-#elif defined(__IPHONE_OS_MIN_REQUIRED)
|
||||
-#include <Availability.h>
|
||||
-#endif
|
||||
|
||||
typedef int fc_atomic_int_t;
|
||||
#define fc_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
|
||||
|
||||
-#define fc_atomic_ptr_get(P) (OSMemoryBarrier (), (void *) *(P))
|
||||
-#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100)
|
||||
-#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
|
||||
-#else
|
||||
-#if __ppc64__ || __x86_64__
|
||||
-#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap64Barrier ((int64_t) (O), (int64_t) (N), (int64_t*) (P))
|
||||
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_OS_VERSION_MIN_REQUIRED >= 20100)
|
||||
+
|
||||
+#if SIZEOF_VOID_P == 8
|
||||
+#define fc_atomic_ptr_get(P) OSAtomicAdd64Barrier (0, (int64_t*)(P))
|
||||
+#elif SIZEOF_VOID_P == 4
|
||||
+#define fc_atomic_ptr_get(P) OSAtomicAdd32Barrier (0, (int32_t*)(P))
|
||||
#else
|
||||
-#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwap32Barrier ((int32_t) (O), (int32_t) (N), (int32_t*) (P))
|
||||
+#error "SIZEOF_VOID_P not 4 or 8 (assumes CHAR_BIT is 8)"
|
||||
#endif
|
||||
+
|
||||
+#define fc_atomic_ptr_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
|
||||
+
|
||||
+#else
|
||||
+#error "Your macOS / iOS targets are too old"
|
||||
#endif
|
||||
|
||||
#elif !defined(FC_NO_MT) && defined(HAVE_INTEL_ATOMIC_PRIMITIVES)
|
||||
@@ -54,6 +54,7 @@ stdenv.mkDerivation rec {
|
||||
|
||||
patches = optionals stdenv.isDarwin [
|
||||
./darwin-compilation.patch
|
||||
./link-with-coreservices.patch
|
||||
] ++ optionals stdenv.hostPlatform.isMusl [
|
||||
./quark_init_on_demand.patch
|
||||
./gobject_init_on_demand.patch
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/meson.build.orig 2020-11-25 13:47:38.499149252 +0900
|
||||
+++ b/meson.build 2020-11-25 13:48:47.098444800 +0900
|
||||
@@ -742,7 +742,7 @@
|
||||
|
||||
if glib_have_carbon
|
||||
glib_conf.set('HAVE_CARBON', true)
|
||||
- osx_ldflags += '-Wl,-framework,Carbon'
|
||||
+ osx_ldflags += ['-Wl,-framework,Carbon', '-Wl,-framework,CoreServices']
|
||||
glib_have_os_x_9_or_later = objcc.compiles('''#include <AvailabilityMacros.h>
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
|
||||
#error Compiling for minimum OS X version before 10.9
|
||||
@@ -46,7 +46,7 @@ let self = stdenv.mkDerivation rec {
|
||||
# to build a .dll on windows, we need --disable-static + --enable-shared
|
||||
# see https://gmplib.org/manual/Notes-for-Particular-Systems.html
|
||||
++ optional (!withStatic && stdenv.hostPlatform.isWindows) "--disable-static --enable-shared"
|
||||
;
|
||||
++ optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) "--disable-assembly";
|
||||
|
||||
doCheck = true; # not cross;
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "1fq30imk8zd26x8066di3kpc5zyfc5z6frr3zll685zcx4dxxrlj";
|
||||
};
|
||||
|
||||
preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") ''
|
||||
MACOSX_DEPLOYMENT_TARGET=10.16
|
||||
'';
|
||||
|
||||
# libevent_openssl is moved into its own output, so that openssl isn't present
|
||||
# in the default closure.
|
||||
outputs = [ "out" "dev" ]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
, pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform
|
||||
, icuSupport ? false, icu ? null
|
||||
, enableShared ? stdenv.hostPlatform.libc != "msvcrt"
|
||||
, enableStatic ? !enableShared,
|
||||
, enableStatic ? !enableShared
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
@@ -53,6 +53,10 @@ stdenv.mkDerivation rec {
|
||||
(lib.withFeatureAs pythonSupport "python" python)
|
||||
];
|
||||
|
||||
preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") ''
|
||||
MACOSX_DEPLOYMENT_TARGET=10.16
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
# disable test that's problematic with newer pythons: see
|
||||
|
||||
@@ -13,6 +13,10 @@ stdenv.mkDerivation rec {
|
||||
|
||||
patches = lib.optional stdenv.isDarwin [ ./bsm-add-audit_token_to_pid.patch ];
|
||||
|
||||
preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") ''
|
||||
MACOSX_DEPLOYMENT_TARGET=10.16
|
||||
'';
|
||||
|
||||
configureFlags = [ "ac_cv_file__usr_include_mach_audit_triggers_defs=no" ];
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -30,6 +30,10 @@ stdenv.mkDerivation rec {
|
||||
"CC=${stdenv.cc.targetPrefix}cc"
|
||||
];
|
||||
|
||||
preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") ''
|
||||
MACOSX_DEPLOYMENT_TARGET=10.16
|
||||
'';
|
||||
|
||||
configureFlags = [
|
||||
"--enable-overlays"
|
||||
"--disable-dependency-tracking" # speeds up one-time build
|
||||
|
||||
@@ -69,6 +69,7 @@ let
|
||||
armv6l-linux = "./Configure linux-armv4 -march=armv6";
|
||||
armv7l-linux = "./Configure linux-armv4 -march=armv7-a";
|
||||
x86_64-darwin = "./Configure darwin64-x86_64-cc";
|
||||
aarch64-darwin = "./Configure darwin64-arm64-cc";
|
||||
x86_64-linux = "./Configure linux-x86_64";
|
||||
x86_64-solaris = "./Configure solaris64-x86_64-gcc";
|
||||
}.${stdenv.hostPlatform.system} or (
|
||||
|
||||
@@ -23,7 +23,8 @@ in stdenv.mkDerivation {
|
||||
|
||||
outputs = [ "bin" "dev" "out" "doc" "man" ];
|
||||
|
||||
configureFlags = optional (!stdenv.hostPlatform.isRiscV) "--enable-jit" ++ [
|
||||
# Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51
|
||||
configureFlags = optional (!stdenv.hostPlatform.isRiscV && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--enable-jit" ++ [
|
||||
"--enable-unicode-properties"
|
||||
"--disable-cpp"
|
||||
]
|
||||
|
||||
@@ -8,10 +8,11 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "0p3699msps07p40g9426lvxa3b41rg7k2fn7qxl2jm0kh4kkkvx9";
|
||||
};
|
||||
|
||||
# Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51
|
||||
configureFlags = [
|
||||
"--enable-pcre2-16"
|
||||
"--enable-pcre2-32"
|
||||
] ++ lib.optional (!stdenv.hostPlatform.isRiscV) "--enable-jit";
|
||||
] ++ lib.optional (!stdenv.hostPlatform.isRiscV && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--enable-jit";
|
||||
|
||||
outputs = [ "bin" "dev" "out" "doc" "man" "devdoc" ];
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ stdenv.mkDerivation (rec {
|
||||
|
||||
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
substituteInPlace configure \
|
||||
--replace '/usr/bin/libtool' 'ar' \
|
||||
--replace 'AR="libtool"' 'AR="ar"' \
|
||||
--replace '/usr/bin/libtool' '${stdenv.cc.targetPrefix}ar' \
|
||||
--replace 'AR="libtool"' 'AR="${stdenv.cc.targetPrefix}ar"' \
|
||||
--replace 'ARFLAGS="-o"' 'ARFLAGS="-r"'
|
||||
'';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user