diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/gcc')
30 files changed, 4392 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix new file mode 100644 index 000000000000..6467cfc801dc --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/4.8/default.nix @@ -0,0 +1,430 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, cloog ? null, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# We enable the isl cloog backend. +assert cloog != null -> isl != null; + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "4.8.5"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = [ ../parallel-bconfig.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ optional hostPlatform.isDarwin ../gfortran-darwin-NXConstStr.patch + ++ [(fetchpatch { + name = "libc_name_p.diff"; # needed to build with gcc6 + url = "https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=ec1cc0263f1"; + sha256 = "01jd7pdarh54ki498g6sz64ijl9a1l5f9v8q2696aaxalvh2vwzl"; + excludes = [ "gcc/cp/ChangeLog" ]; + })] + ++ [ # glibc-2.26 + ../struct-ucontext-4.8.patch + ../sigsegv-not-declared.patch + ../res_state-not-declared.patch + ]; + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = http://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; + sha256 = "08yggr18v373a1ihj0rg2vd6psnic42b518xcgp3r9k81xz1xyr2"; + }; + + inherit patches; + + hardeningDisable = [ "format" "pie" ]; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q LIBC_DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' + done + '' + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (cloog != null) cloog) + ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + optionals (cloog != null) [ + "--with-cloog=${cloog}" + "--disable-cloog-version-check" + "--enable-cloog-backend=isl" + ] ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + hardeningUnsupportedFlags = [ "stackprotector" ]; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix new file mode 100644 index 000000000000..1676668d9111 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/4.9/default.nix @@ -0,0 +1,448 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, cloog ? null, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# We enable the isl cloog backend. +assert cloog != null -> isl != null; + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "4.9.4"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ../use-source-date-epoch.patch ../parallel-bconfig.patch ./parallel-strsignal.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ [ ../struct-ucontext.patch ../struct-sigaltstack-4.9.patch ] # glibc-2.26 + # Retpoline patches pulled from the branch hjl/indirect/gcc-4_9-branch (by H.J. Lu, the author of GCC upstream retpoline commits) + ++ builtins.map ({commit, sha256}: fetchpatch {url = "https://github.com/hjl-tools/gcc/commit/${commit}.patch"; inherit sha256;}) + [{ commit = "e623d21608e96ecd6b65f0d06312117d20488a38"; sha256 = "1ix8i4d2r3ygbv7npmsdj790rhxqrnfwcqzv48b090r9c3ij8ay3"; } + { commit = "2015a09e332309f12de1dadfe179afa6a29368b8"; sha256 = "0xcfs0cbb63llj2gbcdrvxim79ax4k4aswn0a3yjavxsj71s1n91"; } + { commit = "6b11591f4494f705e8746e7d58b7f423191f4e92"; sha256 = "0aydyhsm2ig0khgbp27am7vq7liyqrq6kfhfi2ki0ij0ab1hfbga"; } + { commit = "203c7d9c3e9cb0f88816b481ef8e7e87b3ecc373"; sha256 = "0wqn16y7wy5kg8ngfcni5qdwfphl01axczibbk49bxclwnzvldqa"; } + { commit = "f039c6f284b2c9ce97c8353d6034978795c4872e"; sha256 = "13fkgdb17lpyxfksz1zanxhgpsm0jrss9w61nbl7an4im22hz7ci"; } + { commit = "ed42606bdab1c5d9e5ad828cd6fe1a0557f193b7"; sha256 = "0gdnn8v3p03imj3qga2mzdhpgbmjcklkxdl97jvz5xia2ikzknxm"; } + { commit = "5278e062ef292fd2fbf987d25389785f4c5c0f99"; sha256 = "0j81x758wf8v7j4rx5wc1cy7yhkvhlhv3wmnarwakxiwsspq0vrs"; } + { commit = "76f1ffbbb6cd9f6ecde6c82cd16e20a27242e890"; sha256 = "1py56y6gp7fjf4f8bbsfwh5bs1gnmlqda1ycsmnwlzfm0cshdp0c"; } + { commit = "4ca48b2b688b135c0390f54ea9077ef10aedd52c"; sha256 = "15r019pzr3k0lpgyvdc92c8fayw8b5lrzncna4bqmamcsdz7vsaw"; } + { commit = "98c7bf9ddc80db965d69d61521b1c7a1cec32d9a"; sha256 = "1d7pfdv1q23nf0wadw7jbp6d6r7pnzjpbyxgbdfv7j1vr9l1bp60"; } + { commit = "3dc76b53ad896494ca62550a7a752fecbca3f7a2"; sha256 = "0jvdzfpvfdmklfcjwqblwq1i22iqis7ljpvm7adra5d7zf2xk7xz"; } + { commit = "1e961ed49b18e176c7457f53df2433421387c23b"; sha256 = "04dnqqs4qsvz4g8cq6db5id41kzys7hzhcaycwmc9rpqygs2ajwz"; } + { commit = "e137c72d099f9b3b47f4cc718aa11eab14df1a9c"; sha256 = "1ms0dmz74yf6kwgjfs4d2fhj8y6mcp2n184r3jk44wx2xc24vgb2"; }]; + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = http://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2"; + sha256 = "14l06m7nvcvb0igkbip58x59w3nq6315k6jcz3wr9ch1rn9d44bc"; + }; + + inherit patches; + + hardeningDisable = [ "format" "pie" ]; + + outputs = if langJava || langGo then ["out" "man" "info"] + else [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q LIBC_DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' + done + '' + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (cloog != null) cloog) + ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + sed -i -e "s/-lrt//g" libstdc++-v3/configure + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + '' + + stdenv.lib.optionalString (langJava || langGo) '' + export lib=$out; + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + optionals (cloog != null) [ + "--with-cloog=${cloog}" + "--disable-cloog-version-check" + "--enable-cloog-backend=isl" + ] ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } + +// optionalAttrs (langJava) { + postFixup = '' + target="$(echo "$out/libexec/gcc"/*/*/ecj*)" + patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target" + '';} +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/4.9/parallel-strsignal.patch b/nixpkgs/pkgs/development/compilers/gcc/4.9/parallel-strsignal.patch new file mode 100644 index 000000000000..4c98ca273a54 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/4.9/parallel-strsignal.patch @@ -0,0 +1,61 @@ +gcc/Makefile.in: fix parallel building failure + +The gcc-ar.o, gcc-nm.o, gcc-ranlib.o and errors.o included +config.h which was a generated file. But no explicity rule +to clarify the dependency. There was potential building +failure while parallel make. + +For gcc-ar.o, gcc-nm.o and gcc-ranlib.o, they were compiled from one C +source file gcc-ar.c, we add them to ALL_HOST_BACKEND_OBJS, so the +'$(ALL_HOST_OBJS) : | $(generated_files)' rule could work for these +objects. + +For errors.o, it is part of gengtype, and the gengtype generator program +is special: Two versions are built. One is for the build machine, and one +is for the host. We refered what gengtype-parse.o did (which also is part +of gengtype). + +[GCC #61899] +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61899 + +Upstream-Status: Send to gcc-patches@gcc.gnu.org mailing list + +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> +--- + gcc/Makefile.in | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/gcc/Makefile.in b/gcc/Makefile.in +index 6475cba..56e50bb 100644 +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -1481,13 +1481,16 @@ OBJS-libcommon-target = $(common_out_object_file) prefix.o params.o \ + opts.o opts-common.o options.o vec.o hooks.o common/common-targhooks.o \ + hash-table.o file-find.o + ++# Objects compiled from one C source file gcc-ar.c ++OBJS-gcc-ar = gcc-ar.o gcc-nm.o gcc-ranlib.o ++ + # This lists all host objects for the front ends. + ALL_HOST_FRONTEND_OBJS = $(foreach v,$(CONFIG_LANGUAGES),$($(v)_OBJS)) + + ALL_HOST_BACKEND_OBJS = $(GCC_OBJS) $(OBJS) $(OBJS-libcommon) \ + $(OBJS-libcommon-target) @TREEBROWSER@ main.o c-family/cppspec.o \ + $(COLLECT2_OBJS) $(EXTRA_GCC_OBJS) $(GCOV_OBJS) $(GCOV_DUMP_OBJS) \ +- lto-wrapper.o ++ lto-wrapper.o $(OBJS-gcc-ar) + + # This lists all host object files, whether they are included in this + # compilation or not. +@@ -2437,6 +2440,8 @@ gengtype-parse.o: $(CONFIG_H) + CFLAGS-build/gengtype-parse.o += -DGENERATOR_FILE + build/gengtype-parse.o: $(BCONFIG_H) + ++errors.o : $(CONFIG_H) ++ + gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \ + gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \ + $(XREGEX_H) +-- +1.8.1.2 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/5/default.nix b/nixpkgs/pkgs/development/compilers/gcc/5/default.nix new file mode 100644 index 000000000000..6049cdcb6e8a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/5/default.nix @@ -0,0 +1,447 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "5.5.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ../use-source-date-epoch.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch + ++ optional stdenv.hostPlatform.isMusl (fetchpatch { + url = https://raw.githubusercontent.com/richfelker/musl-cross-make/e84b1bd1fc12a3def33111ca6df522cd6e5ec361/patches/gcc-5.3.0/0001-musl.diff; + sha256 = "0pppbf8myi2kjhm3z3479ihn1cm60kycfv60gj8yy1bs0pl1qcfm"; + }); + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = http://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "11zd1hgzkli3b2v70qsm2hyqppngd4616qc96lmm9zl2kl9yl32k"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/6/default.nix b/nixpkgs/pkgs/development/compilers/gcc/6/default.nix new file mode 100644 index 000000000000..a467527c613e --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/6/default.nix @@ -0,0 +1,455 @@ +{ stdenv, targetPackages, fetchurl, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langJava ? false +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man); required for Java +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null, boehmgc ? null +, zip ? null, unzip ? null, pkgconfig ? null +, gtk2 ? null, libart_lgpl ? null +, libX11 ? null, libXt ? null, libSM ? null, libICE ? null, libXtst ? null +, libXrender ? null, xorgproto ? null +, libXrandr ? null, libXi ? null +, x11Support ? langJava +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +assert langJava -> zip != null && unzip != null + && zlib != null && boehmgc != null + && perl != null; # for `--enable-java-home' + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "6.5.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ../use-source-date-epoch.patch ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch + ; + + javaEcj = fetchurl { + # The `$(top_srcdir)/ecj.jar' file is automatically picked up at + # `configure' time. + + # XXX: Eventually we might want to take it from upstream. + url = "ftp://sourceware.org/pub/java/ecj-4.3.jar"; + sha256 = "0jz7hvc0s6iydmhgh5h2m15yza7p2rlss2vkif30vm9y77m97qcx"; + }; + + # Antlr (optional) allows the Java `gjdoc' tool to be built. We want a + # binary distribution here to allow the whole chain to be bootstrapped. + javaAntlr = fetchurl { + url = http://www.antlr.org/download/antlr-4.4-complete.jar; + sha256 = "02lda2imivsvsis8rnzmbrbp8rh1kb8vmq4i67pqhkwz7lf8y6dz"; + }; + + xlibs = [ + libX11 libXt libSM libICE libXtst libXrender libXrandr libXi + xorgproto + ]; + + javaAwtGtk = langJava && x11Support; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 + "--disable-libmpx" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +# We need all these X libraries when building AWT with GTK+. +assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"; + }; + + inherit patches; + + outputs = if langJava || langGo then ["out" "man" "info"] + else [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else null; + + inherit noSysDirs staticCompiler langJava crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl) + ++ (optional javaAwtGtk pkgconfig); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + ++ (optionals langJava [ boehmgc zip unzip ]) + ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + '' + + stdenv.lib.optionalString (langJava || langGo) '' + export lib=$out; + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + # Java options + optionals langJava [ + "--with-ecj-jar=${javaEcj}" + + # Follow Sun's layout for the convenience of IcedTea/OpenJDK. See + # <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-April/008888.html>. + "--enable-java-home" + "--with-java-home=\${prefix}/lib/jvm/jre" + ] ++ + optional javaAwtGtk "--enable-java-awt=gtk" ++ + optional (langJava && javaAntlr != null) "--with-antlr-jar=${javaAntlr}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] + ++ optional (zlib != null) zlib + ++ optional langJava boehmgc + ++ optionals javaAwtGtk xlibs + ++ optionals javaAwtGtk [ gmp mpfr ] + )); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, Java, and Ada, as well + as libraries for these languages (libstdc++, libgcj, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ peti ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } + +// optionalAttrs (langJava) { + postFixup = '' + target="$(echo "$out/libexec/gcc"/*/*/ecj*)" + patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target" + '';} +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/6/fix-objdump-check.patch b/nixpkgs/pkgs/development/compilers/gcc/6/fix-objdump-check.patch new file mode 100644 index 000000000000..f9adbe9eb1ca --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/6/fix-objdump-check.patch @@ -0,0 +1,43 @@ +commit 4c38abe0967bad78dd6baa61c86923e4d4b346d3 +Author: Ben Gamari <ben@smart-cactus.org> +Date: Sun Nov 5 13:14:19 2017 -0500 + + Fix it + +diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4 +index dd06a58..f4435b8 100644 +--- a/config/gcc-plugin.m4 ++++ b/config/gcc-plugin.m4 +@@ -13,6 +13,32 @@ dnl the same distribution terms as the rest of that program. + # Sets the shell variables enable_plugin and pluginlibs. + AC_DEFUN([GCC_ENABLE_PLUGINS], + [# Check for plugin support ++ ++ # Figure out what objdump we will be using. ++ AS_VAR_SET_IF(gcc_cv_objdump,, [ ++ if test -f $gcc_cv_binutils_srcdir/configure.ac \ ++ && test -f ../binutils/Makefile \ ++ && test x$build = x$host; then ++ # Single tree build which includes binutils. ++ gcc_cv_objdump=../binutils/objdump$build_exeext ++ elif test -x objdump$build_exeext; then ++ gcc_cv_objdump=./objdump$build_exeext ++ elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then ++ gcc_cv_objdump="$OBJDUMP_FOR_TARGET" ++ else ++ AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET) ++ fi]) ++ ++ AC_MSG_CHECKING(what objdump to use) ++ if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then ++ # Single tree build which includes binutils. ++ AC_MSG_RESULT(newly built objdump) ++ elif test x$gcc_cv_objdump = x; then ++ AC_MSG_RESULT(not found) ++ else ++ AC_MSG_RESULT($gcc_cv_objdump) ++ fi ++ + AC_ARG_ENABLE(plugin, + [AS_HELP_STRING([--enable-plugin], [enable plugin support])], + enable_plugin=$enableval, diff --git a/nixpkgs/pkgs/development/compilers/gcc/7/default.nix b/nixpkgs/pkgs/development/compilers/gcc/7/default.nix new file mode 100644 index 000000000000..41af804e551f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/7/default.nix @@ -0,0 +1,400 @@ +{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man) +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "7.4.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ # https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00633.html + ./riscv-pthread-reentrant.patch + # https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00297.html + ./riscv-no-relax.patch + ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied + url = "https://git.busybox.net/buildroot/plain/package/gcc/7.1.0/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02"; + sha256 = "0mrvxsdwip2p3l17dscpc1x8vhdsciqw1z5q9i6p5g9yg1cqnmgs"; + }) + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 + "--disable-libmpx" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + # No final libdecnumber (it may work only in 386) + "--disable-decimal-float" + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "${targetPlatform.config}${stageNameAddon}-" else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +stdenv.mkDerivation ({ + name = crossNameAddon + "${name}${if stripped then "" else "-debug"}-${version}"; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "0lgy170b0pp60j9cczqkmaqyjjb584vfamj4c30swd7k0j6y5pgd"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' + ( + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else "") + + stdenv.lib.optionalString targetPlatform.isAvr '' + makeFlagsArray+=( + 'LIMITS_H_TEST=false' + ) + ''; + + inherit noSysDirs staticCompiler crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (stdenv.cc.isClang && langFortran) "-Wno-unused-command-line-argument"; + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ++ optional (targetPlatform.isAarch64) "--enable-fix-cortex-a53-843419" + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + doCheck = false; # requires a lot of tools, causes a dependency cycle for stdenv + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as + libraries for these languages (libstdc++, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/7/riscv-no-relax.patch b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-no-relax.patch new file mode 100644 index 000000000000..93d9cd1d60f5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-no-relax.patch @@ -0,0 +1,109 @@ +commit e7c570f37384d824cb9725f237920e9691e57269 +gpg: Signature made Tue 06 Mar 2018 04:52:46 PM PST +gpg: using RSA key 00CE76D1834960DFCE886DF8EF4CA1502CCBAB41 +gpg: issuer "palmer@dabbelt.com" +gpg: Good signature from "Palmer Dabbelt <palmer@dabbelt.com>" [ultimate] +gpg: aka "Palmer Dabbelt <palmer@sifive.com>" [ultimate] +Author: Palmer Dabbelt <palmer@sifive.com> +Date: Thu Mar 1 12:01:06 2018 -0800 + + RISC-V: Add and document the "-mno-relax" option + + RISC-V relies on aggressive linker relaxation to get good code size. As + a result no text symbol addresses can be known until link time, which + means that alignment must be handled during the link. This alignment + pass is essentially just another linker relaxation, so this has the + unfortunate side effect that linker relaxation is required for + correctness on many RISC-V targets. + + The RISC-V assembler has supported an ".option norelax" for a long time + because there are situations in which linker relaxation is a bad idea -- + the canonical example is when trying to materialize the initial value of + the global pointer into a register, which would otherwise be relaxed to + a NOP. We've been relying on users who want to disable relaxation for + an entire link to pass "-Wl,--no-relax", but that still relies on the + linker relaxing R_RISCV_ALIGN to handle alignment despite it not being + strictly necessary. + + This patch adds a GCC option, "-mno-relax", that disable linker + relaxation by adding ".option norelax" to the top of every generated + assembly file. The assembler is smart enough to handle alignment at + assemble time for files that have never emitted a relaxable relocation, + so this is sufficient to really disable all relaxations in the linker, + which results in significantly faster link times for large objects. + + This also has the side effect of allowing toolchains that don't support + linker relaxation (LLVM and the Linux module loader) to function + correctly. Toolchains that don't support linker relaxation should + default to "-mno-relax" and error when presented with any R_RISCV_ALIGN + relocation as those need to be handled for correctness. + + gcc/ChangeLog + + 2018-03-01 Palmer Dabbelt <palmer@sifive.com> + + * config/riscv/riscv.opt (mrelax): New option. + * config/riscv/riscv.c (riscv_file_start): Emit ".option + "norelax" when riscv_mrelax is disabled. + * doc/invoke.texi (RISC-V): Document "-mrelax" and "-mno-relax". + +diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c +index c38f6c394d54..3e81874de232 100644 +--- a/gcc/config/riscv/riscv.c ++++ b/gcc/config/riscv/riscv.c +@@ -3979,6 +3979,11 @@ riscv_file_start (void) + + /* Instruct GAS to generate position-[in]dependent code. */ + fprintf (asm_out_file, "\t.option %spic\n", (flag_pic ? "" : "no")); ++ ++ /* If the user specifies "-mno-relax" on the command line then disable linker ++ relaxation in the assembler. */ ++ if (! riscv_mrelax) ++ fprintf (asm_out_file, "\t.option norelax\n"); + } + + /* Implement TARGET_ASM_OUTPUT_MI_THUNK. Generate rtl rather than asm text +diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt +index 581a26bb5c1e..b37ac75d9bb4 100644 +--- a/gcc/config/riscv/riscv.opt ++++ b/gcc/config/riscv/riscv.opt +@@ -106,6 +106,11 @@ mexplicit-relocs + Target Report Mask(EXPLICIT_RELOCS) + Use %reloc() operators, rather than assembly macros, to load addresses. + ++mrelax ++Target Bool Var(riscv_mrelax) Init(1) ++Take advantage of linker relaxations to reduce the number of instructions ++required to materialize symbol addresses. ++ + Mask(64BIT) + + Mask(MUL) +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 8d366c626bae..deb48af2ecad 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -1042,7 +1042,8 @@ See RS/6000 and PowerPC Options. + -msave-restore -mno-save-restore @gol + -mstrict-align -mno-strict-align @gol + -mcmodel=medlow -mcmodel=medany @gol +--mexplicit-relocs -mno-explicit-relocs @gol} ++-mexplicit-relocs -mno-explicit-relocs @gol ++-mrelax -mno-relax @gol} + + @emph{RL78 Options} + @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol +@@ -23102,6 +23103,12 @@ Use or do not use assembler relocation operators when dealing with symbolic + addresses. The alternative is to use assembler macros instead, which may + limit optimization. + ++@item -mrelax ++@itemx -mno-relax ++Take advantage of linker relaxations to reduce the number of instructions ++required to materialize symbol addresses. The default is to take advantage of ++linker relaxations. ++ + @end table + + @node RL78 Options + diff --git a/nixpkgs/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch new file mode 100644 index 000000000000..c7527ffb2b16 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/7/riscv-pthread-reentrant.patch @@ -0,0 +1,13 @@ +Index: gcc/config/riscv/linux.h +=================================================================== +--- a/gcc/config/riscv/linux.h (revision 257620) ++++ b/gcc/config/riscv/linux.h (revision 257621) +@@ -47,6 +47,8 @@ + + #define ICACHE_FLUSH_FUNC "__riscv_flush_icache" + ++#define CPP_SPEC "%{pthread:-D_REENTRANT}" ++ + #define LINK_SPEC "\ + -melf" XLEN_SPEC "lriscv \ + %{shared} \ diff --git a/nixpkgs/pkgs/development/compilers/gcc/8/default.nix b/nixpkgs/pkgs/development/compilers/gcc/8/default.nix new file mode 100644 index 000000000000..80d57c9d538c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/8/default.nix @@ -0,0 +1,378 @@ +{ stdenv, targetPackages, fetchurl, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man) +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, buildPackages +}: + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "8.2.0"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + /* ++ optional (hostPlatform != buildPlatform) (fetchpatch { # XXX: Refine when this should be applied + url = "https://git.busybox.net/buildroot/plain/package/gcc/${version}/0900-remove-selftests.patch?id=11271540bfe6adafbc133caf6b5b902a816f5f02"; + sha256 = ""; # TODO: uncomment and check hash when available. + }) */ + ++ optional langFortran ../gfortran-driving.patch + ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch + ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}${libcCross.incdir or "/include"}") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc" || targetPlatform.libc == "musl") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 + "--disable-libmpx" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +stdenv.mkDerivation ({ + name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "10007smilswiiv2ymazr3b6x2i933c0ycxrr529zh4r6p823qv0r"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + # This should kill all the stdinc frameworks that gcc and friends like to + # insert into default search paths. + prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' + substituteInPlace gcc/config/darwin-c.c \ + --replace 'if (stdinc)' 'if (0)' + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" + + substituteInPlace libgfortran/configure \ + --replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" + ''; + + postPatch = '' + configureScripts=$(find . -name configure) + for configureScript in $configureScripts; do + patchShebangs $configureScript + done + '' + ( + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + ( + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q _DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ + -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' + done + '' + + stdenv.lib.optionalString (targetPlatform.libc == "musl") + '' + sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' + '' + ) + else ""); + + inherit noSysDirs staticCompiler crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if (enableMultilib || targetPlatform.isAvr) + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ++ optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ + "--disable-libsanitizer" + "--disable-symvers" + "libat_cv_have_ifunc=no" + "--disable-gnu-indirect-function" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = optional + (bootstrap && hostPlatform == buildPlatform) + (if profiledCompiler then "profiledbootstrap" else "bootstrap"); + + dontStrip = !stripped; + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); + + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as + libraries for these languages (libstdc++, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ synthetica ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/builder.sh b/nixpkgs/pkgs/development/compilers/gcc/builder.sh new file mode 100644 index 000000000000..07a003691d6b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/builder.sh @@ -0,0 +1,289 @@ +source $stdenv/setup + + +oldOpts="$(shopt -po nounset)" || true +set -euo pipefail + + +export NIX_FIXINC_DUMMY="$NIX_BUILD_TOP/dummy" +mkdir "$NIX_FIXINC_DUMMY" + + +if test "$staticCompiler" = "1"; then + EXTRA_LDFLAGS="-static" +else + EXTRA_LDFLAGS="-Wl,-rpath,${!outputLib}/lib" +fi + + +# GCC interprets empty paths as ".", which we don't want. +if test -z "${CPATH-}"; then unset CPATH; fi +if test -z "${LIBRARY_PATH-}"; then unset LIBRARY_PATH; fi +echo "\$CPATH is \`${CPATH-}'" +echo "\$LIBRARY_PATH is \`${LIBRARY_PATH-}'" + +if test "$noSysDirs" = "1"; then + + declare \ + EXTRA_BUILD_FLAGS EXTRA_FLAGS EXTRA_TARGET_FLAGS \ + EXTRA_BUILD_LDFLAGS EXTRA_TARGET_LDFLAGS + + # Extract flags from Bintools Wrappers + for pre in 'BUILD_' ''; do + curBintools="NIX_${pre}BINTOOLS" + + declare -a extraLDFlags=() + if [[ -e "${!curBintools}/nix-support/orig-libc" ]]; then + # Figure out what extra flags when linking to pass to the gcc + # compilers being generated to make sure that they use our libc. + extraLDFlags=($(< "${!curBintools}/nix-support/libc-ldflags") $(< "${!curBintools}/nix-support/libc-ldflags-before" || true)) + + # The path to the Libc binaries such as `crti.o'. + libc_libdir="$(< "${!curBintools}/nix-support/orig-libc")/lib" + else + # Hack: support impure environments. + extraLDFlags=("-L/usr/lib64" "-L/usr/lib") + libc_libdir="/usr/lib" + fi + extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" + "${extraLDFlags[@]}") + for i in "${extraLDFlags[@]}"; do + declare EXTRA_${pre}LDFLAGS+=" -Wl,$i" + done + done + + # Extract flags from CC Wrappers + for pre in 'BUILD_' ''; do + curCC="NIX_${pre}CC" + curFIXINC="NIX_${pre}FIXINC_DUMMY" + + declare -a extraFlags=() + if [[ -e "${!curCC}/nix-support/orig-libc" ]]; then + # Figure out what extra compiling flags to pass to the gcc compilers + # being generated to make sure that they use our libc. + extraFlags=($(< "${!curCC}/nix-support/libc-cflags")) + + # The path to the Libc headers + libc_devdir="$(< "${!curCC}/nix-support/orig-libc-dev")" + + # Use *real* header files, otherwise a limits.h is generated that + # does not include Libc's limits.h (notably missing SSIZE_MAX, + # which breaks the build). + declare NIX_${pre}FIXINC_DUMMY="$libc_devdir/include" + else + # Hack: support impure environments. + extraFlags=("-isystem" "/usr/include") + declare NIX_${pre}FIXINC_DUMMY=/usr/include + fi + + extraFlags=("-I${!curFIXINC}" "${extraFlags[@]}") + + # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, make + # sure to explictly add them so that files compiled with the bootstrap + # compiler are optimized and (optionally) contain debugging information + # (info "(gccinstall) Building"). + if test -n "${dontStrip-}"; then + extraFlags=("-O2" "-g" "${extraFlags[@]}") + else + # Don't pass `-g' at all; this saves space while building. + extraFlags=("-O2" "${extraFlags[@]}") + fi + + declare EXTRA_${pre}FLAGS="${extraFlags[*]}" + done + + if test -z "${targetConfig-}"; then + # host = target, so the flags are the same + EXTRA_TARGET_FLAGS="$EXTRA_FLAGS" + EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" + fi + + # 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+=( + "BUILD_SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" + "SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" + "NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY" + + "LDFLAGS_FOR_BUILD=$EXTRA_BUILD_LDFLAGS" + #"LDFLAGS=$EXTRA_LDFLAGS" + "LDFLAGS_FOR_TARGET=$EXTRA_TARGET_LDFLAGS" + + "CFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + "CXXFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + "FLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + + # It seems there is a bug in GCC 5 + #"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + #"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + + "CFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + "CXXFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + "FLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + ) + + if test -z "${targetConfig-}"; then + makeFlagsArray+=( + "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + "BOOT_LDFLAGS=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + ) + fi + + if test "$crossStageStatic" == 1; then + # We don't want the gcc build to assume there will be a libc providing + # limits.h in this stagae + makeFlagsArray+=( + 'LIMITS_H_TEST=false' + ) + else + makeFlagsArray+=( + 'LIMITS_H_TEST=true' + ) + fi +fi + +if test -n "${targetConfig-}"; then + # The host strip will destroy some important details of the objects + dontStrip=1 +fi + +eval "$oldOpts" + +providedPreConfigure="$preConfigure"; +preConfigure() { + if test -n "$newlibSrc"; then + tar xvf "$newlibSrc" -C .. + ln -s ../newlib-*/newlib newlib + # Patch to get armvt5el working: + sed -i -e 's/ arm)/ arm*)/' newlib/configure.host + fi + + # Bug - they packaged zlib + if test -d "zlib"; then + # This breaks the build without-headers, which should build only + # the target libgcc as target libraries. + # See 'configure:5370' + rm -Rf zlib + fi + + if test -f "$NIX_CC/nix-support/orig-libc"; then + # Patch the configure script so it finds glibc headers. It's + # important for example in order not to get libssp built, + # because its functionality is in glibc already. + sed -i \ + -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$libc_dev/include", \ + gcc/configure + fi + + if test -n "$crossMingw" -a -n "$crossStageStatic"; then + mkdir -p ../mingw + # --with-build-sysroot expects that: + cp -R $libcCross/include ../mingw + configureFlags="$configureFlags --with-build-sysroot=`pwd`/.." + fi + + # Eval the preConfigure script from nix expression. + eval "$providedPreConfigure" + + # Perform the build in a different directory. + mkdir ../build + cd ../build + configureScript=../$sourceRoot/configure +} + + +postConfigure() { + # Don't store the configure flags in the resulting executables. + sed -e '/TOPLEVEL_CONFIGURE_ARGUMENTS=/d' -i Makefile +} + + +preInstall() { + # Make ‘lib64’ symlinks to ‘lib’. + if [ -n "$is64bit" -a -z "$enableMultilib" ]; then + mkdir -p "$out/lib" + ln -s lib "$out/lib64" + mkdir -p "$lib/lib" + ln -s lib "$lib/lib64" + fi +} + + +postInstall() { + # Move runtime libraries to $lib. + moveToOutput "lib/lib*.so*" "$lib" + moveToOutput "lib/lib*.la" "$lib" + moveToOutput "lib/lib*.dylib" "$lib" + moveToOutput "share/gcc-*/python" "$lib" + + for i in "$lib"/lib/*.{la,py}; do + substituteInPlace "$i" --replace "$out" "$lib" + done + + if [ -n "$enableMultilib" ]; then + moveToOutput "lib64/lib*.so*" "$lib" + moveToOutput "lib64/lib*.la" "$lib" + moveToOutput "lib64/lib*.dylib" "$lib" + + for i in "$lib"/lib64/*.{la,py}; do + substituteInPlace "$i" --replace "$out" "$lib" + done + fi + + # Remove `fixincl' to prevent a retained dependency on the + # previous gcc. + rm -rf $out/libexec/gcc/*/*/install-tools + rm -rf $out/lib/gcc/*/*/install-tools + + # More dependencies with the previous gcc or some libs (gccbug stores the build command line) + rm -rf $out/bin/gccbug + + if type "patchelf"; then + # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out + for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do + PREV_RPATH=`patchelf --print-rpath "$i"` + NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'` + patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK + done + + # For some reason the libs retain RPATH to $out + for i in "$lib"/lib/{libtsan,libasan,libubsan}.so.*.*.*; do + PREV_RPATH=`patchelf --print-rpath "$i"` + NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"` + patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK + done + fi + + if type "install_name_tool"; then + for i in "$lib"/lib/*.*.dylib; do + install_name_tool -id "$i" "$i" || true + for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do + new_path=`echo "$old_path" | sed "s,$out,$lib,"` + install_name_tool -change "$old_path" "$new_path" "$i" || true + done + done + fi + + # Get rid of some "fixed" header files + rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux} + + # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks. + for i in $out/bin/*-gcc*; do + if cmp -s $out/bin/gcc $i; then + ln -sfn gcc $i + fi + done + + for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do + if cmp -s $out/bin/g++ $i; then + ln -sfn g++ $i + fi + done + + # Two identical man pages are shipped (moving and compressing is done later) + ln -sf gcc.1 "$out"/share/man/man1/g++.1 +} + +genericBuild diff --git a/nixpkgs/pkgs/development/compilers/gcc/common/platform-flags.nix b/nixpkgs/pkgs/development/compilers/gcc/common/platform-flags.nix new file mode 100644 index 000000000000..ba6d5912fe88 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/common/platform-flags.nix @@ -0,0 +1,16 @@ +{ lib, targetPlatform }: + +let + p = targetPlatform.platform.gcc or {} + // targetPlatform.parsed.abi; +in lib.concatLists [ + (lib.optional (p ? arch) "--with-arch=${p.arch}") + (lib.optional (p ? cpu) "--with-cpu=${p.cpu}") + (lib.optional (p ? abi) "--with-abi=${p.abi}") + (lib.optional (p ? fpu) "--with-fpu=${p.fpu}") + (lib.optional (p ? float) "--with-float=${p.float}") + (lib.optional (p ? mode) "--with-mode=${p.mode}") + (lib.optional + (let tp = targetPlatform; in tp.isPower && tp.libc == "glibc" && tp.is64bit && tp.isLittleEndian) + "--with-long-double-128") +] diff --git a/nixpkgs/pkgs/development/compilers/gcc/gfortran-darwin-NXConstStr.patch b/nixpkgs/pkgs/development/compilers/gcc/gfortran-darwin-NXConstStr.patch new file mode 100644 index 000000000000..a7e158ca364b --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/gfortran-darwin-NXConstStr.patch @@ -0,0 +1,27 @@ +From 82f81877458ea372176eabb5de36329431dce99b Mon Sep 17 00:00:00 2001 +From: Iain Sandoe <iain@codesourcery.com> +Date: Sat, 21 Dec 2013 00:30:18 +0000 +Subject: [PATCH] don't try to mark local symbols as no-dead-strip + +--- + gcc/config/darwin.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c +index 40804b8..0080299 100644 +--- a/gcc/config/darwin.c ++++ b/gcc/config/darwin.c +@@ -1259,6 +1259,11 @@ darwin_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED) + void + darwin_mark_decl_preserved (const char *name) + { ++ /* Actually we shouldn't mark any local symbol this way, but for now ++ this only happens with ObjC meta-data. */ ++ if (darwin_label_is_anonymous_local_objc_name (name)) ++ return; ++ + fprintf (asm_out_file, "\t.no_dead_strip "); + assemble_name (asm_out_file, name); + fputc ('\n', asm_out_file); +-- +2.2.1 diff --git a/nixpkgs/pkgs/development/compilers/gcc/gfortran-driving.patch b/nixpkgs/pkgs/development/compilers/gcc/gfortran-driving.patch new file mode 100644 index 000000000000..70708886b405 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/gfortran-driving.patch @@ -0,0 +1,20 @@ +This patch fixes interaction with Libtool. +See <http://thread.gmane.org/gmane.comp.gcc.patches/258777>, for details. + +--- a/gcc/fortran/gfortranspec.c ++++ b/gcc/fortran/gfortranspec.c +@@ -461,8 +461,15 @@ For more information about these matters, see the file named COPYING\n\n")); + { + fprintf (stderr, _("Driving:")); + for (i = 0; i < g77_newargc; i++) ++ { ++ if (g77_new_decoded_options[i].opt_index == OPT_l) ++ /* Make sure no white space is inserted after `-l'. */ ++ fprintf (stderr, " -l%s", ++ g77_new_decoded_options[i].canonical_option[1]); ++ else + fprintf (stderr, " %s", + g77_new_decoded_options[i].orig_option_with_args_text); ++ } + fprintf (stderr, "\n"); + } diff --git a/nixpkgs/pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch b/nixpkgs/pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch new file mode 100644 index 000000000000..afd1f7456d32 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/libgomp-dont-force-initial-exec.patch @@ -0,0 +1,40 @@ +From 01c433f4788441c0963005b9d3fad5b2865e6651 Mon Sep 17 00:00:00 2001 +From: Will Dietz <w@wdtz.org> +Date: Mon, 24 Sep 2018 19:57:50 -0500 +Subject: [PATCH] libgomp/configure.tgt: don't force initial-exec tls-model + +--- + libgomp/configure.tgt | 17 ----------------- + 1 file changed, 17 deletions(-) + +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt +index 74d95a570c7..b608c55f0c1 100644 +--- a/libgomp/configure.tgt ++++ b/libgomp/configure.tgt +@@ -10,23 +10,6 @@ + # XCFLAGS Add extra compile flags to use. + # XLDFLAGS Add extra link flags to use. + +-# Optimize TLS usage by avoiding the overhead of dynamic allocation. +-if test $gcc_cv_have_tls = yes ; then +- case "${target}" in +- +- *-*-k*bsd*-gnu*) +- ;; +- +- *-*-linux* | *-*-gnu*) +- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" +- ;; +- +- *-*-rtems*) +- XCFLAGS="${XCFLAGS} -ftls-model=local-exec" +- ;; +- esac +-fi +- + # Since we require POSIX threads, assume a POSIX system by default. + config_path="posix" + +-- +2.19.0 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/libstdc++-hook.sh b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-hook.sh new file mode 100644 index 000000000000..19db70597ce5 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-hook.sh @@ -0,0 +1,4 @@ +# See pkgs/build-support/setup-hooks/role.bash +getHostRole + +export NIX_${role_pre}CXXSTDLIB_COMPILE+=" -isystem $(echo -n @gcc@/include/c++/*) -isystem $(echo -n @gcc@/include/c++/*)/$(@gcc@/bin/gcc -dumpmachine)" diff --git a/nixpkgs/pkgs/development/compilers/gcc/libstdc++-target.patch b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-target.patch new file mode 100644 index 000000000000..fb622b395806 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/libstdc++-target.patch @@ -0,0 +1,32 @@ +Patch to make the target libraries 'configure' scripts find the proper CPP. +I noticed that building the mingw32 cross compiler. +Looking at the build script for mingw in archlinux, I think that only nixos +needs this patch. I don't know why. +diff --git a/Makefile.in b/Makefile.in +index 93f66b6..d691917 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \ + AR="$(AR_FOR_TARGET)"; export AR; \ + AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \ + CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \ ++ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \ + CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \ + CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ + CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \ +@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \ + RAW_CXX_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ + CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \ +- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; ++ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ ++ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; + + NORMAL_TARGET_EXPORTS = \ + $(BASE_TARGET_EXPORTS) \ +- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; ++ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \ ++ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX; + + # Where to find GMP + HOST_GMPLIBS = @gmplibs@ diff --git a/nixpkgs/pkgs/development/compilers/gcc/no-sys-dirs.patch b/nixpkgs/pkgs/development/compilers/gcc/no-sys-dirs.patch new file mode 100644 index 000000000000..36df51904acf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/no-sys-dirs.patch @@ -0,0 +1,28 @@ +diff -ru -x '*~' gcc-4.8.3-orig/gcc/cppdefault.c gcc-4.8.3/gcc/cppdefault.c +--- gcc-4.8.3-orig/gcc/cppdefault.c 2013-01-10 21:38:27.000000000 +0100 ++++ gcc-4.8.3/gcc/cppdefault.c 2014-08-18 16:20:32.893944536 +0200 +@@ -35,6 +35,8 @@ + # undef CROSS_INCLUDE_DIR + #endif + ++#undef LOCAL_INCLUDE_DIR ++ + const struct default_include cpp_include_defaults[] + #ifdef INCLUDE_DEFAULTS + = INCLUDE_DEFAULTS; +diff -ru -x '*~' gcc-4.8.3-orig/gcc/gcc.c gcc-4.8.3/gcc/gcc.c +--- gcc-4.8.3-orig/gcc/gcc.c 2014-03-23 12:30:57.000000000 +0100 ++++ gcc-4.8.3/gcc/gcc.c 2014-08-18 13:19:32.689201690 +0200 +@@ -1162,10 +1162,10 @@ + /* Default prefixes to attach to command names. */ + + #ifndef STANDARD_STARTFILE_PREFIX_1 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib/" ++#define STANDARD_STARTFILE_PREFIX_1 "" + #endif + #ifndef STANDARD_STARTFILE_PREFIX_2 +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" ++#define STANDARD_STARTFILE_PREFIX_2 "" + #endif + + #ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */ diff --git a/nixpkgs/pkgs/development/compilers/gcc/parallel-bconfig.patch b/nixpkgs/pkgs/development/compilers/gcc/parallel-bconfig.patch new file mode 100644 index 000000000000..bc56ac698f5a --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/parallel-bconfig.patch @@ -0,0 +1,32 @@ +Hacky work-around for highly parallel builds. +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57125 + +diff --git a/gcc/Makefile.in b/gcc/Makefile.in +index aad927c..182f666 100644 +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -3908,21 +3908,21 @@ build/gengtype-lex.o: $(BCONFIG_H) + + gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \ + $(SYSTEM_H) +-gengtype-parse.o: $(CONFIG_H) ++gengtype-parse.o: $(CONFIG_H) $(BCONFIG_H) + CFLAGS-gengtype-parse.o += -DGENERATOR_FILE + build/gengtype-parse.o: $(BCONFIG_H) + + gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \ + gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \ + $(XREGEX_H) +-gengtype-state.o: $(CONFIG_H) ++gengtype-state.o: $(CONFIG_H) $(BCONFIG_H) + CFLAGS-gengtype-state.o += -DGENERATOR_FILE + build/gengtype-state.o: $(BCONFIG_H) + + gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h \ + rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \ + $(OBSTACK_H) $(XREGEX_H) +-gengtype.o: $(CONFIG_H) ++gengtype.o: $(CONFIG_H) $(BCONFIG_H) + CFLAGS-gengtype.o += -DGENERATOR_FILE + build/gengtype.o: $(BCONFIG_H) + diff --git a/nixpkgs/pkgs/development/compilers/gcc/ppc-musl.patch b/nixpkgs/pkgs/development/compilers/gcc/ppc-musl.patch new file mode 100644 index 000000000000..bc90888a3797 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/ppc-musl.patch @@ -0,0 +1,18 @@ +diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h +index cbee89140dd..e1f26b0a096 100644 +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -996,13 +996,7 @@ ncrtn.o%s" + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, + +-#ifdef LOCAL_INCLUDE_DIR +-#define INCLUDE_DEFAULTS_MUSL_LOCAL \ +- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ +- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, +-#else + #define INCLUDE_DEFAULTS_MUSL_LOCAL +-#endif + + #ifdef PREFIX_INCLUDE_DIR + #define INCLUDE_DEFAULTS_MUSL_PREFIX \ diff --git a/nixpkgs/pkgs/development/compilers/gcc/res_state-not-declared.patch b/nixpkgs/pkgs/development/compilers/gcc/res_state-not-declared.patch new file mode 100644 index 000000000000..e970487786d0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/res_state-not-declared.patch @@ -0,0 +1,13 @@ +diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc +index fe69430..49f5270 100644 +--- a/libsanitizer/tsan/tsan_platform_linux.cc ++++ b/libsanitizer/tsan/tsan_platform_linux.cc +@@ -351,7 +351,7 @@ bool IsGlobalVar(uptr addr) { + // closes within glibc. The code is a pure hack. + int ExtractResolvFDs(void *state, int *fds, int nfd) { + int cnt = 0; +- __res_state *statp = (__res_state*)state; ++ struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { + if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) + fds[cnt++] = statp->_u._ext.nssocks[i]; diff --git a/nixpkgs/pkgs/development/compilers/gcc/sigsegv-not-declared.patch b/nixpkgs/pkgs/development/compilers/gcc/sigsegv-not-declared.patch new file mode 100644 index 000000000000..f9cfaec82026 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/sigsegv-not-declared.patch @@ -0,0 +1,13 @@ +error: 'SIGSEGV' was not declared in this scope +diff --git a/libsanitizer/asan/asan_linux.cc b/libsanitizer/asan/asan_linux.cc +index 0692eb1..472f734 100644 +--- a/libsanitizer/asan/asan_linux.cc ++++ b/libsanitizer/asan/asan_linux.cc +@@ -26,6 +26,7 @@ + #include <sys/types.h> + #include <fcntl.h> + #include <pthread.h> ++#include <signal.h> + #include <stdio.h> + #include <unistd.h> + #include <unwind.h> diff --git a/nixpkgs/pkgs/development/compilers/gcc/snapshot/default.nix b/nixpkgs/pkgs/development/compilers/gcc/snapshot/default.nix new file mode 100644 index 000000000000..a07f6f1feb2f --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/snapshot/default.nix @@ -0,0 +1,352 @@ +{ stdenv, targetPackages, fetchurl, noSysDirs +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? stdenv.targetPlatform.isDarwin +, langObjCpp ? stdenv.targetPlatform.isDarwin +, langGo ? false +, profiledCompiler ? false +, staticCompiler ? false +, enableShared ? true +, texinfo ? null +, perl ? null # optional, for texi2pod (then pod2man) +, gmp, mpfr, libmpc, gettext, which +, libelf # optional, for link-time optimizations (LTO) +, isl ? null # optional, for the Graphite optimization framework. +, zlib ? null +, enableMultilib ? false +, enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins +, name ? "gcc" +, libcCross ? null +, crossStageStatic ? false +, # Strip kills static libs of other archs (hence no cross) + stripped ? stdenv.hostPlatform == stdenv.buildPlatform + && stdenv.targetPlatform == stdenv.hostPlatform +, gnused ? null +, cloog # unused; just for compat with gcc4, as we override the parameter on some places +, flex ? null +, buildPackages +}: + +# LTO needs libelf and zlib. +assert libelf != null -> zlib != null; + +# Make sure we get GNU sed. +assert stdenv.hostPlatform.isDarwin -> gnused != null; + +# The go frontend is written in c++ +assert langGo -> langCC; + +with stdenv.lib; +with builtins; + +let version = "7-20170409"; + + inherit (stdenv) buildPlatform hostPlatform targetPlatform; + + patches = + [ ] + ++ optional (targetPlatform != hostPlatform) ../libstdc++-target.patch + ++ optional noSysDirs ../no-sys-dirs.patch + ++ optional langFortran ../gfortran-driving.patch; + + /* Cross-gcc settings (build == host != target) */ + crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; + crossDarwin = targetPlatform != hostPlatform && targetPlatform.libc == "libSystem"; + crossConfigureFlags = + # Ensure that -print-prog-name is able to find the correct programs. + [ "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] ++ + (if crossMingw && crossStageStatic then [ + "--with-headers=${libcCross}/include" + "--with-gcc" + "--with-gnu-as" + "--with-gnu-ld" + "--with-gnu-ld" + "--disable-shared" + "--disable-nls" + "--disable-debug" + "--enable-sjlj-exceptions" + "--enable-threads=win32" + "--disable-win32-registry" + "--disable-libmpx" # requires libc + ] else if crossStageStatic then [ + "--disable-libssp" + "--disable-nls" + "--without-headers" + "--disable-threads" + "--disable-libgomp" + "--disable-libquadmath" + "--disable-shared" + "--disable-libatomic" # requires libc + "--disable-decimal-float" # requires libc + "--disable-libmpx" # requires libc + ] else [ + (if crossDarwin then "--with-sysroot=${getLib libcCross}/share/sysroot" + else "--with-headers=${getDev libcCross}/include") + "--enable-__cxa_atexit" + "--enable-long-long" + ] ++ + (if crossMingw then [ + "--enable-threads=win32" + "--enable-sjlj-exceptions" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + "--with-dwarf2" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] else + optionals (targetPlatform.libc == "uclibc") [ + # libsanitizer requires netrom/netrom.h which is not + # available in uclibc. + "--disable-libsanitizer" + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + "--disable-libgomp" + ] + ++ optional (targetPlatform.libc == "newlib") "--with-newlib" + ++ optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" + ++ [ + "--enable-threads=${if targetPlatform.isUnix then "posix" + else if targetPlatform.isWindows then "win32" + else "single"}" + "--enable-nls" + "--disable-decimal-float" # No final libdecnumber (it may work only in 386) + ])); + stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; + crossNameAddon = if targetPlatform != hostPlatform then "-${targetPlatform.config}" + stageNameAddon else ""; + + bootstrap = targetPlatform == hostPlatform; + +in + +stdenv.mkDerivation ({ + name = "${name}${if stripped then "" else "-debug"}-${version}" + crossNameAddon; + + builder = ../builder.sh; + + src = fetchurl { + url = "mirror://gcc/snapshots/${version}/gcc-${version}.tar.bz2"; + sha256 = "19197rw1xrpkb8h10lfgn6zj7yj52x95hdmr0x5lg8i4v3i23b67"; + }; + + inherit patches; + + outputs = [ "out" "lib" "man" "info" ]; + setOutputFlags = false; + NIX_NO_SELF_RPATH = true; + + libc_dev = stdenv.cc.libc_dev; + + hardeningDisable = [ "format" "pie" ]; + + postPatch = + if targetPlatform != hostPlatform || stdenv.cc.libc != null then + # On NixOS, use the right path to the dynamic linker instead of + # `/lib/ld*.so'. + let + libc = if libcCross != null then libcCross else stdenv.cc.libc; + in + '' echo "fixing the \`GLIBC_DYNAMIC_LINKER' and \`UCLIBC_DYNAMIC_LINKER' macros..." + for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h + do + grep -q LIBC_DYNAMIC_LINKER "$header" || continue + echo " fixing \`$header'..." + sed -i "$header" \ + -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' + done + '' + else null; + + inherit noSysDirs staticCompiler crossStageStatic + libcCross crossMingw; + + depsBuildBuild = [ buildPackages.stdenv.cc ]; + nativeBuildInputs = [ texinfo which gettext ] + ++ (optional (perl != null) perl); + + # For building runtime libs + depsBuildTarget = + if hostPlatform == buildPlatform then [ + targetPackages.stdenv.cc.bintools # newly-built gcc will be used + ] else assert targetPlatform == hostPlatform; [ # build != host == target + stdenv.cc + ]; + + buildInputs = [ + gmp mpfr libmpc libelf flex + targetPackages.stdenv.cc.bintools # For linking code at run-time + ] ++ (optional (isl != null) isl) + ++ (optional (zlib != null) zlib) + # The builder relies on GNU sed (for instance, Darwin's `sed' fails with + # "-i may not be used with stdin"), and `stdenvNative' doesn't provide it. + ++ (optional hostPlatform.isDarwin gnused) + ; + + NIX_LDFLAGS = stdenv.lib.optionalString hostPlatform.isSunOS "-lm -ldl"; + + preConfigure = stdenv.lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' + export NIX_LDFLAGS=`echo $NIX_LDFLAGS | sed -e s~$prefix/lib~$prefix/lib/amd64~g` + export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" + export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" + export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" + ''; + + dontDisableStatic = true; + + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + + configureFlags = + # Basic dependencies + [ + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + ] ++ + optional (libelf != null) "--with-libelf=${libelf}" ++ + optional (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include" ++ + + # Basic configuration + [ + "--enable-lto" + "--disable-libstdcxx-pch" + "--without-included-gettext" + "--with-system-zlib" + "--enable-static" + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ++ optionals crossDarwin [ "objc" "obj-c++" ] + ) + ) + }" + ] ++ + + (if enableMultilib + then ["--enable-multilib" "--disable-libquadmath"] + else ["--disable-multilib"]) ++ + optional (!enableShared) "--disable-shared" ++ + (if enablePlugin + then ["--enable-plugin"] + else ["--disable-plugin"]) ++ + + # Optional features + optional (isl != null) "--with-isl=${isl}" ++ + + + (import ../common/platform-flags.nix { inherit (stdenv) lib targetPlatform; }) ++ + optional (targetPlatform != hostPlatform) crossConfigureFlags ++ + optional (!bootstrap) "--disable-bootstrap" ++ + + # Platform-specific flags + optional (targetPlatform == hostPlatform && targetPlatform.isi686) "--with-arch=i686" ++ + optionals hostPlatform.isSunOS [ + "--enable-long-long" "--enable-libssp" "--enable-threads=posix" "--disable-nls" "--enable-__cxa_atexit" + # On Illumos/Solaris GNU as is preferred + "--with-gnu-as" "--without-gnu-ld" + ] + ; + + targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; + + buildFlags = if bootstrap then + (if profiledCompiler then "profiledbootstrap" else "bootstrap") + else ""; + + dontStrip = !stripped; + NIX_STRIP_DEBUG = !stripped; + + installTargets = + if stripped + then "install-strip" + else "install"; + + # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 + ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; + + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. + + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] + ++ optional (zlib != null) zlib + )); + + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); + + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}${libcCross.incdir or "/include"}" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ]); + + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}${libcCross.libdir or "/lib"}" + ] ++ (if crossStageStatic then [ + "-B${libcCross.out}${libcCross.libdir or "/lib"}" + ] else [ + "-Wl,-rpath,${libcCross.out}${libcCross.libdir or "/lib"}" + "-Wl,-rpath-link,${libcCross.out}${libcCross.libdir or "/lib"}" + ])); + + passthru = { + inherit langC langCC langObjC langObjCpp langFortran langGo version; + isGNU = true; + }; + + enableParallelBuilding = true; + inherit enableMultilib; + + inherit (stdenv) is64bit; + + meta = { + homepage = https://gcc.gnu.org/; + license = stdenv.lib.licenses.gpl3Plus; # runtime support libraries are typically LGPLv3+ + description = "GNU Compiler Collection, version ${version}" + + (if stripped then "" else " (with debugging info)"); + + longDescription = '' + The GNU Compiler Collection includes compiler front ends for C, C++, + Objective-C, Fortran, OpenMP for C/C++/Fortran, and Ada, as well as + libraries for these languages (libstdc++, libgomp,...). + + GCC development is a part of the GNU Project, aiming to improve the + compiler used in the GNU system including the GNU/Linux variant. + ''; + + maintainers = with stdenv.lib.maintainers; [ ]; + + platforms = + stdenv.lib.platforms.linux ++ + stdenv.lib.platforms.freebsd ++ + stdenv.lib.platforms.illumos ++ + stdenv.lib.platforms.darwin; + + broken = true; + }; +} + +// optionalAttrs (targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt" && crossStageStatic) { + makeFlags = [ "all-gcc" "all-target-libgcc" ]; + installTargets = "install-gcc install-target-libgcc"; +} + +// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } +) diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack-4.9.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack-4.9.patch new file mode 100644 index 000000000000..fc126b4813d6 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack-4.9.patch @@ -0,0 +1,78 @@ +hand-resolved trivial conflicts for 4.9 from the upstream patch +72edc2c02f8b4768ad660f46a1c7e2400c0a8e06 +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc +index 69c9c10..8e53673 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc +@@ -599,8 +599,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) { + return internal_syscall(__NR_prctl, option, arg2, arg3, arg4, arg5); + } + +-uptr internal_sigaltstack(const struct sigaltstack *ss, +- struct sigaltstack *oss) { ++uptr internal_sigaltstack(const void *ss, void *oss) { + return internal_syscall(__NR_sigaltstack, (uptr)ss, (uptr)oss); + } + +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.h b/libsanitizer/sanitizer_common/sanitizer_linux.h +index 6422df1..8e111d1 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.h ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.h +@@ -18,7 +18,6 @@ + #include "sanitizer_platform_limits_posix.h" + + struct link_map; // Opaque type returned by dlopen(). +-struct sigaltstack; + + namespace __sanitizer { + // Dirent structure for getdents(). Note that this structure is different from +@@ -28,8 +27,7 @@ struct linux_dirent; + // Syscall wrappers. + uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); + uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5); +-uptr internal_sigaltstack(const struct sigaltstack* ss, +- struct sigaltstack* oss); ++uptr internal_sigaltstack(const void* ss, void* oss); + uptr internal_sigaction(int signum, const __sanitizer_kernel_sigaction_t *act, + __sanitizer_kernel_sigaction_t *oldact); + uptr internal_sigprocmask(int how, __sanitizer_kernel_sigset_t *set, +diff --git a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +index 891386dc..234e8c6 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +@@ -273,7 +273,7 @@ static int TracerThread(void* argument) { + + // Alternate stack for signal handling. + InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize); +- struct sigaltstack handler_stack; ++ stack_t handler_stack; + internal_memset(&handler_stack, 0, sizeof(handler_stack)); + handler_stack.ss_sp = handler_stack_memory.data(); + handler_stack.ss_size = kHandlerStackSize; +diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc +index 2ed5718..6f972ab 100644 +--- a/libsanitizer/tsan/tsan_platform_linux.cc ++++ b/libsanitizer/tsan/tsan_platform_linux.cc +@@ -287,7 +287,7 @@ void InitializePlatform() { + int ExtractResolvFDs(void *state, int *fds, int nfd) { + #if SANITIZER_LINUX && !SANITIZER_ANDROID + int cnt = 0; +- __res_state *statp = (__res_state*)state; ++ struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { + if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) + fds[cnt++] = statp->_u._ext.nssocks[i]; + +error: 'SIGSEGV' was not declared in this scope +diff --git a/libsanitizer/asan/asan_linux.cc b/libsanitizer/asan/asan_linux.cc +index 0692eb1..472f734 100644 +--- a/libsanitizer/asan/asan_linux.cc ++++ b/libsanitizer/asan/asan_linux.cc +@@ -26,6 +26,7 @@ + #include <sys/types.h> + #include <fcntl.h> + #include <pthread.h> ++#include <signal.h> + #include <stdio.h> + #include <unistd.h> + #include <unwind.h> diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack.patch new file mode 100644 index 000000000000..6e1ddb252c24 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-sigaltstack.patch @@ -0,0 +1,87 @@ +From 72edc2c02f8b4768ad660f46a1c7e2400c0a8e06 Mon Sep 17 00:00:00 2001 +From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> +Date: Mon, 17 Jul 2017 19:41:08 +0000 +Subject: [PATCH] Backported from mainline 2017-07-14 Jakub + Jelinek <jakub@redhat.com> + + PR sanitizer/81066 + * sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969. + * sanitizer_common/sanitizer_linux.cc: Likewise. + * sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise. + * tsan/tsan_platform_linux.cc: Likewise. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@250287 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + libsanitizer/ChangeLog (REMOVED) | 11 +++++++++++ + libsanitizer/sanitizer_common/sanitizer_linux.cc | 3 +-- + libsanitizer/sanitizer_common/sanitizer_linux.h | 4 +--- + .../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc | 2 +- + libsanitizer/tsan/tsan_platform_linux.cc | 2 +- + 5 files changed, 15 insertions(+), 7 deletions(-) + +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cc b/libsanitizer/sanitizer_common/sanitizer_linux.cc +index 806fcd5..5b6f186 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.cc +@@ -605,8 +605,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) { + } + #endif + +-uptr internal_sigaltstack(const struct sigaltstack *ss, +- struct sigaltstack *oss) { ++uptr internal_sigaltstack(const void *ss, void *oss) { + return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss); + } + +diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.h b/libsanitizer/sanitizer_common/sanitizer_linux.h +index 895bfc1..a42df57 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_linux.h ++++ b/libsanitizer/sanitizer_common/sanitizer_linux.h +@@ -19,7 +19,6 @@ + #include "sanitizer_platform_limits_posix.h" + + struct link_map; // Opaque type returned by dlopen(). +-struct sigaltstack; + + namespace __sanitizer { + // Dirent structure for getdents(). Note that this structure is different from +@@ -28,8 +27,7 @@ struct linux_dirent; + + // Syscall wrappers. + uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count); +-uptr internal_sigaltstack(const struct sigaltstack* ss, +- struct sigaltstack* oss); ++uptr internal_sigaltstack(const void* ss, void* oss); + uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set, + __sanitizer_sigset_t *oldset); + +diff --git a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +index 891386dc..234e8c6 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc +@@ -273,7 +273,7 @@ static int TracerThread(void* argument) { + + // Alternate stack for signal handling. + InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize); +- struct sigaltstack handler_stack; ++ stack_t handler_stack; + internal_memset(&handler_stack, 0, sizeof(handler_stack)); + handler_stack.ss_sp = handler_stack_memory.data(); + handler_stack.ss_size = kHandlerStackSize; +diff --git a/libsanitizer/tsan/tsan_platform_linux.cc b/libsanitizer/tsan/tsan_platform_linux.cc +index 2ed5718..6f972ab 100644 +--- a/libsanitizer/tsan/tsan_platform_linux.cc ++++ b/libsanitizer/tsan/tsan_platform_linux.cc +@@ -287,7 +287,7 @@ void InitializePlatform() { + int ExtractResolvFDs(void *state, int *fds, int nfd) { + #if SANITIZER_LINUX && !SANITIZER_ANDROID + int cnt = 0; +- __res_state *statp = (__res_state*)state; ++ struct __res_state *statp = (struct __res_state*)state; + for (int i = 0; i < MAXNS && cnt < nfd; i++) { + if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1) + fds[cnt++] = statp->_u._ext.nssocks[i]; +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.5.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.5.patch new file mode 100644 index 000000000000..a84e9ffe2681 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.5.patch @@ -0,0 +1,107 @@ +Trivally backported the upstream commit +b685411208e0aaa79190d54faf945763514706b8 +(different directory, some files not present, etc.) +We only really use x86* from those, probably, so I didn't bother much. +diff --git a/gcc/config/alpha/linux-unwind.h b/gcc/config/alpha/linux-unwind.h +index bdbba4a..e84812e 100644 +--- a/gcc/config/alpha/linux-unwind.h ++++ b/gcc/config/alpha/linux-unwind.h +@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + sc = &rt_->uc.uc_mcontext; + } +diff --git a/gcc/config/bfin/linux-unwind.h b/gcc/config/bfin/linux-unwind.h +index 77b7c23..8bf5e82 100644 +--- a/gcc/config/bfin/linux-unwind.h ++++ b/gcc/config/bfin/linux-unwind.h +@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context, + void *puc; + char retcode[8]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + + /* The void * cast is necessary to avoid an aliasing warning. +diff --git a/gcc/config/i386/linux-unwind.h b/gcc/config/i386/linux-unwind.h +index 540a0a2..29efbe3 100644 +--- a/gcc/config/i386/linux-unwind.h ++++ b/gcc/config/i386/linux-unwind.h +@@ -58,7 +58,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context, + if (*(unsigned char *)(pc+0) == 0x48 + && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL) + { +- struct ucontext *uc_ = context->cfa; ++ ucontext_t *uc_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem + because it does not alias anything. */ +@@ -138,7 +138,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context, + siginfo_t *pinfo; + void *puc; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/gcc/config/m68k/linux-unwind.h b/gcc/config/m68k/linux-unwind.h +index 75b7cf7..f964e24 100644 +--- a/gcc/config/m68k/linux-unwind.h ++++ b/gcc/config/m68k/linux-unwind.h +@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + /* <sys/ucontext.h> is unfortunately broken right now. */ + struct uw_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + unsigned long uc_filler[80]; +diff --git a/gcc/config/pa/linux-unwind.h b/gcc/config/pa/linux-unwind.h +index 9a2657f..e47493d 100644 +--- a/gcc/config/pa/linux-unwind.h ++++ b/gcc/config/pa/linux-unwind.h +@@ -80,7 +80,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context, + struct sigcontext *sc; + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *frame; + + /* rt_sigreturn trampoline: +diff --git a/gcc/config/sh/linux-unwind.h b/gcc/config/sh/linux-unwind.h +index e389cac..0bf43ba 100644 +--- a/gcc/config/sh/linux-unwind.h ++++ b/gcc/config/sh/linux-unwind.h +@@ -180,7 +180,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/gcc/config/xtensa/linux-unwind.h b/gcc/config/xtensa/linux-unwind.h +index 9872492..586a9d4 100644 +--- a/gcc/config/xtensa/linux-unwind.h ++++ b/gcc/config/xtensa/linux-unwind.h +@@ -67,7 +67,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context, + + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* movi a2, __NR_rt_sigreturn; syscall */ +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.8.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.8.patch new file mode 100644 index 000000000000..630ef6586e45 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-4.8.patch @@ -0,0 +1,177 @@ +From b685411208e0aaa79190d54faf945763514706b8 Mon Sep 17 00:00:00 2001 +From: jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> +Date: Tue, 4 Jul 2017 10:23:57 +0000 +Subject: [PATCH] Use ucontext_t not struct ucontext in linux-unwind.h files. + +Current glibc no longer gives the ucontext_t type the tag struct +ucontext, to conform with POSIX namespace rules. This requires +various linux-unwind.h files in libgcc, that were previously using +struct ucontext, to be fixed to use ucontext_t instead. This is +similar to the removal of the struct siginfo tag from siginfo_t some +years ago. + +This patch changes those files to use ucontext_t instead. As the +standard name that should be unconditionally safe, so this is not +restricted to architectures supported by glibc, or conditioned on the +glibc version. + +Tested compilation together with current glibc with glibc's +build-many-glibcs.py. + + * config/aarch64/linux-unwind.h (aarch64_fallback_frame_state), + config/alpha/linux-unwind.h (alpha_fallback_frame_state), + config/bfin/linux-unwind.h (bfin_fallback_frame_state), + config/i386/linux-unwind.h (x86_64_fallback_frame_state, + x86_fallback_frame_state), config/m68k/linux-unwind.h (struct + uw_ucontext), config/nios2/linux-unwind.h (struct nios2_ucontext), + config/pa/linux-unwind.h (pa32_fallback_frame_state), + config/sh/linux-unwind.h (sh_fallback_frame_state), + config/tilepro/linux-unwind.h (tile_fallback_frame_state), + config/xtensa/linux-unwind.h (xtensa_fallback_frame_state): Use + ucontext_t instead of struct ucontext. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@249957 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + libgcc/ChangeLog (REMOVED) | 14 ++++++++++++++ + libgcc/config/aarch64/linux-unwind.h | 2 +- + libgcc/config/alpha/linux-unwind.h | 2 +- + libgcc/config/bfin/linux-unwind.h | 2 +- + libgcc/config/i386/linux-unwind.h | 4 ++-- + libgcc/config/m68k/linux-unwind.h | 2 +- + libgcc/config/nios2/linux-unwind.h | 2 +- + libgcc/config/pa/linux-unwind.h | 2 +- + libgcc/config/sh/linux-unwind.h | 2 +- + libgcc/config/tilepro/linux-unwind.h | 2 +- + libgcc/config/xtensa/linux-unwind.h | 2 +- + 11 files changed, 25 insertions(+), 11 deletions(-) + +diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h +index 4512efb..06de45a 100644 +--- a/libgcc/config/aarch64/linux-unwind.h ++++ b/libgcc/config/aarch64/linux-unwind.h +@@ -52,7 +52,7 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe + { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + }; + + struct rt_sigframe *rt_; +diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h +index bdbba4a..e84812e 100644 +--- a/libgcc/config/alpha/linux-unwind.h ++++ b/libgcc/config/alpha/linux-unwind.h +@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + sc = &rt_->uc.uc_mcontext; + } +diff --git a/libgcc/config/bfin/linux-unwind.h b/libgcc/config/bfin/linux-unwind.h +index 77b7c23..8bf5e82 100644 +--- a/libgcc/config/bfin/linux-unwind.h ++++ b/libgcc/config/bfin/linux-unwind.h +@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context, + void *puc; + char retcode[8]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + + /* The void * cast is necessary to avoid an aliasing warning. +diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h +index 540a0a2..29efbe3 100644 +--- a/libgcc/config/i386/linux-unwind.h ++++ b/libgcc/config/i386/linux-unwind.h +@@ -58,7 +58,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context, + if (*(unsigned char *)(pc+0) == 0x48 + && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL) + { +- struct ucontext *uc_ = context->cfa; ++ ucontext_t *uc_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem + because it does not alias anything. */ +@@ -138,7 +138,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context, + siginfo_t *pinfo; + void *puc; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/m68k/linux-unwind.h b/libgcc/config/m68k/linux-unwind.h +index 75b7cf7..f964e24 100644 +--- a/libgcc/config/m68k/linux-unwind.h ++++ b/libgcc/config/m68k/linux-unwind.h +@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + /* <sys/ucontext.h> is unfortunately broken right now. */ + struct uw_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + unsigned long uc_filler[80]; +diff --git a/libgcc/config/pa/linux-unwind.h b/libgcc/config/pa/linux-unwind.h +index 9a2657f..e47493d 100644 +--- a/libgcc/config/pa/linux-unwind.h ++++ b/libgcc/config/pa/linux-unwind.h +@@ -80,7 +80,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context, + struct sigcontext *sc; + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *frame; + + /* rt_sigreturn trampoline: +diff --git a/libgcc/config/sh/linux-unwind.h b/libgcc/config/sh/linux-unwind.h +index e389cac..0bf43ba 100644 +--- a/libgcc/config/sh/linux-unwind.h ++++ b/libgcc/config/sh/linux-unwind.h +@@ -180,7 +180,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h +index 796e976..75f8890 100644 +--- a/libgcc/config/tilepro/linux-unwind.h ++++ b/libgcc/config/tilepro/linux-unwind.h +@@ -61,7 +61,7 @@ tile_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe { + unsigned char save_area[C_ABI_SAVE_AREA_SIZE]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* Return if this is not a signal handler. */ +diff --git a/libgcc/config/xtensa/linux-unwind.h b/libgcc/config/xtensa/linux-unwind.h +index 9872492..586a9d4 100644 +--- a/libgcc/config/xtensa/linux-unwind.h ++++ b/libgcc/config/xtensa/linux-unwind.h +@@ -67,7 +67,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context, + + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* movi a2, __NR_rt_sigreturn; syscall */ +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-libjava.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-libjava.patch new file mode 100644 index 000000000000..3892a56954e0 --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext-libjava.patch @@ -0,0 +1,33 @@ +--- a/libjava/include/x86_64-signal.h ++++ a/libjava/include/x86_64-signal.h +@@ -28,7 +28,7 @@ + #define HANDLE_DIVIDE_OVERFLOW \ + do \ + { \ +- struct ucontext *_uc = (struct ucontext *)_p; \ ++ ucontext_t *_uc = (ucontext_t *)_p; \ + gregset_t &_gregs = _uc->uc_mcontext.gregs; \ + unsigned char *_rip = (unsigned char *)_gregs[REG_RIP]; \ + \ +--- a/libjava/include/i386-signal.h ++++ a/libjava/include/i386-signal.h +@@ -29,7 +29,7 @@ + #define HANDLE_DIVIDE_OVERFLOW \ + do \ + { \ +- struct ucontext *_uc = (struct ucontext *)_p; \ ++ ucontext_t *_uc = (ucontext_t *)_p; \ + gregset_t &_gregs = _uc->uc_mcontext.gregs; \ + unsigned char *_eip = (unsigned char *)_gregs[REG_EIP]; \ + \ +--- a/libjava/include/s390-signal.h ++++ a/libjava/include/s390-signal.h +@@ -51,7 +51,7 @@ + struct \ + { \ + unsigned long int uc_flags; \ +- struct ucontext *uc_link; \ ++ ucontext_t *uc_link; \ + stack_t uc_stack; \ + mcontext_t uc_mcontext; \ + unsigned long sigmask[2]; \ diff --git a/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext.patch b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext.patch new file mode 100644 index 000000000000..c7fb6d1f71cf --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/struct-ucontext.patch @@ -0,0 +1,190 @@ +From b685411208e0aaa79190d54faf945763514706b8 Mon Sep 17 00:00:00 2001 +From: jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> +Date: Tue, 4 Jul 2017 10:23:57 +0000 +Subject: [PATCH] Use ucontext_t not struct ucontext in linux-unwind.h files. + +Current glibc no longer gives the ucontext_t type the tag struct +ucontext, to conform with POSIX namespace rules. This requires +various linux-unwind.h files in libgcc, that were previously using +struct ucontext, to be fixed to use ucontext_t instead. This is +similar to the removal of the struct siginfo tag from siginfo_t some +years ago. + +This patch changes those files to use ucontext_t instead. As the +standard name that should be unconditionally safe, so this is not +restricted to architectures supported by glibc, or conditioned on the +glibc version. + +Tested compilation together with current glibc with glibc's +build-many-glibcs.py. + + * config/aarch64/linux-unwind.h (aarch64_fallback_frame_state), + config/alpha/linux-unwind.h (alpha_fallback_frame_state), + config/bfin/linux-unwind.h (bfin_fallback_frame_state), + config/i386/linux-unwind.h (x86_64_fallback_frame_state, + x86_fallback_frame_state), config/m68k/linux-unwind.h (struct + uw_ucontext), config/nios2/linux-unwind.h (struct nios2_ucontext), + config/pa/linux-unwind.h (pa32_fallback_frame_state), + config/sh/linux-unwind.h (sh_fallback_frame_state), + config/tilepro/linux-unwind.h (tile_fallback_frame_state), + config/xtensa/linux-unwind.h (xtensa_fallback_frame_state): Use + ucontext_t instead of struct ucontext. + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@249957 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + libgcc/ChangeLog (REMOVED) | 14 ++++++++++++++ + libgcc/config/aarch64/linux-unwind.h | 2 +- + libgcc/config/alpha/linux-unwind.h | 2 +- + libgcc/config/bfin/linux-unwind.h | 2 +- + libgcc/config/i386/linux-unwind.h | 4 ++-- + libgcc/config/m68k/linux-unwind.h | 2 +- + libgcc/config/nios2/linux-unwind.h | 2 +- + libgcc/config/pa/linux-unwind.h | 2 +- + libgcc/config/sh/linux-unwind.h | 2 +- + libgcc/config/tilepro/linux-unwind.h | 2 +- + libgcc/config/xtensa/linux-unwind.h | 2 +- + 11 files changed, 25 insertions(+), 11 deletions(-) + +diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h +index 4512efb..06de45a 100644 +--- a/libgcc/config/aarch64/linux-unwind.h ++++ b/libgcc/config/aarch64/linux-unwind.h +@@ -52,7 +52,7 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe + { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + }; + + struct rt_sigframe *rt_; +diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h +index bdbba4a..e84812e 100644 +--- a/libgcc/config/alpha/linux-unwind.h ++++ b/libgcc/config/alpha/linux-unwind.h +@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + sc = &rt_->uc.uc_mcontext; + } +diff --git a/libgcc/config/bfin/linux-unwind.h b/libgcc/config/bfin/linux-unwind.h +index 77b7c23..8bf5e82 100644 +--- a/libgcc/config/bfin/linux-unwind.h ++++ b/libgcc/config/bfin/linux-unwind.h +@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context, + void *puc; + char retcode[8]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + + /* The void * cast is necessary to avoid an aliasing warning. +diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h +index 540a0a2..29efbe3 100644 +--- a/libgcc/config/i386/linux-unwind.h ++++ b/libgcc/config/i386/linux-unwind.h +@@ -58,7 +58,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context, + if (*(unsigned char *)(pc+0) == 0x48 + && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL) + { +- struct ucontext *uc_ = context->cfa; ++ ucontext_t *uc_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem + because it does not alias anything. */ +@@ -138,7 +138,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context, + siginfo_t *pinfo; + void *puc; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/m68k/linux-unwind.h b/libgcc/config/m68k/linux-unwind.h +index 75b7cf7..f964e24 100644 +--- a/libgcc/config/m68k/linux-unwind.h ++++ b/libgcc/config/m68k/linux-unwind.h +@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + /* <sys/ucontext.h> is unfortunately broken right now. */ + struct uw_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + unsigned long uc_filler[80]; +diff --git a/libgcc/config/nios2/linux-unwind.h b/libgcc/config/nios2/linux-unwind.h +index 2304142..30f25ea 100644 +--- a/libgcc/config/nios2/linux-unwind.h ++++ b/libgcc/config/nios2/linux-unwind.h +@@ -38,7 +38,7 @@ struct nios2_mcontext { + + struct nios2_ucontext { + unsigned long uc_flags; +- struct ucontext *uc_link; ++ ucontext_t *uc_link; + stack_t uc_stack; + struct nios2_mcontext uc_mcontext; + sigset_t uc_sigmask; /* mask last for extensibility */ +diff --git a/libgcc/config/pa/linux-unwind.h b/libgcc/config/pa/linux-unwind.h +index 9a2657f..e47493d 100644 +--- a/libgcc/config/pa/linux-unwind.h ++++ b/libgcc/config/pa/linux-unwind.h +@@ -80,7 +80,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context, + struct sigcontext *sc; + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *frame; + + /* rt_sigreturn trampoline: +diff --git a/libgcc/config/sh/linux-unwind.h b/libgcc/config/sh/linux-unwind.h +index e389cac..0bf43ba 100644 +--- a/libgcc/config/sh/linux-unwind.h ++++ b/libgcc/config/sh/linux-unwind.h +@@ -180,7 +180,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context, + { + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_ = context->cfa; + /* The void * cast is necessary to avoid an aliasing warning. + The aliasing warning is correct, but should not be a problem +diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h +index 796e976..75f8890 100644 +--- a/libgcc/config/tilepro/linux-unwind.h ++++ b/libgcc/config/tilepro/linux-unwind.h +@@ -61,7 +61,7 @@ tile_fallback_frame_state (struct _Unwind_Context *context, + struct rt_sigframe { + unsigned char save_area[C_ABI_SAVE_AREA_SIZE]; + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* Return if this is not a signal handler. */ +diff --git a/libgcc/config/xtensa/linux-unwind.h b/libgcc/config/xtensa/linux-unwind.h +index 9872492..586a9d4 100644 +--- a/libgcc/config/xtensa/linux-unwind.h ++++ b/libgcc/config/xtensa/linux-unwind.h +@@ -67,7 +67,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context, + + struct rt_sigframe { + siginfo_t info; +- struct ucontext uc; ++ ucontext_t uc; + } *rt_; + + /* movi a2, __NR_rt_sigreturn; syscall */ +-- +2.9.3 + diff --git a/nixpkgs/pkgs/development/compilers/gcc/use-source-date-epoch.patch b/nixpkgs/pkgs/development/compilers/gcc/use-source-date-epoch.patch new file mode 100644 index 000000000000..65a5ab028c1c --- /dev/null +++ b/nixpkgs/pkgs/development/compilers/gcc/use-source-date-epoch.patch @@ -0,0 +1,52 @@ +https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02210.html + +diff --git a/libcpp/macro.c b/libcpp/macro.c +index 1e0a0b5..a52e3cb 100644 +--- a/libcpp/macro.c ++++ b/libcpp/macro.c +@@ -349,14 +349,38 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node) + slow on some systems. */ + time_t tt; + struct tm *tb = NULL; ++ char *source_date_epoch; + +- /* (time_t) -1 is a legitimate value for "number of seconds +- since the Epoch", so we have to do a little dance to +- distinguish that from a genuine error. */ +- errno = 0; +- tt = time(NULL); +- if (tt != (time_t)-1 || errno == 0) +- tb = localtime (&tt); ++ /* Allow the date and time to be set externally by an exported ++ environment variable to enable reproducible builds. */ ++ source_date_epoch = getenv ("SOURCE_DATE_EPOCH"); ++ if (source_date_epoch) ++ { ++ errno = 0; ++ tt = (time_t) strtol (source_date_epoch, NULL, 10); ++ if (errno == 0) ++ { ++ tb = gmtime (&tt); ++ if (tb == NULL) ++ cpp_error (pfile, CPP_DL_ERROR, ++ "SOURCE_DATE_EPOCH=\"%s\" is not a valid date", ++ source_date_epoch); ++ } ++ else ++ cpp_error (pfile, CPP_DL_ERROR, ++ "SOURCE_DATE_EPOCH=\"%s\" is not a valid number", ++ source_date_epoch); ++ } ++ else ++ { ++ /* (time_t) -1 is a legitimate value for "number of seconds ++ since the Epoch", so we have to do a little dance to ++ distinguish that from a genuine error. */ ++ errno = 0; ++ tt = time(NULL); ++ if (tt != (time_t)-1 || errno == 0) ++ tb = localtime (&tt); ++ } + + if (tb) + { |