summary refs log tree commit diff
path: root/pkgs/development/libraries/gcc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-07-23 14:13:07 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-07-24 20:22:51 -0400
commit0f3a7982e7e73bbc58f86dfed811d51c6206d24a (patch)
treeff77e11cd55507f5a502e3ebbb54b0b83f632c4c /pkgs/development/libraries/gcc
parenta6ede9f46e54a3bba8e9cd60b3a884687c3a8336 (diff)
downloadnixpkgs-0f3a7982e7e73bbc58f86dfed811d51c6206d24a.tar
nixpkgs-0f3a7982e7e73bbc58f86dfed811d51c6206d24a.tar.gz
nixpkgs-0f3a7982e7e73bbc58f86dfed811d51c6206d24a.tar.bz2
nixpkgs-0f3a7982e7e73bbc58f86dfed811d51c6206d24a.tar.lz
nixpkgs-0f3a7982e7e73bbc58f86dfed811d51c6206d24a.tar.xz
nixpkgs-0f3a7982e7e73bbc58f86dfed811d51c6206d24a.tar.zst
nixpkgs-0f3a7982e7e73bbc58f86dfed811d51c6206d24a.zip
libstdcxx5: Move around ahead of other GCC libs being added
Diffstat (limited to 'pkgs/development/libraries/gcc')
-rw-r--r--pkgs/development/libraries/gcc/libstdc++/5.nix117
-rw-r--r--pkgs/development/libraries/gcc/libstdc++/no-sys-dirs.patch53
-rw-r--r--pkgs/development/libraries/gcc/libstdc++/struct-ucontext.patch61
3 files changed, 231 insertions, 0 deletions
diff --git a/pkgs/development/libraries/gcc/libstdc++/5.nix b/pkgs/development/libraries/gcc/libstdc++/5.nix
new file mode 100644
index 00000000000..f8397052b77
--- /dev/null
+++ b/pkgs/development/libraries/gcc/libstdc++/5.nix
@@ -0,0 +1,117 @@
+{ stdenv, fetchurl, fetchpatch, flex, bison, file }:
+
+stdenv.mkDerivation rec {
+  name = "libstdc++5-${version}";
+  version = "3.3.6";
+
+  src = [
+    (fetchurl {
+      url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
+      sha256 = "1dpyrpsgakilz2rnh5f8gvrzq5pwzvndacc0df6m04bpqn5fx6sg";
+    })
+    (fetchurl {
+      url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
+      sha256 = "14lxl81f7adpc9jxfiwzdxsdzs5zv4piv8xh7f9w910hfzrgvsby";
+    })
+  ];
+
+  patches = [
+    ./no-sys-dirs.patch
+    (fetchpatch {
+      name = "siginfo.patch";
+      url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/siginfo.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
+      sha256 = "15zldbm33yba293dgrgsbv3j332hkc3iqpyc8fa7zl42mh9qk22j";
+      extraPrefix = "";
+    })
+    (fetchpatch {
+      name = "gcc-3.4.3-no_multilib_amd64.patch";
+      url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/gcc-3.4.3-no_multilib_amd64.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
+      sha256 = "11m5lc51b0addhc4yq4rz0dwpv6k73rrj73wya3lqdk8rly6cjpm";
+      extraPrefix = "";
+    })
+    # Required because of glibc 2.26
+    ./struct-ucontext.patch
+  ];
+
+  postPatch = ''
+    # fix build issue with recent gcc
+    sed -i "s#O_CREAT#O_CREAT, 0666#" gcc/collect2.c
+
+    # No fixincludes
+    sed -i -e 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
+  '';
+
+  preConfigure = ''
+    mkdir ../build
+    cd ../build
+    configureScript=../$sourceRoot/configure
+  '';
+
+  preBuild = ''
+    # libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
+    # Thing.
+    export CPP="gcc -E"
+
+    # Use *real* header files, otherwise a limits.h is generated
+    # that does not include Glibc's limits.h (notably missing
+    # SSIZE_MAX, which breaks the build).
+    export NIX_FIXINC_DUMMY="$(cat $NIX_CC/nix-support/orig-libc-dev)/include"
+
+    # The path to the Glibc binaries such as `crti.o'.
+    glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
+
+    # Figure out what extra flags to pass to the gcc compilers
+    # being generated to make sure that they use our glibc.
+    EXTRA_FLAGS="-I$NIX_FIXINC_DUMMY $(cat $NIX_CC/nix-support/libc-cflags) -O2"
+
+    extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $(cat $NIX_BINTOOLS/nix-support/libc-ldflags) $(cat $NIX_BINTOOLS/nix-support/libc-ldflags-before)"
+    for i in $extraLDFlags; do
+      EXTRA_FLAGS="$EXTRA_FLAGS -Wl,$i"
+    done
+
+    # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
+    # the startfiles.
+    # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
+    # for the startfiles.
+    makeFlagsArray=( \
+      "''${makeFlagsArray[@]}" \
+      NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+      SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
+      CFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
+      CFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
+      CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
+      CXXFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
+      FLAGS_FOR_TARGET="$EXTRA_FLAGS" \
+      LDFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
+      LDFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
+      BOOT_CFLAGS="$EXTRA_FLAGS" \
+      BOOT_LDFLAGS="$EXTRA_FLAGS"
+      )
+  '';
+
+  hardeningDisable = [ "format" ];
+
+  nativeBuildInputs = [ flex bison file ];
+
+  configureFlags = [ "--disable-multilib" "--enable-__cxa-atexit" "--enable-threads=posix" "--enable-languages=c++" "--enable-clocale=gnu" ];
+
+  buildFLags = [ "all-target-libstdc++-v3" ];
+
+  installFlags = [ "install-target-libstdc++-v3" ];
+
+  postInstall = ''
+    # Remove includefiles and libs provided by gcc
+    shopt -s extglob
+    rm -rf $out/{bin,include,share,man,info}
+    rm -f $out/lib/*.a
+    rm -rf $out/lib/!(libstdc++*)
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://gcc.gnu.org/;
+    license = licenses.lgpl3Plus;
+    description = "GNU Compiler Collection, version ${version} -- C++ standard library";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ abbradar ];
+  };
+}
diff --git a/pkgs/development/libraries/gcc/libstdc++/no-sys-dirs.patch b/pkgs/development/libraries/gcc/libstdc++/no-sys-dirs.patch
new file mode 100644
index 00000000000..8c91d75f2a5
--- /dev/null
+++ b/pkgs/development/libraries/gcc/libstdc++/no-sys-dirs.patch
@@ -0,0 +1,53 @@
+diff -ru3 gcc-3.3.6-old/gcc/cppdefault.c gcc-3.3.6/gcc/cppdefault.c
+--- gcc-3.3.6-old/gcc/cppdefault.c	2003-11-07 02:13:31.000000000 +0300
++++ gcc-3.3.6/gcc/cppdefault.c	2016-09-02 16:00:03.492484016 +0300
+@@ -26,6 +26,10 @@
+ #include "system.h"
+ #include "cppdefault.h"
+ 
++#undef LOCAL_INCLUDE_DIR
++#undef SYSTEM_INCLUDE_DIR
++#undef STANDARD_INCLUDE_DIR
++
+ const struct default_include cpp_include_defaults[]
+ #ifdef INCLUDE_DEFAULTS
+ = INCLUDE_DEFAULTS;
+diff -ru3 gcc-3.3.6-old/gcc/gcc.c gcc-3.3.6/gcc/gcc.c
+--- gcc-3.3.6-old/gcc/gcc.c	2004-04-01 20:55:17.000000000 +0400
++++ gcc-3.3.6/gcc/gcc.c	2016-09-02 16:01:24.843520114 +0300
+@@ -6130,10 +6130,6 @@
+ 		      NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
+ 	}
+ 
+-      add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_1,
+-			    "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+-      add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_2,
+-			    "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
+ #if 0 /* Can cause surprises, and one can use -B./ instead.  */
+       add_prefix (&startfile_prefixes, "./", NULL,
+ 		  PREFIX_PRIORITY_LAST, 1, NULL, 0);
+diff -ru3 gcc-3.3.6-old/gcc/Makefile.in gcc-3.3.6/gcc/Makefile.in
+--- gcc-3.3.6-old/gcc/Makefile.in	2004-04-01 20:55:23.000000000 +0400
++++ gcc-3.3.6/gcc/Makefile.in	2016-09-02 16:00:03.493484017 +0300
+@@ -260,7 +260,11 @@
+ PARTITION_H = $(srcdir)/../include/partition.h
+ 
+ # Default native SYSTEM_HEADER_DIR, to be overridden by targets.
+-NATIVE_SYSTEM_HEADER_DIR = /usr/include
++# Nix: we override NATIVE_SYSTEM_HEADER_DIR in order to prevent
++# `fixinc' from fixing header files in /usr/include.  However,
++# NATIVE_SYSTEM_HEADER_DIR must point to an existing directory, so set
++# it to some dummy directory.
++NATIVE_SYSTEM_HEADER_DIR = $(NIX_FIXINC_DUMMY)
+ # Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
+ CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
+ 
+@@ -2201,7 +2205,7 @@
+   -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+   -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_alias)\" \
+   -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+-  -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
++  -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
+   -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
+   -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+   @TARGET_SYSTEM_ROOT_DEFINE@
diff --git a/pkgs/development/libraries/gcc/libstdc++/struct-ucontext.patch b/pkgs/development/libraries/gcc/libstdc++/struct-ucontext.patch
new file mode 100644
index 00000000000..5462e0e33ec
--- /dev/null
+++ b/pkgs/development/libraries/gcc/libstdc++/struct-ucontext.patch
@@ -0,0 +1,61 @@
+diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
+index 3a2940c..67f9899 100644
+--- a/gcc/config/alpha/linux.h
++++ b/gcc/config/alpha/linux.h
+@@ -89,7 +89,7 @@ Boston, MA 02111-1307, USA.  */
+       {									\
+ 	struct rt_sigframe {						\
+ 	  struct siginfo info;						\
+-	  struct ucontext uc;						\
++	  ucontext_t uc;						\
+ 	} *rt_ = (CONTEXT)->cfa;					\
+ 	sc_ = &rt_->uc.uc_mcontext;					\
+       }									\
+diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
+index e86ab3d..30797a7 100644
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -260,7 +260,7 @@ Boston, MA 02111-1307, USA.  */
+ 	  siginfo_t *pinfo;					\
+ 	  void *puc;							\
+ 	  siginfo_t info;						\
+-	  struct ucontext uc;						\
++	  ucontext_t uc;						\
+ 	} *rt_ = (CONTEXT)->cfa;					\
+ 	sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext;		\
+       }									\
+diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
+index fbfaa58..200c8dc 100644
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -112,7 +112,7 @@ Boston, MA 02111-1307, USA.  */
+     if (*(unsigned char *)(pc_+0) == 0x48				\
+ 	&& *(unsigned long *)(pc_+1) == 0x050f0000000fc0c7)		\
+       {									\
+-	struct ucontext *uc_ = (CONTEXT)->cfa;				\
++	ucontext_t *uc_ = (CONTEXT)->cfa;				\
+ 	sc_ = (struct sigcontext *) &uc_->uc_mcontext;			\
+       }									\
+     else								\
+@@ -182,7 +182,7 @@ Boston, MA 02111-1307, USA.  */
+ 	  struct siginfo *pinfo;					\
+ 	  void *puc;							\
+ 	  struct siginfo info;						\
+-	  struct ucontext uc;						\
++	  ucontext_t uc;						\
+ 	} *rt_ = (CONTEXT)->cfa;					\
+ 	sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext;		\
+       }									\
+diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
+index ba70ec1..0fff8b1 100644
+--- a/gcc/config/rs6000/linux.h
++++ b/gcc/config/rs6000/linux.h
+@@ -101,7 +101,7 @@ Boston, MA 02111-1307, USA.  */
+ 
+ struct kernel_old_ucontext {
+   unsigned long     uc_flags;
+-  struct ucontext  *uc_link;
++  ucontext_t       *uc_link;
+   stack_t           uc_stack;
+   struct sigcontext_struct uc_mcontext;
+   sigset_t          uc_sigmask;