From a2a82db7cf3eda1a17abe2f673291852c4a85ba9 Mon Sep 17 00:00:00 2001 From: Dan Peebles Date: Tue, 21 Mar 2017 01:36:28 -0400 Subject: [PATCH] gfortran/gcc: simplify & clean up on Darwin This should eliminate the branched logic for gfortran on Darwin, as well as preventing accidental inclusion of impure paths in gcc and gfortran builds. --- pkgs/development/compilers/gcc/5/default.nix | 10 +++- .../compilers/gcc/gfortran-darwin.nix | 52 ------------------- .../compilers/gcc/gfortran-darwin.patch | 26 ---------- pkgs/top-level/all-packages.nix | 5 +- 4 files changed, 10 insertions(+), 83 deletions(-) delete mode 100644 pkgs/development/compilers/gcc/gfortran-darwin.nix delete mode 100644 pkgs/development/compilers/gcc/gfortran-darwin.patch diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index da4f7a606705..3e9104a82fbc 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -76,7 +76,8 @@ let version = "5.4.0"; ++ optional langAda ../gnat-cflags.patch ++ optional langFortran ../gfortran-driving.patch - # This could be applied unconditionally but I don't want to cause a full Linux rebuild. + # This could be applied unconditionally but I don't want to cause a full + # Linux rebuild. ++ optional stdenv.cc.isClang ./libcxx38-and-above.patch; javaEcj = fetchurl { @@ -234,6 +235,13 @@ stdenv.mkDerivation ({ libc_dev = stdenv.cc.libc_dev; + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = if stdenv.isDarwin then '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + '' else null; + postPatch = if (stdenv.isGNU || (libcCross != null # e.g., building `gcc.crossDrv' diff --git a/pkgs/development/compilers/gcc/gfortran-darwin.nix b/pkgs/development/compilers/gcc/gfortran-darwin.nix deleted file mode 100644 index 48caeea5f1ff..000000000000 --- a/pkgs/development/compilers/gcc/gfortran-darwin.nix +++ /dev/null @@ -1,52 +0,0 @@ -# This is a derivation specific to OS X (Darwin) -{gmp, mpfr, libmpc, isl_0_14, cloog, zlib, fetchurl, stdenv - -, Libsystem -}: - -stdenv.mkDerivation rec { - name = "gfortran-${version}"; - version = "5.1.0"; - - buildInputs = [ gmp mpfr libmpc isl_0_14 cloog zlib ]; - - src = fetchurl { - url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; - sha256 = "1bd5vj4px3s8nlakbgrh38ynxq4s654m6nxz7lrj03mvkkwgvnmp"; - }; - - patches = ./gfortran-darwin.patch; - - hardeningDisable = [ "format" ]; - - configureFlags = '' - --disable-bootstrap - --disable-cloog-version-check - --disable-isl-version-check - --disable-multilib - --enable-checking=release - --enable-languages=fortran - --with-cloog=${cloog} - --with-gmp=${gmp.dev} - --with-isl=${isl_0_14} - --with-mpc=${libmpc} - --with-mpfr=${mpfr.dev} - --with-native-system-header-dir=${Libsystem}/include - --with-system-zlib - ''; - - postConfigure = '' - export DYLD_LIBRARY_PATH=`pwd`/`uname -m`-apple-darwin`uname -r`/libgcc - ''; - - makeFlags = [ "CC=clang" ]; - - passthru.cc = stdenv.cc.cc; - - meta = with stdenv.lib; { - description = "GNU Fortran compiler, part of the GNU Compiler Collection"; - homepage = "https://gcc.gnu.org/fortran/"; - license = licenses.gpl3Plus; - platforms = platforms.darwin; - }; -} diff --git a/pkgs/development/compilers/gcc/gfortran-darwin.patch b/pkgs/development/compilers/gcc/gfortran-darwin.patch deleted file mode 100644 index 73c5d35153b0..000000000000 --- a/pkgs/development/compilers/gcc/gfortran-darwin.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/gcc/config/darwin-c.c 2015-01-09 22:18:42.000000000 +0200 -+++ b/gcc/config/darwin-c.c 2015-06-27 04:17:58.000000000 +0300 -@@ -490,8 +490,7 @@ - - static const char *framework_defaults [] = - { -- "/System/Library/Frameworks", -- "/Library/Frameworks", -+// stdenvDarwinPure - }; - - /* Register the GNU objective-C runtime include path if STDINC. */ - - /* Register the GNU objective-C runtime include path if STDINC. */ ---- a/gcc/cppdefault.c 2015-01-05 14:33:28.000000000 +0200 -+++ b/gcc/cppdefault.c 2015-06-27 04:16:15.000000000 +0300 -@@ -35,6 +35,9 @@ - # undef CROSS_INCLUDE_DIR - #endif - -+// stdenvDarwinPure -+# undef LOCAL_INCLUDE_DIR -+ - const struct default_include cpp_include_defaults[] - #ifdef INCLUDE_DEFAULTS - = INCLUDE_DEFAULTS; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1e089956fdbf..7ce142534bc4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5058,10 +5058,7 @@ with pkgs; isl = if !stdenv.isDarwin then isl_0_14 else null; })); - gfortran = if !stdenv.isDarwin then gfortran5 - else callPackage ../development/compilers/gcc/gfortran-darwin.nix { - inherit (darwin) Libsystem; - }; + gfortran = gfortran5; gfortran48 = wrapCC (gcc48.cc.override { name = "gfortran";