From 8e6206f9c9324d0a4ae151d1ed1d099ba76cc5ee Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 23 Jun 2022 09:36:08 -0400 Subject: [PATCH 1/3] gcc49: Fix build on darwin --- pkgs/development/compilers/gcc/4.9/default.nix | 6 ++++-- .../development/compilers/gcc/common/pre-configure.nix | 10 ++++++---- pkgs/top-level/all-packages.nix | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index b3d0f8d5d502..571d0b023124 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -154,7 +154,10 @@ stdenv.mkDerivation ({ hardeningDisable = [ "format" "pie" ]; - outputs = if langJava || langGo then ["out" "man" "info"] + # When targetting darwin, libgcc_ext.10.{4,5}.dylib are created as + # MH_DYLIB_STUB files, which install_name_tool can't change, so we + # get a cycle between $out and $lib. + outputs = if langJava || langGo || targetPlatform.isDarwin then ["out" "man" "info"] else [ "out" "lib" "man" "info" ]; setOutputFlags = false; NIX_NO_SELF_RPATH = true; @@ -328,7 +331,6 @@ stdenv.mkDerivation ({ maintainers = with lib.maintainers; [ veprbl ]; platforms = lib.platforms.unix; - badPlatforms = lib.platforms.darwin; }; } diff --git a/pkgs/development/compilers/gcc/common/pre-configure.nix b/pkgs/development/compilers/gcc/common/pre-configure.nix index d9977e0ba2f9..310e7f8b574b 100644 --- a/pkgs/development/compilers/gcc/common/pre-configure.nix +++ b/pkgs/development/compilers/gcc/common/pre-configure.nix @@ -6,14 +6,16 @@ , langGo }: assert langJava -> lib.versionOlder version "7"; -assert langAda -> gnatboot != null; - -lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' +assert langAda -> gnatboot != null; let + needsLib + = (lib.versionOlder version "7" && (langJava || langGo)) + || (lib.versions.major version == "4" && lib.versions.minor version == "9" && targetPlatform.isDarwin); +in lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" -'' + lib.optionalString (lib.versionOlder version "7" && (langJava || langGo)) '' +'' + lib.optionalString needsLib '' export lib=$out; '' + lib.optionalString langAda '' export PATH=${gnatboot}/bin:$PATH diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index daa41e5e4db1..f57ddc358582 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12812,6 +12812,9 @@ with pkgs; isl = if !stdenv.isDarwin then isl_0_11 else null; cloog = if !stdenv.isDarwin then cloog_0_18_0 else null; + + # Build fails on Darwin with clang + stdenv = if stdenv.isDarwin then gccStdenv else stdenv; })); gcc6 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/6 { From 4d781f329ded7a99d0225e4f01fc56303b1d18ab Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 23 Jun 2022 12:37:27 -0400 Subject: [PATCH 2/3] z3_4_4_0: Fix build on darwin. --- pkgs/applications/science/logic/z3/4.4.0.nix | 2 ++ pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/science/logic/z3/4.4.0.nix b/pkgs/applications/science/logic/z3/4.4.0.nix index a3d6c16fb7df..857bbbdee5d0 100644 --- a/pkgs/applications/science/logic/z3/4.4.0.nix +++ b/pkgs/applications/science/logic/z3/4.4.0.nix @@ -14,6 +14,8 @@ stdenv.mkDerivation rec { buildInputs = [ python ]; enableParallelBuilding = true; + CXXFLAGS = if stdenv.isDarwin then "-std=gnu++98" else null; + configurePhase = "python scripts/mk_make.py --prefix=$out && cd build"; # z3's install phase is stupid because it tries to calculate the diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f57ddc358582..be3369ee1e70 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -33631,7 +33631,7 @@ with pkgs; z3 = z3_4_8; z3_4_4_0 = callPackage ../applications/science/logic/z3/4.4.0.nix { python = python2; - stdenv = gcc49Stdenv; + stdenv = if stdenv.isDarwin then stdenv else gcc49Stdenv; }; z3-tptp = callPackage ../applications/science/logic/z3/tptp.nix {}; From c4f2260cdbfdcedc57337821110eb6c1071a9b6d Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Thu, 23 Jun 2022 13:24:53 -0400 Subject: [PATCH 3/3] isabelle: Fix build on darwin --- .../science/logic/isabelle/default.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/science/logic/isabelle/default.nix b/pkgs/applications/science/logic/isabelle/default.nix index 9e5d40be2c6d..0bdcd352051c 100644 --- a/pkgs/applications/science/logic/isabelle/default.nix +++ b/pkgs/applications/science/logic/isabelle/default.nix @@ -47,10 +47,15 @@ in stdenv.mkDerivation rec { sha256 = "0jfaqckhg388jh9b4msrpkv6wrd6xzlw18m0bngbby8k8ywalp9i"; }; - buildInputs = [ polyml z3 veriT vampire eprover-ho ] - ++ lib.optionals (!stdenv.isDarwin) [ nettools java ]; + buildInputs = [ polyml z3 veriT vampire eprover-ho nettools ] + ++ lib.optionals (!stdenv.isDarwin) [ java ]; - sourceRoot = dirname; + sourceRoot = "${dirname}${lib.optionalString stdenv.isDarwin ".app"}"; + + postUnpack = if stdenv.isDarwin then '' + mv $sourceRoot ${dirname} + sourceRoot=${dirname} + '' else null; postPatch = '' patchShebangs . @@ -112,6 +117,9 @@ in stdenv.mkDerivation rec { --replace '"$ML_HOME/" ^ (if ML_System.platform_is_windows then "sha1.dll" else "libsha1.so")' '"${sha1}/lib/libsha1.so"' rm -r heaps + '' + lib.optionalString (stdenv.hostPlatform.system == "x86_64-darwin") '' + substituteInPlace lib/scripts/isabelle-platform \ + --replace 'ISABELLE_APPLE_PLATFORM64=arm64-darwin' "" '' + (if ! stdenv.isLinux then "" else '' arch=${if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64-linux" else "x86-linux"} for f in contrib/*/$arch/{bash_process,epclextract,nunchaku,SPASS,zipperposition}; do @@ -180,7 +188,7 @@ in stdenv.mkDerivation rec { homepage = "https://isabelle.in.tum.de/"; license = licenses.bsd3; maintainers = [ maintainers.jwiegley maintainers.jvanbruegge ]; - platforms = platforms.linux; + platforms = platforms.unix; }; } // { withComponents = f: