nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 75 lines 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 pkgs, 5 overrideCC, 6 buildPackages, 7 targetPackages, 8 callPackage, 9 isl_0_20, 10 noSysDirs, 11 wrapCC, 12}@args: 13 14let 15 versions = import ./versions.nix; 16 gccForMajorMinorVersion = 17 majorMinorVersion: 18 let 19 majorVersion = lib.versions.major majorMinorVersion; 20 atLeast = lib.versionAtLeast majorMinorVersion; 21 attrName = "gcc${lib.replaceStrings [ "." ] [ "" ] majorMinorVersion}"; 22 pkg = lib.lowPrio ( 23 wrapCC ( 24 callPackage ./default.nix { 25 inherit noSysDirs; 26 inherit majorMinorVersion; 27 reproducibleBuild = true; 28 profiledCompiler = false; 29 libcCross = 30 if !lib.systems.equals stdenv.targetPlatform stdenv.buildPlatform then 31 targetPackages.libc or pkgs.libc 32 else 33 null; 34 threadsCross = 35 if !lib.systems.equals stdenv.targetPlatform stdenv.buildPlatform then 36 targetPackages.threads or pkgs.threads 37 else 38 { }; 39 isl = if stdenv.hostPlatform.isDarwin then null else isl_0_20; 40 # do not allow version skew when cross-building gcc 41 # 42 # When `gcc` is cross-built (`build` != `target` && `host` == `target`) 43 # `gcc` assumes that it has a compatible cross-compiler in the environment 44 # that can build target libraries. Version of a cross-compiler has to 45 # match the compiler being cross-built as libraries frequently use fresh 46 # compiler features, like `-std=c++26` or target-specific types like 47 # `_Bfloat16`. 48 # Version mismatch causes build failures like: 49 # https://github.com/NixOS/nixpkgs/issues/351905 50 # 51 # Similar problems (but on a smaller scale) happen when a `gcc` 52 # cross-compiler is built (`build` == `host` && `host` != `target`) built 53 # by a mismatching version of a native compiler (`build` == `host` && 54 # `host` == `target`). 55 # 56 # Let's fix both problems by requiring the same compiler version for 57 # cross-case. 58 stdenv = 59 if 60 ( 61 (!lib.systems.equals stdenv.targetPlatform stdenv.buildPlatform) 62 || (!lib.systems.equals stdenv.hostPlatform stdenv.targetPlatform) 63 ) 64 && stdenv.cc.isGNU 65 then 66 overrideCC stdenv buildPackages."gcc${majorVersion}" 67 else 68 stdenv; 69 } 70 ) 71 ); 72 in 73 lib.nameValuePair attrName pkg; 74in 75lib.listToAttrs (map gccForMajorMinorVersion versions.allMajorVersions)