1 { lib, stdenv, fetchurl, fetchpatch, flex, bison, file }:
3 stdenv.mkDerivation rec {
9 url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
10 sha256 = "1dpyrpsgakilz2rnh5f8gvrzq5pwzvndacc0df6m04bpqn5fx6sg";
13 url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
14 sha256 = "14lxl81f7adpc9jxfiwzdxsdzs5zv4piv8xh7f9w910hfzrgvsby";
21 name = "siginfo.patch";
22 url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/siginfo.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
23 sha256 = "15zldbm33yba293dgrgsbv3j332hkc3iqpyc8fa7zl42mh9qk22j";
27 name = "gcc-3.4.3-no_multilib_amd64.patch";
28 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";
29 sha256 = "11m5lc51b0addhc4yq4rz0dwpv6k73rrj73wya3lqdk8rly6cjpm";
32 # Required because of glibc 2.26
33 ./struct-ucontext.patch
37 # fix build issue with recent gcc
38 sed -i "s#O_CREAT#O_CREAT, 0666#" gcc/collect2.c
41 sed -i -e 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
47 configureScript=../$sourceRoot/configure
51 # libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
55 # Use *real* header files, otherwise a limits.h is generated
56 # that does not include Glibc's limits.h (notably missing
57 # SSIZE_MAX, which breaks the build).
58 export NIX_FIXINC_DUMMY="$(cat $NIX_CC/nix-support/orig-libc-dev)/include"
60 # The path to the Glibc binaries such as `crti.o'.
61 glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
63 # Figure out what extra flags to pass to the gcc compilers
64 # being generated to make sure that they use our glibc.
65 EXTRA_FLAGS="-I$NIX_FIXINC_DUMMY $(cat $NIX_CC/nix-support/libc-crt1-cflags) $(cat $NIX_CC/nix-support/libc-cflags) -O2"
67 extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $(cat $NIX_BINTOOLS/nix-support/libc-ldflags) $(cat $NIX_BINTOOLS/nix-support/libc-ldflags-before)"
68 for i in $extraLDFlags; do
69 EXTRA_FLAGS="$EXTRA_FLAGS -Wl,$i"
72 # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
74 # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
77 "''${makeFlagsArray[@]}" \
78 NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
79 SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
80 CFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
81 CFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
82 CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
83 CXXFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
84 FLAGS_FOR_TARGET="$EXTRA_FLAGS" \
85 LDFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
86 LDFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
87 BOOT_CFLAGS="$EXTRA_FLAGS" \
88 BOOT_LDFLAGS="$EXTRA_FLAGS"
92 hardeningDisable = [ "format" ];
94 nativeBuildInputs = [ flex bison file ];
96 configureFlags = [ "--disable-multilib" "--enable-__cxa-atexit" "--enable-threads=posix" "--enable-languages=c++" "--enable-clocale=gnu" ];
98 buildFLags = [ "all-target-libstdc++-v3" ];
100 installFlags = [ "install-target-libstdc++-v3" ];
103 # Remove includefiles and libs provided by gcc
105 rm -rf $out/{bin,include,share,man,info}
107 rm -rf $out/lib/!(libstdc++*)
111 homepage = "https://gcc.gnu.org/";
112 license = licenses.lgpl3Plus;
113 description = "GNU Compiler Collection, version ${version} -- C++ standard library";
114 platforms = platforms.linux;
115 maintainers = with maintainers; [ abbradar ];