From 2b34bdd2baef495318e48cadcd445f81fcc81f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Tue, 26 Oct 2010 18:56:02 +0000 Subject: [PATCH] Two fixes in one: - our gcc should not bring libssp, because glibc provides __stack_chk_fail already. libssp is only for some non-glibc systems. The gcc configure script was not finding the header files of our glibc, so it assumed it did not provide __stack_chk_fail. I wrote code in the builder that patches the gcc/configure script properly for that. As a consequence, the glibc does not need anymore the "nscd-ssp-linking" patch, and we have a saner gcc (without libssp when using -fstack-protector) - Instead of disabling the sse42 strstr() implementation in glibc due to the bug http://sourceware.org/bugzilla/show_bug.cgi?id=12123, I provide a better patch written after more reserach (that I submitted upstream already, and it's pending review). svn path=/nixpkgs/branches/stdenv-updates/; revision=24493 --- pkgs/development/compilers/gcc-4.5/builder.sh | 8 ++++++++ .../libraries/glibc-2.12/common.nix | 18 +++--------------- .../glibc-2.12/disable-strstr-sse42.patch | 14 -------------- .../libraries/glibc-2.12/libpthread_init.patch | 15 +++++++++++++++ .../glibc-2.12/nscd-ssp-linking.patch | 16 ---------------- 5 files changed, 26 insertions(+), 45 deletions(-) delete mode 100644 pkgs/development/libraries/glibc-2.12/disable-strstr-sse42.patch create mode 100644 pkgs/development/libraries/glibc-2.12/libpthread_init.patch delete mode 100644 pkgs/development/libraries/glibc-2.12/nscd-ssp-linking.patch diff --git a/pkgs/development/compilers/gcc-4.5/builder.sh b/pkgs/development/compilers/gcc-4.5/builder.sh index 5d66cc09532e..aedd5b46b121 100644 --- a/pkgs/development/compilers/gcc-4.5/builder.sh +++ b/pkgs/development/compilers/gcc-4.5/builder.sh @@ -159,6 +159,14 @@ preConfigure() { rm -Rf zlib fi + # Patch the configure script so it finds glibc headers + # It's important for example in order not to get libssp built, because it's + # functionality is in glibc already. + glibc_headers="$(cat $NIX_GCC/nix-support/orig-libc)/include" + sed -i \ + -e s,glibc_header_dir=/usr/include,glibc_header_dir=$glibc_headers, \ + gcc/configure + if test -n "$crossMingw" -a -n "$crossStageStatic"; then mkdir -p ../mingw # --with-build-sysroot expects that: diff --git a/pkgs/development/libraries/glibc-2.12/common.nix b/pkgs/development/libraries/glibc-2.12/common.nix index 5b85cb61bf82..164929b5fcb0 100644 --- a/pkgs/development/libraries/glibc-2.12/common.nix +++ b/pkgs/development/libraries/glibc-2.12/common.nix @@ -75,22 +75,10 @@ stdenv.mkDerivation ({ /* Allow nixos and nix handle the locale-archive. */ ./nix-locale-archive.patch - /* A fix for a glibc nscd linking bug, reported upstream already.*/ - /* Currently this fix works only for i686; as it only affects - the building of glibc from a final nixpkgs stdenv, we don't care much - on whether it works or not. The patch does not affect building - from the bootstrap-tools gcc because it does not have libssp at all. - TODO: Link ssp to nscd dynamically, and set the proper rpath to - nscd, although linking dynamically will make this libc - dynamically linked with gcc's libssp, and gcc's libssp is dynamically - linked with stdenv.glibc's libc. This does not look very correct. - */ - ./nscd-ssp-linking.patch + /* Patch already sent upstream against a segafult on libpthread load */ + ./libpthread_init.patch - /* Workaround for a glibc bug reported upstraem already */ - ./disable-strstr-sse42.patch - - /* Fix for a vulnerability */ + /* Fix for a vulnerability, taken from upstream */ ./audit_suid.patch ]; diff --git a/pkgs/development/libraries/glibc-2.12/disable-strstr-sse42.patch b/pkgs/development/libraries/glibc-2.12/disable-strstr-sse42.patch deleted file mode 100644 index 0c473305039e..000000000000 --- a/pkgs/development/libraries/glibc-2.12/disable-strstr-sse42.patch +++ /dev/null @@ -1,14 +0,0 @@ -Workaround for http://sources.redhat.com/bugzilla/show_bug.cgi?id=12123 - -diff --git a/sysdeps/i386/i686/multiarch/strstr-c.c b/sysdeps/i386/i686/multiarch/strstr-c.c -index efa9f78..cd34a88 100644 ---- a/sysdeps/i386/i686/multiarch/strstr-c.c -+++ b/sysdeps/i386/i686/multiarch/strstr-c.c -@@ -10,4 +10,6 @@ - extern char *__strstr_sse42 (const char *, const char *) attribute_hidden; - extern __typeof (__strstr_ia32) __strstr_ia32 attribute_hidden; - --libc_ifunc (strstr, HAS_SSE4_2 ? __strstr_sse42 : __strstr_ia32); -+// Disabled any sse42, due to a bug: -+// http://sources.redhat.com/bugzilla/show_bug.cgi?id=12123 -+libc_ifunc (strstr, __strstr_ia32); diff --git a/pkgs/development/libraries/glibc-2.12/libpthread_init.patch b/pkgs/development/libraries/glibc-2.12/libpthread_init.patch new file mode 100644 index 000000000000..9ce2e6f846eb --- /dev/null +++ b/pkgs/development/libraries/glibc-2.12/libpthread_init.patch @@ -0,0 +1,15 @@ +http://sourceware.org/bugzilla/show_bug.cgi?id=12123 + +diff --git a/nptl/sysdeps/i386/Makefile b/nptl/sysdeps/i386/Makefile +index 2f0d88f..3d9d223 100644 +--- a/nptl/sysdeps/i386/Makefile ++++ b/nptl/sysdeps/i386/Makefile +@@ -21,6 +21,8 @@ gen-as-const-headers += tcb-offsets.sym + endif + + ifeq ($(subdir),nptl) ++CFLAGS-nptl-init.c += -mpreferred-stack-boundary=4 ++CFLAGS-pt-initfini.c += -mpreferred-stack-boundary=4 + CFLAGS-pthread_create.c += -mpreferred-stack-boundary=4 + CFLAGS-tst-align.c += -mpreferred-stack-boundary=4 + CFLAGS-tst-align2.c += -mpreferred-stack-boundary=4 diff --git a/pkgs/development/libraries/glibc-2.12/nscd-ssp-linking.patch b/pkgs/development/libraries/glibc-2.12/nscd-ssp-linking.patch deleted file mode 100644 index 2e47cee348ed..000000000000 --- a/pkgs/development/libraries/glibc-2.12/nscd-ssp-linking.patch +++ /dev/null @@ -1,16 +0,0 @@ -http://sources.redhat.com/bugzilla/show_bug.cgi?id=12125 - -diff --git a/nscd/Makefile b/nscd/Makefile -index 93874e5..63f7144 100644 ---- a/nscd/Makefile -+++ b/nscd/Makefile -@@ -90,6 +90,9 @@ CFLAGS-nscd_initgroups.c = -fexceptions - nscd-cflags = -DIS_IN_nscd=1 -D_FORTIFY_SOURCE=2 - ifeq (yesyes,$(have-fpie)$(build-shared)) - nscd-cflags += $(pie-ccflag) -+ifeq (yes,$(have-ssp)) -+link-extra-libs += -Wl,-Bstatic -lssp -Wl,-Bdynamic -+endif - endif - ifeq (yes,$(have-ssp)) - nscd-cflags += -fstack-protector