|
1 | 1 | { lib |
2 | 2 | , stdenv |
3 | | -, gccStdenv |
4 | | -, gcc9Stdenv |
| 3 | +, pkgs |
5 | 4 | , callPackage |
6 | 5 | , isl_0_20 |
7 | 6 | , libcCross |
|
15 | 14 | versions = import ./versions.nix; |
16 | 15 | gccForMajorMinorVersion = majorMinorVersion: |
17 | 16 | let |
| 17 | + majorVersion = lib.versions.major majorMinorVersion; |
18 | 18 | atLeast = lib.versionAtLeast majorMinorVersion; |
19 | 19 | attrName = "gcc${lib.replaceStrings ["."] [""] majorMinorVersion}"; |
20 | 20 | pkg = lowPrio (wrapCC (callPackage ./default.nix { |
|
24 | 24 | profiledCompiler = false; |
25 | 25 | libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then args.libcCross else null; |
26 | 26 | threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else { }; |
27 | | - isl = if stdenv.hostPlatform.isDarwin then null else isl_0_20; |
| 27 | + # do not allow version skew when cross-building gcc |
| 28 | + # |
| 29 | + # When `gcc` is cross-built (`build` != `target` && `host` == `target`) |
| 30 | + # `gcc` assumes that it has a compatible cross-compiler in the environment |
| 31 | + # that can build target libraries. Version of a cross-compiler has to |
| 32 | + # match the compiler being cross-built as libraries frequently use fresh |
| 33 | + # compiler features, like `-std=c++26` or target-specific types like |
| 34 | + # `_Bfloat16`. |
| 35 | + # Version mismatch causes build failures like: |
| 36 | + # https://github.com/NixOS/nixpkgs/issues/351905 |
| 37 | + # |
| 38 | + # Similar problems (but on a smaller scale) happen when a `gcc` |
| 39 | + # cross-compiler is built (`build` == `host` && `host` != `target`) built |
| 40 | + # by a mismatching version of a native compiler (`build` == `host` && |
| 41 | + # `host` == `target`). |
| 42 | + # |
| 43 | + # Let's fix both problems by requiring the same compiler version for |
| 44 | + # cross-case. |
| 45 | + stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform || stdenv.hostPlatform != stdenv.targetPlatform) && stdenv.cc.isGNU then pkgs."gcc${majorVersion}Stdenv" else stdenv; |
28 | 46 | })); |
29 | 47 | in |
30 | 48 | lib.nameValuePair attrName pkg; |
|
0 commit comments