gcc: if atLeast 13, use deduplicated version

+10 -352
-351
pkgs/development/compilers/gcc/13/default.nix
··· 1 - { lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs 2 - , langC ? true, langCC ? true, langFortran ? false 3 - , langAda ? false 4 - , langObjC ? stdenv.targetPlatform.isDarwin 5 - , langObjCpp ? stdenv.targetPlatform.isDarwin 6 - , langD ? false 7 - , langGo ? false 8 - , reproducibleBuild ? true 9 - , profiledCompiler ? false 10 - , langJit ? false 11 - , staticCompiler ? false 12 - , enableShared ? stdenv.targetPlatform.hasSharedLibraries 13 - , enableLTO ? stdenv.hostPlatform.hasSharedLibraries 14 - , texinfo ? null 15 - , perl ? null # optional, for texi2pod (then pod2man) 16 - , gmp, mpfr, libmpc, gettext, which, patchelf, binutils 17 - , isl ? null # optional, for the Graphite optimization framework. 18 - , zlib ? null 19 - , libucontext ? null 20 - , gnat-bootstrap ? null 21 - , enableMultilib ? false 22 - , enablePlugin ? stdenv.hostPlatform == stdenv.buildPlatform # Whether to support user-supplied plug-ins 23 - , name ? "gcc" 24 - , libcCross ? null 25 - , threadsCross ? null # for MinGW 26 - , withoutTargetLibc ? false 27 - , gnused ? null 28 - , cloog # unused; just for compat with gcc4, as we override the parameter on some places 29 - , buildPackages 30 - , libxcrypt 31 - , disableGdbPlugin ? !enablePlugin 32 - , nukeReferences 33 - , callPackage 34 - }: 35 - 36 - # Make sure we get GNU sed. 37 - assert stdenv.buildPlatform.isDarwin -> gnused != null; 38 - 39 - # The go frontend is written in c++ 40 - assert langGo -> langCC; 41 - assert langAda -> gnat-bootstrap != null; 42 - 43 - # TODO: fixup D bootstapping, probably by using gdc11 (and maybe other changes). 44 - # error: GDC is required to build d 45 - assert !langD; 46 - 47 - # threadsCross is just for MinGW 48 - assert threadsCross != {} -> stdenv.targetPlatform.isWindows; 49 - 50 - # profiledCompiler builds inject non-determinism in one of the compilation stages. 51 - # If turned on, we can't provide reproducible builds anymore 52 - assert reproducibleBuild -> profiledCompiler == false; 53 - 54 - with lib; 55 - with builtins; 56 - 57 - let majorVersion = "13"; 58 - version = "${majorVersion}.2.0"; 59 - disableBootstrap = !stdenv.hostPlatform.isDarwin && !profiledCompiler; 60 - 61 - inherit (stdenv) buildPlatform hostPlatform targetPlatform; 62 - 63 - patches = 64 - optional (targetPlatform != hostPlatform) ../libstdc++-target.patch 65 - ++ optional noSysDirs ../gcc-12-no-sys-dirs.patch 66 - ++ optional noSysDirs ./no-sys-dirs-riscv.patch 67 - ++ [ 68 - ../gnat-cflags-11.patch 69 - ../gcc-12-gfortran-driving.patch 70 - ../ppc-musl.patch 71 - ] 72 - # We only apply this patch when building a native toolchain for aarch64-darwin, as it breaks building 73 - # a foreign one: https://github.com/iains/gcc-12-branch/issues/18 74 - ++ optional (stdenv.isDarwin && stdenv.isAarch64 && buildPlatform == hostPlatform && hostPlatform == targetPlatform) (fetchpatch { 75 - name = "gcc-13-darwin-aarch64-support.patch"; 76 - url = "https://raw.githubusercontent.com/Homebrew/formula-patches/3c5cbc8e9cf444a1967786af48e430588e1eb481/gcc/gcc-13.2.0.diff"; 77 - sha256 = "sha256-Y5r3U3dwAFG6+b0TNCFd18PNxYu2+W/5zDbZ5cHvv+U="; 78 - }) 79 - ++ optional langD ../libphobos.patch 80 - 81 - # backport fixes to build gccgo with musl libc 82 - ++ optionals (langGo && stdenv.hostPlatform.isMusl) [ 83 - (fetchpatch { 84 - excludes = [ "gcc/go/gofrontend/MERGE" ]; 85 - url = "https://github.com/gcc-mirror/gcc/commit/cf79b1117bd177d3d4c6ed24b6fa243c3628ac2d.diff"; 86 - hash = "sha256-mS5ZiYi5D8CpGXrWg3tXlbhp4o86ew1imCTwaHLfl+I="; 87 - }) 88 - (fetchpatch { 89 - excludes = [ "gcc/go/gofrontend/MERGE" ]; 90 - url = "https://github.com/gcc-mirror/gcc/commit/7f195a2270910a6ed08bd76e3a16b0a6503f9faf.diff"; 91 - hash = "sha256-Ze/cFM0dQofKH00PWPDoklXUlwWhwA1nyTuiDAZ6FKo="; 92 - }) 93 - (fetchpatch { 94 - excludes = [ "gcc/go/gofrontend/MERGE" ]; 95 - url = "https://github.com/gcc-mirror/gcc/commit/762fd5e5547e464e25b4bee435db6df4eda0de90.diff"; 96 - hash = "sha256-o28upwTcHAnHG2Iq0OewzwSBEhHs+XpBGdIfZdT81pk="; 97 - }) 98 - (fetchpatch { 99 - excludes = [ "gcc/go/gofrontend/MERGE" ]; 100 - url = "https://github.com/gcc-mirror/gcc/commit/e73d9fcafbd07bc3714fbaf8a82db71d50015c92.diff"; 101 - hash = "sha256-1SjYCVHLEUihdON2TOC3Z2ufM+jf2vH0LvYtZL+c1Fo="; 102 - }) 103 - (fetchpatch { 104 - excludes = [ "gcc/go/gofrontend/MERGE" ]; 105 - url = "https://github.com/gcc-mirror/gcc/commit/b6c6a3d64f2e4e9347733290aca3c75898c44b2e.diff"; 106 - hash = "sha256-RycJ3YCHd3MXtYFjxP0zY2Wuw7/C4bWoBAQtTKJZPOQ="; 107 - }) 108 - (fetchpatch { 109 - excludes = [ "gcc/go/gofrontend/MERGE" ]; 110 - url = "https://github.com/gcc-mirror/gcc/commit/2b1a604a9b28fbf4f382060bebd04adb83acc2f9.diff"; 111 - hash = "sha256-WiBQG0Xbk75rHk+AMDvsbrm+dc7lDH0EONJXSdEeMGE="; 112 - }) 113 - (fetchpatch { 114 - url = "https://github.com/gcc-mirror/gcc/commit/c86b726c048eddc1be320c0bf64a897658bee13d.diff"; 115 - hash = "sha256-QSIlqDB6JRQhbj/c3ejlmbfWz9l9FurdSWxpwDebnlI="; 116 - }) 117 - ] 118 - 119 - # Fix detection of bootstrap compiler Ada support (cctools as) on Nix Darwin 120 - ++ optional (stdenv.isDarwin && langAda) ../ada-cctools-as-detection-configure.patch 121 - 122 - # Use absolute path in GNAT dylib install names on Darwin 123 - ++ optional (stdenv.isDarwin && langAda) ../gnat-darwin-dylib-install-name.patch 124 - ; 125 - 126 - /* Cross-gcc settings (build == host != target) */ 127 - crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt"; 128 - stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final"; 129 - crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-"; 130 - 131 - callFile = lib.callPackageWith { 132 - # lets 133 - inherit 134 - majorVersion 135 - version 136 - buildPlatform 137 - hostPlatform 138 - targetPlatform 139 - patches 140 - crossMingw 141 - stageNameAddon 142 - crossNameAddon 143 - ; 144 - # inherit generated with 'nix eval --json --impure --expr "with import ./. {}; lib.attrNames (lib.functionArgs gcc13.cc.override)" | jq '.[]' --raw-output' 145 - inherit 146 - binutils 147 - buildPackages 148 - cloog 149 - withoutTargetLibc 150 - disableBootstrap 151 - disableGdbPlugin 152 - enableLTO 153 - enableMultilib 154 - enablePlugin 155 - enableShared 156 - fetchpatch 157 - fetchurl 158 - gettext 159 - gmp 160 - gnat-bootstrap 161 - gnused 162 - isl 163 - langAda 164 - langC 165 - langCC 166 - langD 167 - langFortran 168 - langGo 169 - langJit 170 - langObjC 171 - langObjCpp 172 - lib 173 - libcCross 174 - libmpc 175 - libucontext 176 - libxcrypt 177 - mpfr 178 - name 179 - noSysDirs 180 - nukeReferences 181 - patchelf 182 - perl 183 - profiledCompiler 184 - reproducibleBuild 185 - staticCompiler 186 - stdenv 187 - targetPackages 188 - texinfo 189 - threadsCross 190 - which 191 - zip 192 - zlib 193 - ; 194 - }; 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"; 204 - hash = "sha256-4nXnZEKmBnNBon8Exca4PYYTFEAEwEE1KIY9xrXHQ9o="; 205 - }; 206 - 207 - inherit patches; 208 - 209 - outputs = [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib"; 210 - setOutputFlags = false; 211 - NIX_NO_SELF_RPATH = true; 212 - 213 - libc_dev = stdenv.cc.libc_dev; 214 - 215 - hardeningDisable = [ "format" "pie" ]; 216 - 217 - postPatch = '' 218 - configureScripts=$(find . -name configure) 219 - for configureScript in $configureScripts; do 220 - patchShebangs $configureScript 221 - done 222 - '' 223 - # This should kill all the stdinc frameworks that gcc and friends like to 224 - # insert into default search paths. 225 - + lib.optionalString hostPlatform.isDarwin '' 226 - substituteInPlace gcc/config/darwin-c.cc \ 227 - --replace 'if (stdinc)' 'if (0)' 228 - 229 - substituteInPlace libgcc/config/t-slibgcc-darwin \ 230 - --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name ''${!outputLib}/lib/\$(SHLIB_INSTALL_NAME)" 231 - 232 - substituteInPlace libgfortran/configure \ 233 - --replace "-install_name \\\$rpath/\\\$soname" "-install_name ''${!outputLib}/lib/\\\$soname" 234 - '' 235 - + ( 236 - lib.optionalString (targetPlatform != hostPlatform || stdenv.cc.libc != null) 237 - # On NixOS, use the right path to the dynamic linker instead of 238 - # `/lib/ld*.so'. 239 - (let 240 - libc = if libcCross != null then libcCross else stdenv.cc.libc; 241 - in 242 - ( 243 - '' echo "fixing the \`GLIBC_DYNAMIC_LINKER', \`UCLIBC_DYNAMIC_LINKER', and \`MUSL_DYNAMIC_LINKER' macros..." 244 - for header in "gcc/config/"*-gnu.h "gcc/config/"*"/"*.h 245 - do 246 - grep -q _DYNAMIC_LINKER "$header" || continue 247 - echo " fixing \`$header'..." 248 - sed -i "$header" \ 249 - -e 's|define[[:blank:]]*\([UCG]\+\)LIBC_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define \1LIBC_DYNAMIC_LINKER\2 "${libc.out}\3"|g' \ 250 - -e 's|define[[:blank:]]*MUSL_DYNAMIC_LINKER\([0-9]*\)[[:blank:]]"\([^\"]\+\)"$|define MUSL_DYNAMIC_LINKER\1 "${libc.out}\2"|g' 251 - done 252 - '' 253 - + lib.optionalString (targetPlatform.libc == "musl") 254 - '' 255 - sed -i gcc/config/linux.h -e '1i#undef LOCAL_INCLUDE_DIR' 256 - '' 257 - ) 258 - )) 259 - + lib.optionalString targetPlatform.isAvr '' 260 - makeFlagsArray+=( 261 - '-s' # workaround for hitting hydra log limit 262 - 'LIMITS_H_TEST=false' 263 - ) 264 - ''; 265 - 266 - inherit noSysDirs staticCompiler withoutTargetLibc 267 - libcCross crossMingw; 268 - 269 - inherit (callFile ../common/dependencies.nix { }) depsBuildBuild nativeBuildInputs depsBuildTarget buildInputs depsTargetTarget; 270 - 271 - NIX_LDFLAGS = lib.optionalString hostPlatform.isSunOS "-lm"; 272 - 273 - 274 - preConfigure = (callFile ../common/pre-configure.nix { }) + '' 275 - ln -sf ${libxcrypt}/include/crypt.h libsanitizer/sanitizer_common/crypt.h 276 - ''; 277 - 278 - dontDisableStatic = true; 279 - 280 - configurePlatforms = [ "build" "host" "target" ]; 281 - 282 - configureFlags = callFile ../common/configure-flags.nix { }; 283 - 284 - targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null; 285 - 286 - buildFlags = 287 - # we do not yet have Nix-driven profiling 288 - assert profiledCompiler -> !disableBootstrap; 289 - let target = 290 - lib.optionalString (profiledCompiler) "profiled" + 291 - lib.optionalString (targetPlatform == hostPlatform && hostPlatform == buildPlatform && !disableBootstrap) "bootstrap"; 292 - in lib.optional (target != "") target; 293 - 294 - inherit (callFile ../common/strip-attributes.nix { }) 295 - stripDebugList 296 - stripDebugListTarget 297 - preFixup; 298 - 299 - # https://gcc.gnu.org/PR109898 300 - enableParallelInstalling = false; 301 - 302 - # https://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 303 - ${if hostPlatform.system == "x86_64-solaris" then "CC" else null} = "gcc -m64"; 304 - 305 - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the 306 - # library headers and binaries, regarless of the language being compiled. 307 - # 308 - # Likewise, the LTO code doesn't find zlib. 309 - # 310 - # Cross-compiling, we need gcc not to read ./specs in order to build the g++ 311 - # compiler (after the specs for the cross-gcc are created). Having 312 - # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. 313 - 314 - CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] 315 - ++ optional (zlib != null) zlib 316 - )); 317 - 318 - LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath (optional (zlib != null) zlib)); 319 - 320 - inherit (callFile ../common/extra-target-flags.nix { }) 321 - EXTRA_FLAGS_FOR_TARGET 322 - EXTRA_LDFLAGS_FOR_TARGET 323 - ; 324 - 325 - passthru = { 326 - inherit langC langCC langObjC langObjCpp langAda langFortran langGo langD version; 327 - isGNU = true; 328 - }; 329 - 330 - enableParallelBuilding = true; 331 - inherit enableShared enableMultilib; 332 - 333 - meta = { 334 - inherit (callFile ../common/meta.nix { }) 335 - homepage 336 - license 337 - description 338 - longDescription 339 - platforms 340 - maintainers 341 - ; 342 - }; 343 - } 344 - 345 - // optionalAttrs (enableMultilib) { dontMoveLib64 = true; } 346 - )) 347 - [ 348 - (callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared; }) 349 - (callPackage ../common/checksum.nix { inherit langC langCC; }) 350 - ] 351 -
pkgs/development/compilers/gcc/13/no-sys-dirs-riscv.patch pkgs/development/compilers/gcc/patches/13/no-sys-dirs-riscv.patch
+10 -1
pkgs/top-level/all-packages.nix
··· 15800 15800 (lib.listToAttrs (map (version: 15801 15801 let atLeast = lib.versionAtLeast version; 15802 15802 attrName = "gcc${lib.replaceStrings ["."] [""] version}"; 15803 - pkg = lowPrio (wrapCC (callPackage (../development/compilers/gcc + "/${version}") ({ 15803 + deduplicatedVersions = { # map from majorVersion to exact version 15804 + "13" = "13.1.0"; 15805 + }; 15806 + deduplicated = deduplicatedVersions ? "${version}"; 15807 + path = if deduplicated 15808 + then ../development/compilers/gcc/default.nix 15809 + else ../development/compilers/gcc + "/${version}"; 15810 + pkg = lowPrio (wrapCC (callPackage path ({ 15804 15811 inherit noSysDirs; 15805 15812 reproducibleBuild = true; 15806 15813 profiledCompiler = false; ··· 15825 15832 } // lib.optionalAttrs (atLeast "6" && !(atLeast "9")) { 15826 15833 # gcc 10 is too strict to cross compile gcc <= 8 15827 15834 stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; 15835 + } // lib.optionalAttrs deduplicated { 15836 + version = deduplicatedVersions."${version}"; 15828 15837 }))); 15829 15838 in lib.nameValuePair attrName pkg 15830 15839 ) [ "4.8" "4.9" "6" "7" "8" "9" "10" "11" "12" "13" ]))