Merge pull request #237856 from amjoseph-nixpkgs/pr/gcc/no-more-custom-builder

gcc: use standard builder instead of custom builder.sh

authored by Artturi and committed by GitHub 4f133e5e 68f6fef8

+299 -333
+1 -3
pkgs/development/compilers/gcc/10/default.nix
··· 144 145 in 146 147 - lib.pipe (stdenv.mkDerivation ({ 148 pname = "${crossNameAddon}${name}"; 149 inherit version; 150 - 151 - builder = ../builder.sh; 152 153 src = fetchurl { 154 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
··· 144 145 in 146 147 + lib.pipe ((callFile ../common/builder.nix {}) ({ 148 pname = "${crossNameAddon}${name}"; 149 inherit version; 150 151 src = fetchurl { 152 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+1 -3
pkgs/development/compilers/gcc/11/default.nix
··· 157 158 in 159 160 - lib.pipe (stdenv.mkDerivation ({ 161 pname = "${crossNameAddon}${name}"; 162 inherit version; 163 - 164 - builder = ../builder.sh; 165 166 src = fetchurl { 167 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
··· 157 158 in 159 160 + lib.pipe ((callFile ../common/builder.nix {}) ({ 161 pname = "${crossNameAddon}${name}"; 162 inherit version; 163 164 src = fetchurl { 165 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+1 -3
pkgs/development/compilers/gcc/12/default.nix
··· 201 202 in 203 204 - lib.pipe (stdenv.mkDerivation ({ 205 pname = "${crossNameAddon}${name}"; 206 inherit version; 207 - 208 - builder = ../builder.sh; 209 210 src = fetchurl { 211 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
··· 201 202 in 203 204 + lib.pipe ((callFile ../common/builder.nix {}) ({ 205 pname = "${crossNameAddon}${name}"; 206 inherit version; 207 208 src = fetchurl { 209 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+1 -3
pkgs/development/compilers/gcc/13/default.nix
··· 195 196 in 197 198 - lib.pipe (stdenv.mkDerivation ({ 199 pname = "${crossNameAddon}${name}"; 200 inherit version; 201 - 202 - builder = ../builder.sh; 203 204 src = fetchurl { 205 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
··· 195 196 in 197 198 + lib.pipe ((callFile ../common/builder.nix {}) ({ 199 pname = "${crossNameAddon}${name}"; 200 inherit version; 201 202 src = fetchurl { 203 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+1 -3
pkgs/development/compilers/gcc/4.8/default.nix
··· 193 # We need all these X libraries when building AWT with GTK. 194 assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; 195 196 - lib.pipe (stdenv.mkDerivation ({ 197 pname = "${crossNameAddon}${name}"; 198 inherit version; 199 - 200 - builder = ../builder.sh; 201 202 src = fetchurl { 203 url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
··· 193 # We need all these X libraries when building AWT with GTK. 194 assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; 195 196 + lib.pipe ((callFile ../common/builder.nix {}) ({ 197 pname = "${crossNameAddon}${name}"; 198 inherit version; 199 200 src = fetchurl { 201 url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
+1 -3
pkgs/development/compilers/gcc/4.9/default.nix
··· 210 # We need all these X libraries when building AWT with GTK. 211 assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; 212 213 - lib.pipe (stdenv.mkDerivation ({ 214 pname = "${crossNameAddon}${name}"; 215 inherit version; 216 - 217 - builder = ../builder.sh; 218 219 src = fetchurl { 220 url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
··· 210 # We need all these X libraries when building AWT with GTK. 211 assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; 212 213 + lib.pipe ((callFile ../common/builder.nix {}) ({ 214 pname = "${crossNameAddon}${name}"; 215 inherit version; 216 217 src = fetchurl { 218 url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.bz2";
+1 -3
pkgs/development/compilers/gcc/6/default.nix
··· 199 # We need all these X libraries when building AWT with GTK. 200 assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; 201 202 - lib.pipe (stdenv.mkDerivation ({ 203 pname = "${crossNameAddon}${name}"; 204 inherit version; 205 - 206 - builder = ../builder.sh; 207 208 src = if stdenv.targetPlatform.isVc4 then fetchFromGitHub { 209 owner = "itszor";
··· 199 # We need all these X libraries when building AWT with GTK. 200 assert x11Support -> (filter (x: x == null) ([ gtk2 libart_lgpl ] ++ xlibs)) == []; 201 202 + lib.pipe ((callFile ../common/builder.nix {}) ({ 203 pname = "${crossNameAddon}${name}"; 204 inherit version; 205 206 src = if stdenv.targetPlatform.isVc4 then fetchFromGitHub { 207 owner = "itszor";
+1 -3
pkgs/development/compilers/gcc/7/default.nix
··· 149 150 in 151 152 - lib.pipe (stdenv.mkDerivation ({ 153 pname = "${crossNameAddon}${name}"; 154 inherit version; 155 - 156 - builder = ../builder.sh; 157 158 src = fetchurl { 159 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
··· 149 150 in 151 152 + lib.pipe ((callFile ../common/builder.nix {}) ({ 153 pname = "${crossNameAddon}${name}"; 154 inherit version; 155 156 src = fetchurl { 157 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+1 -3
pkgs/development/compilers/gcc/8/default.nix
··· 130 131 in 132 133 - lib.pipe (stdenv.mkDerivation ({ 134 pname = "${crossNameAddon}${name}"; 135 inherit version; 136 - 137 - builder = ../builder.sh; 138 139 src = fetchurl { 140 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
··· 130 131 in 132 133 + lib.pipe ((callFile ../common/builder.nix {}) ({ 134 pname = "${crossNameAddon}${name}"; 135 inherit version; 136 137 src = fetchurl { 138 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
+1 -3
pkgs/development/compilers/gcc/9/default.nix
··· 144 145 in 146 147 - lib.pipe (stdenv.mkDerivation ({ 148 pname = "${crossNameAddon}${name}"; 149 inherit version; 150 - 151 - builder = ../builder.sh; 152 153 src = fetchurl { 154 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
··· 144 145 in 146 147 + lib.pipe ((callFile ../common/builder.nix {}) ({ 148 pname = "${crossNameAddon}${name}"; 149 inherit version; 150 151 src = fetchurl { 152 url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
-290
pkgs/development/compilers/gcc/builder.sh
··· 1 - if [ -e .attrs.sh ]; then source .attrs.sh; fi 2 - source $stdenv/setup 3 - 4 - 5 - oldOpts="$(shopt -po nounset)" || true 6 - set -euo pipefail 7 - 8 - 9 - export NIX_FIXINC_DUMMY="$NIX_BUILD_TOP/dummy" 10 - mkdir "$NIX_FIXINC_DUMMY" 11 - 12 - 13 - if test "$staticCompiler" = "1"; then 14 - EXTRA_LDFLAGS="-static" 15 - else 16 - EXTRA_LDFLAGS="-Wl,-rpath,${!outputLib}/lib" 17 - fi 18 - 19 - 20 - # GCC interprets empty paths as ".", which we don't want. 21 - if test -z "${CPATH-}"; then unset CPATH; fi 22 - if test -z "${LIBRARY_PATH-}"; then unset LIBRARY_PATH; fi 23 - echo "\$CPATH is \`${CPATH-}'" 24 - echo "\$LIBRARY_PATH is \`${LIBRARY_PATH-}'" 25 - 26 - if test "$noSysDirs" = "1"; then 27 - 28 - declare \ 29 - EXTRA_FLAGS_FOR_BUILD EXTRA_FLAGS EXTRA_FLAGS_FOR_TARGET \ 30 - EXTRA_LDFLAGS_FOR_BUILD EXTRA_LDFLAGS_FOR_TARGET 31 - 32 - # Extract flags from Bintools Wrappers 33 - for post in '_FOR_BUILD' ''; do 34 - curBintools="NIX_BINTOOLS${post}" 35 - 36 - declare -a extraLDFlags=() 37 - if [[ -e "${!curBintools}/nix-support/orig-libc" ]]; then 38 - # Figure out what extra flags when linking to pass to the gcc 39 - # compilers being generated to make sure that they use our libc. 40 - extraLDFlags=($(< "${!curBintools}/nix-support/libc-ldflags") $(< "${!curBintools}/nix-support/libc-ldflags-before" || true)) 41 - if [ -e ${!curBintools}/nix-support/ld-set-dynamic-linker ]; then 42 - extraLDFlags=-dynamic-linker=$(< ${!curBintools}/nix-support/dynamic-linker) 43 - fi 44 - 45 - # The path to the Libc binaries such as `crti.o'. 46 - libc_libdir="$(< "${!curBintools}/nix-support/orig-libc")/lib" 47 - else 48 - # Hack: support impure environments. 49 - extraLDFlags=("-L/usr/lib64" "-L/usr/lib") 50 - libc_libdir="/usr/lib" 51 - fi 52 - extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" 53 - "${extraLDFlags[@]}") 54 - for i in "${extraLDFlags[@]}"; do 55 - declare EXTRA_LDFLAGS${post}+=" -Wl,$i" 56 - done 57 - done 58 - 59 - # Extract flags from CC Wrappers 60 - for post in '_FOR_BUILD' ''; do 61 - curCC="NIX_CC${post}" 62 - curFIXINC="NIX_FIXINC_DUMMY${post}" 63 - 64 - declare -a extraFlags=() 65 - if [[ -e "${!curCC}/nix-support/orig-libc" ]]; then 66 - # Figure out what extra compiling flags to pass to the gcc compilers 67 - # being generated to make sure that they use our libc. 68 - extraFlags=($(< "${!curCC}/nix-support/libc-crt1-cflags") $(< "${!curCC}/nix-support/libc-cflags")) 69 - 70 - # The path to the Libc headers 71 - libc_devdir="$(< "${!curCC}/nix-support/orig-libc-dev")" 72 - 73 - # Use *real* header files, otherwise a limits.h is generated that 74 - # does not include Libc's limits.h (notably missing SSIZE_MAX, 75 - # which breaks the build). 76 - declare NIX_FIXINC_DUMMY${post}="$libc_devdir/include" 77 - else 78 - # Hack: support impure environments. 79 - extraFlags=("-isystem" "/usr/include") 80 - declare NIX_FIXINC_DUMMY${post}=/usr/include 81 - fi 82 - 83 - extraFlags=("-I${!curFIXINC}" "${extraFlags[@]}") 84 - 85 - # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, make 86 - # sure to explictly add them so that files compiled with the bootstrap 87 - # compiler are optimized and (optionally) contain debugging information 88 - # (info "(gccinstall) Building"). 89 - if test -n "${dontStrip-}"; then 90 - extraFlags=("-O2" "-g" "${extraFlags[@]}") 91 - else 92 - # Don't pass `-g' at all; this saves space while building. 93 - extraFlags=("-O2" "${extraFlags[@]}") 94 - fi 95 - 96 - declare EXTRA_FLAGS${post}="${extraFlags[*]}" 97 - done 98 - 99 - if test -z "${targetConfig-}"; then 100 - # host = target, so the flags are the same 101 - EXTRA_FLAGS_FOR_TARGET="$EXTRA_FLAGS" 102 - EXTRA_LDFLAGS_FOR_TARGET="$EXTRA_LDFLAGS" 103 - fi 104 - 105 - # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find 106 - # the startfiles. 107 - # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx 108 - # for the startfiles. 109 - makeFlagsArray+=( 110 - "BUILD_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY_FOR_BUILD" 111 - "SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY_FOR_BUILD" 112 - "NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY" 113 - 114 - "LDFLAGS_FOR_BUILD=$EXTRA_LDFLAGS_FOR_BUILD" 115 - #"LDFLAGS=$EXTRA_LDFLAGS" 116 - "LDFLAGS_FOR_TARGET=$EXTRA_LDFLAGS_FOR_TARGET" 117 - 118 - "CFLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD" 119 - "CXXFLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD" 120 - "FLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD" 121 - 122 - # It seems there is a bug in GCC 5 123 - #"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" 124 - #"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" 125 - 126 - "CFLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 127 - "CXXFLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 128 - "FLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 129 - ) 130 - 131 - if test -z "${targetConfig-}"; then 132 - makeFlagsArray+=( 133 - "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" 134 - "BOOT_LDFLAGS=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 135 - ) 136 - fi 137 - 138 - if test "$withoutTargetLibc" == 1; then 139 - # We don't want the gcc build to assume there will be a libc providing 140 - # limits.h in this stage 141 - makeFlagsArray+=( 142 - 'LIMITS_H_TEST=false' 143 - ) 144 - else 145 - makeFlagsArray+=( 146 - 'LIMITS_H_TEST=true' 147 - ) 148 - fi 149 - fi 150 - 151 - eval "$oldOpts" 152 - 153 - providedPreConfigure="$preConfigure"; 154 - preConfigure() { 155 - if test -n "$newlibSrc"; then 156 - tar xvf "$newlibSrc" -C .. 157 - ln -s ../newlib-*/newlib newlib 158 - # Patch to get armvt5el working: 159 - sed -i -e 's/ arm)/ arm*)/' newlib/configure.host 160 - fi 161 - 162 - # Bug - they packaged zlib 163 - if test -d "zlib"; then 164 - # This breaks the build without-headers, which should build only 165 - # the target libgcc as target libraries. 166 - # See 'configure:5370' 167 - rm -Rf zlib 168 - fi 169 - 170 - if test -n "$crossMingw" -a -n "$withoutTargetLibc"; then 171 - mkdir -p ../mingw 172 - # --with-build-sysroot expects that: 173 - cp -R $libcCross/include ../mingw 174 - configureFlags="$configureFlags --with-build-sysroot=`pwd`/.." 175 - fi 176 - 177 - # Eval the preConfigure script from nix expression. 178 - eval "$providedPreConfigure" 179 - 180 - # Perform the build in a different directory. 181 - mkdir ../build 182 - cd ../build 183 - configureScript=../$sourceRoot/configure 184 - } 185 - 186 - 187 - postConfigure() { 188 - # Avoid store paths when embedding ./configure flags into gcc. 189 - # Mangled arguments are still useful when reporting bugs upstream. 190 - sed -e "/TOPLEVEL_CONFIGURE_ARGUMENTS=/ s|$NIX_STORE/[a-z0-9]\{32\}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" -i Makefile 191 - } 192 - 193 - 194 - preInstall() { 195 - mkdir -p "$out/${targetConfig}/lib" 196 - mkdir -p "${!outputLib}/${targetConfig}/lib" 197 - # Make ‘lib64’ symlinks to ‘lib’. 198 - if [ -n "$linkLib64toLib" ]; then 199 - ln -s lib "$out/${targetConfig}/lib64" 200 - ln -s lib "${!outputLib}/${targetConfig}/lib64" 201 - fi 202 - # Make ‘lib32’ symlinks to ‘lib’. 203 - if [ -n "$linkLib32toLib" ]; then 204 - ln -s lib "$out/${targetConfig}/lib32" 205 - ln -s lib "${!outputLib}/${targetConfig}/lib32" 206 - fi 207 - } 208 - 209 - 210 - postInstall() { 211 - # Move runtime libraries to lib output. 212 - moveToOutput "${targetConfig+$targetConfig/}lib/lib*.so*" "${!outputLib}" 213 - moveToOutput "${targetConfig+$targetConfig/}lib/lib*.la" "${!outputLib}" 214 - moveToOutput "${targetConfig+$targetConfig/}lib/lib*.dylib" "${!outputLib}" 215 - moveToOutput "${targetConfig+$targetConfig/}lib/lib*.dll.a" "${!outputLib}" 216 - moveToOutput "share/gcc-*/python" "${!outputLib}" 217 - 218 - if [ -z "$enableShared" ]; then 219 - moveToOutput "${targetConfig+$targetConfig/}lib/lib*.a" "${!outputLib}" 220 - fi 221 - 222 - for i in "${!outputLib}/${targetConfig}"/lib/*.{la,py}; do 223 - substituteInPlace "$i" --replace "$out" "${!outputLib}" 224 - done 225 - 226 - if [ -n "$enableMultilib" ]; then 227 - moveToOutput "${targetConfig+$targetConfig/}lib64/lib*.so*" "${!outputLib}" 228 - moveToOutput "${targetConfig+$targetConfig/}lib64/lib*.la" "${!outputLib}" 229 - moveToOutput "${targetConfig+$targetConfig/}lib64/lib*.dylib" "${!outputLib}" 230 - 231 - for i in "${!outputLib}/${targetConfig}"/lib64/*.{la,py}; do 232 - substituteInPlace "$i" --replace "$out" "${!outputLib}" 233 - done 234 - fi 235 - 236 - # Remove `fixincl' to prevent a retained dependency on the 237 - # previous gcc. 238 - rm -rf $out/libexec/gcc/*/*/install-tools 239 - rm -rf $out/lib/gcc/*/*/install-tools 240 - 241 - # More dependencies with the previous gcc or some libs (gccbug stores the build command line) 242 - rm -rf $out/bin/gccbug 243 - 244 - if type "install_name_tool"; then 245 - for i in "${!outputLib}"/lib/*.*.dylib "${!outputLib}"/lib/*.so.[0-9]; do 246 - install_name_tool -id "$i" "$i" || true 247 - for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do 248 - new_path=`echo "$old_path" | sed "s,$out,${!outputLib},"` 249 - install_name_tool -change "$old_path" "$new_path" "$i" || true 250 - done 251 - done 252 - fi 253 - 254 - # Cross-compiler specific: 255 - # --with-headers=$dir option triggers gcc to make a private copy 256 - # of $dir headers and use it later as `-isysroot`. This prevents 257 - # cc-wrapper from overriding libc headers with `-idirafter`. 258 - # It should be safe to drop it and rely solely on the cc-wrapper. 259 - local sysinc_dir=$out/${targetConfig+$targetConfig/}sys-include 260 - if [ -d "$sysinc_dir" ]; then 261 - chmod -R u+w "$out/${targetConfig+$targetConfig/}sys-include" 262 - rm -rfv "$out/${targetConfig+$targetConfig/}sys-include" 263 - fi 264 - 265 - # Get rid of some "fixed" header files 266 - rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux,sys/mount.h,bits/statx.h} 267 - 268 - # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks. 269 - for i in $out/bin/*-gcc*; do 270 - if cmp -s $out/bin/gcc $i; then 271 - ln -sfn gcc $i 272 - fi 273 - done 274 - 275 - for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do 276 - if cmp -s $out/bin/g++ $i; then 277 - ln -sfn g++ $i 278 - fi 279 - done 280 - 281 - # Two identical man pages are shipped (moving and compressing is done later) 282 - for i in "$out"/share/man/man1/*g++.1; do 283 - if test -e "$i"; then 284 - man_prefix=`echo "$i" | sed "s,.*/\(.*\)g++.1,\1,"` 285 - ln -sf "$man_prefix"gcc.1 "$i" 286 - fi 287 - done 288 - } 289 - 290 - genericBuild
···
+289
pkgs/development/compilers/gcc/common/builder.nix
···
··· 1 + { lib 2 + , stdenv 3 + , enableMultilib 4 + }: 5 + 6 + originalAttrs: (stdenv.mkDerivation (finalAttrs: originalAttrs // { 7 + preUnpack = '' 8 + oldOpts="$(shopt -po nounset)" || true 9 + set -euo pipefail 10 + 11 + export NIX_FIXINC_DUMMY="$NIX_BUILD_TOP/dummy" 12 + mkdir "$NIX_FIXINC_DUMMY" 13 + 14 + if test "$staticCompiler" = "1"; then 15 + EXTRA_LDFLAGS="-static" 16 + else 17 + EXTRA_LDFLAGS="-Wl,-rpath,''${!outputLib}/lib" 18 + fi 19 + 20 + # GCC interprets empty paths as ".", which we don't want. 21 + if test -z "''${CPATH-}"; then unset CPATH; fi 22 + if test -z "''${LIBRARY_PATH-}"; then unset LIBRARY_PATH; fi 23 + echo "\$CPATH is \`''${CPATH-}'" 24 + echo "\$LIBRARY_PATH is \`''${LIBRARY_PATH-}'" 25 + 26 + if test "$noSysDirs" = "1"; then 27 + 28 + declare -g \ 29 + EXTRA_FLAGS_FOR_BUILD EXTRA_FLAGS EXTRA_FLAGS_FOR_TARGET \ 30 + EXTRA_LDFLAGS_FOR_BUILD EXTRA_LDFLAGS_FOR_TARGET 31 + 32 + # Extract flags from Bintools Wrappers 33 + for post in '_FOR_BUILD' ""; do 34 + curBintools="NIX_BINTOOLS''${post}" 35 + 36 + declare -a extraLDFlags=() 37 + if [[ -e "''${!curBintools}/nix-support/orig-libc" ]]; then 38 + # Figure out what extra flags when linking to pass to the gcc 39 + # compilers being generated to make sure that they use our libc. 40 + extraLDFlags=($(< "''${!curBintools}/nix-support/libc-ldflags") $(< "''${!curBintools}/nix-support/libc-ldflags-before" || true)) 41 + if [ -e ''${!curBintools}/nix-support/ld-set-dynamic-linker ]; then 42 + extraLDFlags=-dynamic-linker=$(< ''${!curBintools}/nix-support/dynamic-linker) 43 + fi 44 + 45 + # The path to the Libc binaries such as `crti.o'. 46 + libc_libdir="$(< "''${!curBintools}/nix-support/orig-libc")/lib" 47 + else 48 + # Hack: support impure environments. 49 + extraLDFlags=("-L/usr/lib64" "-L/usr/lib") 50 + libc_libdir="/usr/lib" 51 + fi 52 + extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" 53 + "''${extraLDFlags[@]}") 54 + for i in "''${extraLDFlags[@]}"; do 55 + declare -g EXTRA_LDFLAGS''${post}+=" -Wl,$i" 56 + done 57 + done 58 + 59 + # Extract flags from CC Wrappers 60 + for post in '_FOR_BUILD' ""; do 61 + curCC="NIX_CC''${post}" 62 + curFIXINC="NIX_FIXINC_DUMMY''${post}" 63 + 64 + declare -a extraFlags=() 65 + if [[ -e "''${!curCC}/nix-support/orig-libc" ]]; then 66 + # Figure out what extra compiling flags to pass to the gcc compilers 67 + # being generated to make sure that they use our libc. 68 + extraFlags=($(< "''${!curCC}/nix-support/libc-crt1-cflags") $(< "''${!curCC}/nix-support/libc-cflags")) 69 + 70 + # The path to the Libc headers 71 + libc_devdir="$(< "''${!curCC}/nix-support/orig-libc-dev")" 72 + 73 + # Use *real* header files, otherwise a limits.h is generated that 74 + # does not include Libc's limits.h (notably missing SSIZE_MAX, 75 + # which breaks the build). 76 + declare -g NIX_FIXINC_DUMMY''${post}="$libc_devdir/include" 77 + else 78 + # Hack: support impure environments. 79 + extraFlags=("-isystem" "/usr/include") 80 + declare -g NIX_FIXINC_DUMMY''${post}=/usr/include 81 + fi 82 + 83 + extraFlags=("-I''${!curFIXINC}" "''${extraFlags[@]}") 84 + 85 + # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, make 86 + # sure to explictly add them so that files compiled with the bootstrap 87 + # compiler are optimized and (optionally) contain debugging information 88 + # (info "(gccinstall) Building"). 89 + if test -n "''${dontStrip-}"; then 90 + extraFlags=("-O2" "-g" "''${extraFlags[@]}") 91 + else 92 + # Don't pass `-g' at all; this saves space while building. 93 + extraFlags=("-O2" "''${extraFlags[@]}") 94 + fi 95 + 96 + declare -g EXTRA_FLAGS''${post}="''${extraFlags[*]}" 97 + done 98 + 99 + if test -z "''${targetConfig-}"; then 100 + # host = target, so the flags are the same 101 + EXTRA_FLAGS_FOR_TARGET="$EXTRA_FLAGS" 102 + EXTRA_LDFLAGS_FOR_TARGET="$EXTRA_LDFLAGS" 103 + fi 104 + 105 + # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find 106 + # the startfiles. 107 + # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx 108 + # for the startfiles. 109 + makeFlagsArray+=( 110 + "BUILD_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY_FOR_BUILD" 111 + "SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY_FOR_BUILD" 112 + "NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY" 113 + 114 + "LDFLAGS_FOR_BUILD=$EXTRA_LDFLAGS_FOR_BUILD" 115 + #"LDFLAGS=$EXTRA_LDFLAGS" 116 + "LDFLAGS_FOR_TARGET=$EXTRA_LDFLAGS_FOR_TARGET" 117 + 118 + "CFLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD" 119 + "CXXFLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD" 120 + "FLAGS_FOR_BUILD=$EXTRA_FLAGS_FOR_BUILD $EXTRA_LDFLAGS_FOR_BUILD" 121 + 122 + # It seems there is a bug in GCC 5 123 + #"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" 124 + #"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" 125 + 126 + "CFLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 127 + "CXXFLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 128 + "FLAGS_FOR_TARGET=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 129 + ) 130 + 131 + if test -z "''${targetConfig-}"; then 132 + makeFlagsArray+=( 133 + "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" 134 + "BOOT_LDFLAGS=$EXTRA_FLAGS_FOR_TARGET $EXTRA_LDFLAGS_FOR_TARGET" 135 + ) 136 + fi 137 + 138 + if test "$withoutTargetLibc" == 1; then 139 + # We don't want the gcc build to assume there will be a libc providing 140 + # limits.h in this stage 141 + makeFlagsArray+=( 142 + 'LIMITS_H_TEST=false' 143 + ) 144 + else 145 + makeFlagsArray+=( 146 + 'LIMITS_H_TEST=true' 147 + ) 148 + fi 149 + fi 150 + 151 + eval "$oldOpts" 152 + ''; 153 + 154 + preConfigure = (originalAttrs.preConfigure or "") + '' 155 + if test -n "$newlibSrc"; then 156 + tar xvf "$newlibSrc" -C .. 157 + ln -s ../newlib-*/newlib newlib 158 + # Patch to get armvt5el working: 159 + sed -i -e 's/ arm)/ arm*)/' newlib/configure.host 160 + fi 161 + 162 + # Bug - they packaged zlib 163 + if test -d "zlib"; then 164 + # This breaks the build without-headers, which should build only 165 + # the target libgcc as target libraries. 166 + # See 'configure:5370' 167 + rm -Rf zlib 168 + fi 169 + 170 + if test -n "$crossMingw" -a -n "$withoutTargetLibc"; then 171 + mkdir -p ../mingw 172 + # --with-build-sysroot expects that: 173 + cp -R $libcCross/include ../mingw 174 + configureFlags="$configureFlags --with-build-sysroot=`pwd`/.." 175 + fi 176 + 177 + # Perform the build in a different directory. 178 + mkdir ../build 179 + cd ../build 180 + configureScript=../$sourceRoot/configure 181 + ''; 182 + 183 + postConfigure = '' 184 + # Avoid store paths when embedding ./configure flags into gcc. 185 + # Mangled arguments are still useful when reporting bugs upstream. 186 + sed -e "/TOPLEVEL_CONFIGURE_ARGUMENTS=/ s|$NIX_STORE/[a-z0-9]\{32\}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" -i Makefile 187 + ''; 188 + 189 + preInstall = '' 190 + mkdir -p "$out/''${targetConfig}/lib" 191 + mkdir -p "''${!outputLib}/''${targetConfig}/lib" 192 + '' + 193 + # Make `lib64` symlinks to `lib`. 194 + lib.optionalString (!enableMultilib && stdenv.hostPlatform.is64bit && !stdenv.hostPlatform.isMips64n32) '' 195 + ln -s lib "$out/''${targetConfig}/lib64" 196 + ln -s lib "''${!outputLib}/''${targetConfig}/lib64" 197 + '' + 198 + # On mips platforms, gcc follows the IRIX naming convention: 199 + # 200 + # $PREFIX/lib = mips32 201 + # $PREFIX/lib32 = mips64n32 202 + # $PREFIX/lib64 = mips64 203 + # 204 + # Make `lib32` symlinks to `lib`. 205 + lib.optionalString (!enableMultilib && stdenv.targetPlatform.isMips64n32) '' 206 + ln -s lib "$out/''${targetConfig}/lib32" 207 + ln -s lib "''${!outputLib}/''${targetConfig}/lib32" 208 + ''; 209 + 210 + postInstall = '' 211 + # Move runtime libraries to lib output. 212 + moveToOutput "''${targetConfig+$targetConfig/}lib/lib*.so*" "''${!outputLib}" 213 + moveToOutput "''${targetConfig+$targetConfig/}lib/lib*.la" "''${!outputLib}" 214 + moveToOutput "''${targetConfig+$targetConfig/}lib/lib*.dylib" "''${!outputLib}" 215 + moveToOutput "''${targetConfig+$targetConfig/}lib/lib*.dll.a" "''${!outputLib}" 216 + moveToOutput "share/gcc-*/python" "''${!outputLib}" 217 + 218 + if [ -z "$enableShared" ]; then 219 + moveToOutput "''${targetConfig+$targetConfig/}lib/lib*.a" "''${!outputLib}" 220 + fi 221 + 222 + for i in "''${!outputLib}/''${targetConfig}"/lib/*.{la,py}; do 223 + substituteInPlace "$i" --replace "$out" "''${!outputLib}" 224 + done 225 + 226 + if [ -n "$enableMultilib" ]; then 227 + moveToOutput "''${targetConfig+$targetConfig/}lib64/lib*.so*" "''${!outputLib}" 228 + moveToOutput "''${targetConfig+$targetConfig/}lib64/lib*.la" "''${!outputLib}" 229 + moveToOutput "''${targetConfig+$targetConfig/}lib64/lib*.dylib" "''${!outputLib}" 230 + 231 + for i in "''${!outputLib}/''${targetConfig}"/lib64/*.{la,py}; do 232 + substituteInPlace "$i" --replace "$out" "''${!outputLib}" 233 + done 234 + fi 235 + 236 + # Remove `fixincl' to prevent a retained dependency on the 237 + # previous gcc. 238 + rm -rf $out/libexec/gcc/*/*/install-tools 239 + rm -rf $out/lib/gcc/*/*/install-tools 240 + 241 + # More dependencies with the previous gcc or some libs (gccbug stores the build command line) 242 + rm -rf $out/bin/gccbug 243 + 244 + if type "install_name_tool"; then 245 + for i in "''${!outputLib}"/lib/*.*.dylib "''${!outputLib}"/lib/*.so.[0-9]; do 246 + install_name_tool -id "$i" "$i" || true 247 + for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do 248 + new_path=`echo "$old_path" | sed "s,$out,''${!outputLib},"` 249 + install_name_tool -change "$old_path" "$new_path" "$i" || true 250 + done 251 + done 252 + fi 253 + 254 + # Cross-compiler specific: 255 + # --with-headers=$dir option triggers gcc to make a private copy 256 + # of $dir headers and use it later as `-isysroot`. This prevents 257 + # cc-wrapper from overriding libc headers with `-idirafter`. 258 + # It should be safe to drop it and rely solely on the cc-wrapper. 259 + local sysinc_dir=$out/''${targetConfig+$targetConfig/}sys-include 260 + if [ -d "$sysinc_dir" ]; then 261 + chmod -R u+w "$out/''${targetConfig+$targetConfig/}sys-include" 262 + rm -rfv "$out/''${targetConfig+$targetConfig/}sys-include" 263 + fi 264 + 265 + # Get rid of some "fixed" header files 266 + rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux,sys/mount.h,bits/statx.h} 267 + 268 + # Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks. 269 + for i in $out/bin/*-gcc*; do 270 + if cmp -s $out/bin/gcc $i; then 271 + ln -sfn gcc $i 272 + fi 273 + done 274 + 275 + for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do 276 + if cmp -s $out/bin/g++ $i; then 277 + ln -sfn g++ $i 278 + fi 279 + done 280 + 281 + # Two identical man pages are shipped (moving and compressing is done later) 282 + for i in "$out"/share/man/man1/*g++.1; do 283 + if test -e "$i"; then 284 + man_prefix=`echo "$i" | sed "s,.*/\(.*\)g++.1,\1,"` 285 + ln -sf "$man_prefix"gcc.1 "$i" 286 + fi 287 + done 288 + ''; 289 + }))
-13
pkgs/development/compilers/gcc/common/pre-configure.nix
··· 148 echo 'SHLIB_LC=${SHLIB_LC}' >> libgcc/Makefile.in 149 '') 150 151 - + lib.optionalString (!enableMultilib && hostPlatform.is64bit && !hostPlatform.isMips64n32) '' 152 - export linkLib64toLib=1 153 - '' 154 - 155 - # On mips platforms, gcc follows the IRIX naming convention: 156 - # 157 - # $PREFIX/lib = mips32 158 - # $PREFIX/lib32 = mips64n32 159 - # $PREFIX/lib64 = mips64 160 - # 161 - + lib.optionalString (!enableMultilib && targetPlatform.isMips64n32) '' 162 - export linkLib32toLib=1 163 - ''
··· 148 echo 'SHLIB_LC=${SHLIB_LC}' >> libgcc/Makefile.in 149 '') 150