From c183c7b3ec282c56b3b9943ce0496281f3b15cec Mon Sep 17 00:00:00 2001 From: Danie Roux Date: Mon, 2 Sep 2013 18:47:20 +0200 Subject: [PATCH 1/6] coreutils: Make it build on OSX 10.0.8 Take patch from: https://lists.gnu.org/archive/html/bug-coreutils/2013-01/msg00119.html --- pkgs/tools/misc/coreutils/8.19.nix | 2 ++ pkgs/tools/misc/coreutils/stpncpy.patch | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 pkgs/tools/misc/coreutils/stpncpy.patch diff --git a/pkgs/tools/misc/coreutils/8.19.nix b/pkgs/tools/misc/coreutils/8.19.nix index 23db167f307..59602e69d1d 100644 --- a/pkgs/tools/misc/coreutils/8.19.nix +++ b/pkgs/tools/misc/coreutils/8.19.nix @@ -14,6 +14,8 @@ stdenv.mkDerivation rec { sha256 = "1rx9x3fp848w4nny7irdkcpkan9fcx24d99v5dkwgkyq7wc76f5d"; }; + patches = [ ./stpncpy.patch ]; + nativeBuildInputs = [ perl ]; buildInputs = [ gmp ] ++ stdenv.lib.optional aclSupport acl diff --git a/pkgs/tools/misc/coreutils/stpncpy.patch b/pkgs/tools/misc/coreutils/stpncpy.patch new file mode 100644 index 00000000000..d4a0e0ee0e1 --- /dev/null +++ b/pkgs/tools/misc/coreutils/stpncpy.patch @@ -0,0 +1,11 @@ +--- coreutils-8.19/lib/stpncpy.c.orig 2013-09-02 18:20:00.000000000 +0200 ++++ coreutils-8.19/lib/stpncpy.c 2013-09-02 18:20:31.000000000 +0200 +@@ -31,7 +31,7 @@ + /* Copy no more than N bytes of SRC to DST, returning a pointer past the + last non-NUL byte written into DST. */ + char * +-__stpncpy (char *dest, const char *src, size_t n) ++(__stpncpy) (char *dest, const char *src, size_t n) + { + char c; + char *s = dest; From 76ca653d7b280287c875b67a5476ead6d33307a7 Mon Sep 17 00:00:00 2001 From: Danie Roux Date: Sat, 7 Sep 2013 16:30:23 +0200 Subject: [PATCH 2/6] coreutils: 8.20 does build on Darwin Where gcc is: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) --- pkgs/top-level/all-packages.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f64684c8a3e..3bb5373dd2b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -665,11 +665,7 @@ let convmv = callPackage ../tools/misc/convmv { }; - coreutils = (if stdenv.isDarwin then - # 8.20 doesn't build on Darwin - callPackage ../tools/misc/coreutils/8.19.nix - else - callPackage ../tools/misc/coreutils) + coreutils = callPackage ../tools/misc/coreutils { # TODO: Add ACL support for cross-Linux. aclSupport = crossSystem == null && stdenv.isLinux; From 14109047bdda9d3522a1968b59d75e5520c11775 Mon Sep 17 00:00:00 2001 From: Danie Roux Date: Sat, 7 Sep 2013 16:36:10 +0200 Subject: [PATCH 3/6] gettext: Guard against compiler not supporting __builtin_stpncpy From https://lists.macosforge.org/pipermail/macports-dev/2011-July/015263.html: 5) Building with a compiler that doesn't support newer __builtins If your port uses MacPorts compilers rather than the default compiler, you may run into trouble with string functions. You'll see errors at link time about undefined __builtin_* functions. If this happens, you may want to compile with -D_FORTIFY_SOURCE=0 to tell the headers to use unfortified versions which do not use compiler builtins. --- pkgs/development/libraries/gettext/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index 5468c9f2336..dbc17ffa1bb 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -19,6 +19,9 @@ stdenv.mkDerivation (rec { "--config-cache" ]); + makeFlags = stdenv.lib.optionalString stdenv.isDarwin + "CFLAGS=-D_FORTIFY_SOURCE=0"; + # On cross building, gettext supposes that the wchar.h from libc # does not fulfill gettext needs, so it tries to work with its # own wchar.h file, which does not cope well with the system's From 123ab78ee037f80a7ed98010f95168c48b2aa78b Mon Sep 17 00:00:00 2001 From: Danie Roux Date: Sat, 7 Sep 2013 16:42:04 +0200 Subject: [PATCH 4/6] coreutils: Remove 8.19 reference --- pkgs/tools/misc/coreutils/8.19.nix | 72 ------------------------- pkgs/tools/misc/coreutils/stpncpy.patch | 11 ---- 2 files changed, 83 deletions(-) delete mode 100644 pkgs/tools/misc/coreutils/8.19.nix delete mode 100644 pkgs/tools/misc/coreutils/stpncpy.patch diff --git a/pkgs/tools/misc/coreutils/8.19.nix b/pkgs/tools/misc/coreutils/8.19.nix deleted file mode 100644 index 59602e69d1d..00000000000 --- a/pkgs/tools/misc/coreutils/8.19.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ stdenv, fetchurl, perl, gmp ? null -, aclSupport ? false, acl ? null -, selinuxSupport? false, libselinux ? null, libsepol ? null -}: - -assert aclSupport -> acl != null; -assert selinuxSupport -> libselinux != null && libsepol != null; - -stdenv.mkDerivation rec { - name = "coreutils-8.19"; - - src = fetchurl { - url = "mirror://gnu/coreutils/${name}.tar.xz"; - sha256 = "1rx9x3fp848w4nny7irdkcpkan9fcx24d99v5dkwgkyq7wc76f5d"; - }; - - patches = [ ./stpncpy.patch ]; - - nativeBuildInputs = [ perl ]; - buildInputs = [ gmp ] - ++ stdenv.lib.optional aclSupport acl - ++ stdenv.lib.optional selinuxSupport libselinux - ++ stdenv.lib.optional selinuxSupport libsepol; - - crossAttrs = ({ - buildInputs = [ gmp ] - ++ stdenv.lib.optional aclSupport acl.crossDrv - ++ stdenv.lib.optional selinuxSupport libselinux.crossDrv - ++ stdenv.lib.optional selinuxSupport libsepol.crossDrv - ++ stdenv.lib.optional (stdenv.gccCross.libc ? libiconv) - stdenv.gccCross.libc.libiconv.crossDrv; - - # Needed for fstatfs() - # I don't know why it is not properly detected cross building with glibc. - configureFlags = [ "fu_cv_sys_stat_statfs2_bsize=yes" ]; - doCheck = false; - } - - // - - # XXX: Temporary workaround to allow GNU/Hurd builds with newer libcs. - (stdenv.lib.optionalAttrs (stdenv.cross.config == "i586-pc-gnu") { - patches = [ ./gets-undeclared.patch ]; - })); - - # The tests are known broken on Cygwin - # (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19025), - # Darwin (http://thread.gmane.org/gmane.comp.gnu.core-utils.bugs/19351), - # and {Open,Free}BSD. - doCheck = stdenv ? glibc; - - enableParallelBuilding = true; - - NIX_LDFLAGS = stdenv.lib.optionalString selinuxSupport "-lsepol"; - - meta = { - homepage = http://www.gnu.org/software/coreutils/; - description = "The basic file, shell and text manipulation utilities of the GNU operating system"; - - longDescription = '' - The GNU Core Utilities are the basic file, shell and text - manipulation utilities of the GNU operating system. These are - the core utilities which are expected to exist on every - operating system. - ''; - - license = "GPLv3+"; - - maintainers = [ ]; - }; -} - diff --git a/pkgs/tools/misc/coreutils/stpncpy.patch b/pkgs/tools/misc/coreutils/stpncpy.patch deleted file mode 100644 index d4a0e0ee0e1..00000000000 --- a/pkgs/tools/misc/coreutils/stpncpy.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- coreutils-8.19/lib/stpncpy.c.orig 2013-09-02 18:20:00.000000000 +0200 -+++ coreutils-8.19/lib/stpncpy.c 2013-09-02 18:20:31.000000000 +0200 -@@ -31,7 +31,7 @@ - /* Copy no more than N bytes of SRC to DST, returning a pointer past the - last non-NUL byte written into DST. */ - char * --__stpncpy (char *dest, const char *src, size_t n) -+(__stpncpy) (char *dest, const char *src, size_t n) - { - char c; - char *s = dest; From 055e646bfc1fc0b06ac61ee88f1d31b1698f287f Mon Sep 17 00:00:00 2001 From: Danie Roux Date: Sun, 8 Sep 2013 02:04:43 +0200 Subject: [PATCH 5/6] coreutils: Guard against compiler not supporting __builtin_stpncpy_chk From https://lists.macosforge.org/pipermail/macports-dev/2011-July/015263.html: 5) Building with a compiler that doesn't support newer __builtins If your port uses MacPorts compilers rather than the default compiler, you may run into trouble with string functions. You'll see errors at link time about undefined __builtin_* functions. If this happens, you may want to compile with -D_FORTIFY_SOURCE=0 to tell the headers to use unfortified versions which do not use compiler builtins. --- pkgs/tools/misc/coreutils/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix index da3e8d09a23..c4066c89d1d 100644 --- a/pkgs/tools/misc/coreutils/default.nix +++ b/pkgs/tools/misc/coreutils/default.nix @@ -59,6 +59,9 @@ let NIX_LDFLAGS = stdenv.lib.optionalString selinuxSupport "-lsepol"; + makeFlags = stdenv.lib.optionalString stdenv.isDarwin + "CFLAGS=-D_FORTIFY_SOURCE=0"; + meta = { homepage = http://www.gnu.org/software/coreutils/; description = "The basic file, shell and text manipulation utilities of the GNU operating system"; From 961c2fe7c3cb5410b747c258bc29328c0433a264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Sat, 14 Sep 2013 14:56:10 +0200 Subject: [PATCH 6/6] coreutils,gettext: don't change hash except for darwin Also some style cleanup. Note that defining an empty-string variable *does* change the hash. I would like to change this behaviour one day (clean up attrs when compiling the derivation). --- .../development/libraries/gettext/default.nix | 25 +++++++++--------- pkgs/tools/misc/coreutils/default.nix | 26 +++++++++---------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index dbc17ffa1bb..4908662591c 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -1,8 +1,10 @@ -{ stdenv, fetchurl, libiconv }: +{ stdenv, fetchurl, libiconvOrEmpty }: + +with { inherit (stdenv.lib) optionals optionalAttrs; }; stdenv.mkDerivation (rec { name = "gettext-0.18.1.1"; - + src = fetchurl { url = "mirror://gnu/gettext/${name}.tar.gz"; sha256 = "1sa3ch12qxa4h3ya6hkz119yclcccmincl9j20dhrdx5mykp3b4k"; @@ -11,7 +13,7 @@ stdenv.mkDerivation (rec { patches = [ ./no-gets.patch ]; configureFlags = [ "--disable-csharp" ] - ++ (stdenv.lib.optionals stdenv.isCygwin + ++ (optionals stdenv.isCygwin [ # We have a static libiconv, so we can only build the static lib. "--disable-shared" "--enable-static" @@ -19,9 +21,6 @@ stdenv.mkDerivation (rec { "--config-cache" ]); - makeFlags = stdenv.lib.optionalString stdenv.isDarwin - "CFLAGS=-D_FORTIFY_SOURCE=0"; - # On cross building, gettext supposes that the wchar.h from libc # does not fulfill gettext needs, so it tries to work with its # own wchar.h file, which does not cope well with the system's @@ -33,12 +32,12 @@ stdenv.mkDerivation (rec { fi ''; - buildInputs = stdenv.lib.optional (!stdenv.isLinux) libiconv; - + buildInputs = libiconvOrEmpty; + enableParallelBuilding = true; - + crossAttrs = { - buildInputs = stdenv.lib.optional (stdenv.gccCross.libc ? libiconv) + buildInputs = optional (stdenv.gccCross.libc ? libiconv) stdenv.gccCross.libc.libiconv.crossDrv; # Gettext fails to guess the cross compiler configureFlags = "CXX=${stdenv.cross.config}-g++"; @@ -73,9 +72,11 @@ stdenv.mkDerivation (rec { }; } -// +// optionalAttrs stdenv.isDarwin { + makeFlags = "CFLAGS=-D_FORTIFY_SOURCE=0"; +} -stdenv.lib.optionalAttrs stdenv.isCygwin { +// optionalAttrs stdenv.isCygwin { patchPhase = # Make sure `error.c' gets compiled and is part of `libgettextlib.la'. # This fixes: diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix index c4066c89d1d..65a3bec555e 100644 --- a/pkgs/tools/misc/coreutils/default.nix +++ b/pkgs/tools/misc/coreutils/default.nix @@ -6,8 +6,11 @@ assert aclSupport -> acl != null; assert selinuxSupport -> libselinux != null && libsepol != null; + +with { inherit (stdenv.lib) optional optionals optionalString optionalAttrs; }; + let - self = stdenv.mkDerivation rec { + self = stdenv.mkDerivation (rec { name = "coreutils-8.21"; src = fetchurl { @@ -17,16 +20,14 @@ let nativeBuildInputs = [ perl ]; buildInputs = [ gmp ] - ++ stdenv.lib.optional aclSupport acl - ++ stdenv.lib.optional selinuxSupport libselinux - ++ stdenv.lib.optional selinuxSupport libsepol; + ++ optional aclSupport acl + ++ optionals selinuxSupport [ libselinux libsepol ]; crossAttrs = { buildInputs = [ gmp ] - ++ stdenv.lib.optional aclSupport acl.crossDrv - ++ stdenv.lib.optional selinuxSupport libselinux.crossDrv - ++ stdenv.lib.optional selinuxSupport libsepol.crossDrv - ++ stdenv.lib.optional (stdenv.gccCross.libc ? libiconv) + ++ optional aclSupport acl.crossDrv + ++ optionals selinuxSupport [ libselinux.crossDrv libsepol.crossDrv ] + ++ optional (stdenv.gccCross.libc ? libiconv) stdenv.gccCross.libc.libiconv.crossDrv; buildPhase = '' @@ -57,10 +58,7 @@ let enableParallelBuilding = true; - NIX_LDFLAGS = stdenv.lib.optionalString selinuxSupport "-lsepol"; - - makeFlags = stdenv.lib.optionalString stdenv.isDarwin - "CFLAGS=-D_FORTIFY_SOURCE=0"; + NIX_LDFLAGS = optionalString selinuxSupport "-lsepol"; meta = { homepage = http://www.gnu.org/software/coreutils/; @@ -77,6 +75,8 @@ let maintainers = [ ]; }; - }; + } // optionalAttrs stdenv.isDarwin { + makeFlags = "CFLAGS=-D_FORTIFY_SOURCE=0"; + }); in self