Commit Graph

1113 Commits

Author SHA1 Message Date
github-actions[bot]
b90e2fc451
Merge staging-next into staging 2023-11-04 06:01:49 +00:00
github-actions[bot]
10d3ba75f0
Merge master into staging-next 2023-11-04 06:01:18 +00:00
Adam Joseph
36f5b2e42b gcc.libgcc: compare host and target platforms, rathern than their triples
The rest of our gcc expression prepends "${targetPlatform.config}-"
to paths and binaries if `hostPlatform!=targetPlatform`.  The
`libgcc.nix` expression was using
'hostPlatform.config!=targetPlatform.config`, which caused it to
look in the wrong place when moving files.  This commit corrects that.
2023-11-04 05:58:23 +00:00
Artturi
4693035911
Merge pull request #240596 from amjoseph-nixpkgs/pr/gcc/stage-rename 2023-10-27 17:13:59 +03:00
Adam Joseph
1904125877 gcc: change "-stage-static" to "-nolibc" and "-stage-final" to ""
This commit changes the target suffix for the first-stage cross
compiler from `-stage-static` to `-nolibc`, and eliminates the
target suffix from the final-stage cross compiler (previously
`-stage-final`).

Co-authored-by: Artturi <Artturin@artturin.com>
Co-authored-by: John Ericson <git@JohnEricson.me>
2023-10-26 20:07:18 -07:00
Vladimír Čunát
d811555465
Merge branch 'staging' into staging-next 2023-10-26 10:36:50 +02:00
Adam Joseph
425cac96bf gcc: create dummy crtstuff on S390 as well
This commit replicates the fix in
https://github.com/NixOS/nixpkgs/pull/258032 for S390 as well.

Co-authored-by: Artturi <Artturin@artturin.com>
2023-10-25 08:36:22 +00:00
github-actions[bot]
4312247c19
Merge staging-next into staging 2023-10-22 12:01:52 +00:00
Weijia Wang
0a8e3e0748 gcc: create dummy crtstuff on loongarch64 2023-10-22 09:48:16 +00:00
github-actions[bot]
aca616eec2
Merge staging-next into staging 2023-10-11 12:01:48 +00:00
github-actions[bot]
0e9411554d
Merge master into staging-next 2023-10-11 12:01:09 +00:00
Alyssa Ross
69b9532a74
gcc: always inhibit libc in cross with same configs
It's not just gcc->clang cross compilation that produces different
platforms with equal configs — dynamic->static cross compilation can
have the same result (e.g. pkgsMusl.pkgsStatic).  So, remove the check
for LLVM, but keep the check that the configs match.

This fixes pkgsMusl.nix on x86_64-linux, which depends on
pkgsMusl.pkgsStatic.buildPackages.gccWithoutTargetLibc.cc.

Fixes: 926c920c12 ("gcc: tighten condition for inhibit_libc=true")
2023-10-10 10:58:44 +00:00
github-actions[bot]
81871f4c87
Merge staging-next into staging 2023-10-08 12:01:52 +00:00
Fabián Heredia Montiel
7f16b623fc Merge remote-tracking branch 'origin/master' into staging-next 2023-10-08 00:18:22 -06:00
Artturi
b64b1ed759
Merge pull request #255192 from trofi/cc-wrapper-no-__FILE_-refs 2023-10-08 04:30:09 +03:00
Artturin
fa54cb146a gcc: add fallback to condition
```
> pkgsMusl.nix
error: attribute 'useLLVM' missing

$ nix eval -f . pkgsMusl.pkgsStatic.stdenv.targetPlatform.useLLVM
error: attribute 'useLLVM' in selection path 'pkgsMusl.pkgsStatic.stdenv.targetPlatform.useLLVM' not found
```
2023-10-07 18:26:49 +03:00
Alyssa Ross
a838aa244f
Merge remote-tracking branch 'origin/master' into staging-next
The hash for pytensor is not correct, but that's also the case in
master, so a merge commit isn't the place to fix it.

Conflicts:
	pkgs/development/python-modules/faadelays/default.nix
	pkgs/development/python-modules/pytensor/default.nix
	pkgs/tools/admin/rset/default.nix
2023-10-05 08:02:48 +00:00
Artturi
c748544b2f
Merge pull request #241206 from amjoseph-nixpkgs/tighten-inhibit_libc-condition 2023-10-05 04:43:53 +03:00
Sergei Trofimovich
537176760c gcc12, gcc13: always mangle __FILE__ into invalid store path
Without the change `__FILE__` used in static inline functions in headers
embed paths to header files into executable images. For local headers
it's not a problem, but for headers in `/nix/store` this causes `-dev`
inputs to be retained in runtime closure.

Typical examples are `nix` -> `nlonhmann_json` and `pipewire` ->
`lttng-ust.dev`.

Ideally we would like to use `-fmacro-prefix-map=` feature of `gcc` as:

  -fmacro-prefix-map=/nix/store/$hash1-nlohmann-json-ver=/nix/store/eeee.eee-nlohmann-json-ver
  -fmacro-prefix-map=/nix/...

In practice it quickly exhausts argument lengtth limit due to `gcc`
deficiency: https://gcc.gnu.org/PR111527

Until it;s fixed let's hardcode header mangling if $NIX_STORE variable
is present in the environment.

Tested as:

    $ printf "# 0 \"/nix/store/01234567890123456789012345678901-pppppp-vvvvvvv\" \nconst char * f(void) { return __FILE__; }" | NIX_STORE=/nix/store ./gcc/xgcc -Bgcc -x c - -S -o -
    ...
    .string "/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-pppppp-vvvvvvv"
    ...

Mangled successfully.
2023-10-04 21:16:13 +01:00
github-actions[bot]
ab895db907
Merge staging-next into staging 2023-09-22 00:02:40 +00:00
Adam Joseph
ea61be413c gcc: set GFORTRAN_FOR_TARGET on cross-built native compilers
For a cross-built native compiler, i.e. build!=(host==target), the
bundled libgfortran needs a gfortran which can run on the
buildPlatform and emit code for the targetPlatform.  The compiler
which is built alongside gfortran in this configuration doesn't meet
that need: it runs on the hostPlatform.

This commit passes the necessary compiler via `GFORTRAN_FOR_TARGET`,
using `pkgsBuildTarget.gfortran`.
2023-09-21 09:24:56 +03:00
Artturi
2e705d027f
Merge pull request #250498 from amjoseph-nixpkgs/gcc/deduplicate/simplify2 2023-09-19 07:47:50 +03:00
github-actions[bot]
b4fdbf27f2
Merge master into staging-next 2023-09-09 06:01:15 +00:00
John Ericson
e829eca886
Merge pull request #253939 from angerman/angerman/ucrt64
Add ucrt64 mingw toolchain.
2023-09-08 22:40:14 -04:00
github-actions[bot]
a376e04925
Merge master into staging-next 2023-09-09 00:02:10 +00:00
Adam Joseph
aafab3b5b6 gcc: for cross compilers, don't build libgcc twice
Cross-compiled binaries currently end up with two different libgcc
outpaths in their closure.  This is harmless, but confusing.

The two libgccs are:

- One of them is the "first" targetPlatform libgcc, which is built
  by the "first" cross-compiler.  This "first libgcc" and "first
  compiler" are used to build the targetPlatform glibc.

- Once glibc is built, we *rebuild* the cross-compiler, since gcc
  can't enable most of its features unless you give it an
  already-compiled targetPlatform glibc.  When this "second"
  compiler is built, it also builds an extra copy of libgcc.

This commit discards the second, extra libgcc, and instead puts a
reference to the first (correct) libgcc into the "second compiler"
`.passthru.libgcc`, so that anybody expecting `stdenv.cc.cc.libgcc`
to exist will still find it there.

Closes #249680
2023-09-08 16:07:50 +03:00
Moritz Angermann
a81e3dcd75 treewide: replace libc == "msvcrt" with isMinGW
msvcrt is only one of the libcs in MinGW. We therefore
replace explictly testing for msvcrt with the isMinGW
predicate. This lays the foundation for ucrt64 support.
2023-09-08 10:56:08 +00:00
Artturi
161bf63234
Merge pull request #250496 from amjoseph-nixpkgs/simplify 2023-09-06 02:44:34 +03:00
Artturin
5c63f69ed2 gcc.patches: For gcc49 apply libsanitizer-no-cyclades-9 patch later
otherwise there is a conflict
2023-09-02 21:49:08 +03:00
Artturin
3d4e0708a0 gcc: move dll.a in lib64 to lib output too
same as c304c1e7d0
2023-08-29 01:04:15 +03:00
marius david
2eeb227d77 gcc: move dll to output 2023-08-27 21:40:34 +03:00
Adam Joseph
af319af225 gcc: unescapify backslash 2023-08-23 21:47:12 -07:00
Adam Joseph
80198b835b gcc: remove backticks-used-as-quotes (error prone) 2023-08-23 21:47:12 -07:00
Adam Joseph
040cf4248d gcc: simplify expression by applying workarounds more broadly
This commit simplifies our gcc expression by applying various
workarounds unconditionally, rather than only to exactly the
versions which applied them prior to the deduplication cleanup.

Unlike its predecessors https://github.com/NixOS/nixpkgs/pull/249707
and https://github.com/NixOS/nixpkgs/pull/250489 this commit *does*
affect eval.
2023-08-23 21:47:12 -07:00
Adam Joseph
6c8b8bc2f1 gcc: limit gcc12 isMips --disable-libsanitizer to abi=="gnu" 2023-08-23 14:32:50 -07:00
Sergei Trofimovich
a62c92ab9b gcc12: disable libsanitizer for mips64
Without the change build on mips64-unknown-linux-gnu fails as:

        $ nix-build -A buildPackages.gcc12 --argstr crossSystem mips64-linux

        In file included from ...-glibc-mips64-unknown-linux-gnu-2.37-8-dev/include/bits/stat.h:25,
                         from ...-glibc-mips64-unknown-linux-gnu-2.37-8-dev/include/fcntl.h:78,
                         from ../../../../gcc-12.3.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:55:
        ...-glibc-mips64-unknown-linux-gnu-2.37-8-dev/include/bits/struct_stat.h:190:8: error: redefinition of 'struct stat64'
          190 | struct stat64
              |        ^~~~~~
2023-08-23 14:30:54 -07:00
Adam Joseph
62c676ce6f gcc: patches: reorganize and simplify
This PR sorts the huge pile of patches and deduplicates it.  Unlike
its predecessors https://github.com/NixOS/nixpkgs/pull/249707 and
https://github.com/NixOS/nixpkgs/pull/250489 this commit *does*
affect eval.

Patches below are organized into three general categories:

1. Patches relevant to gcc>=12 on every platform
2. Patches relevant to gcc>=12 on specific platforms
3. Patches relevant only to gcc<12, sorted by the newest version to
   which they might be relevant
2023-08-21 02:18:57 -07:00
Adam Joseph
1b0ed9f81b gcc: patches: fix patch name 2023-08-20 23:43:45 -07:00
Adam Joseph
b955304456 gcc: patches: fix patch name 2023-08-20 23:43:19 -07:00
Adam Joseph
8221d5f4e7 gcc: resolve merge conflict from staging 2023-08-20 23:00:03 -07:00
Adam Joseph
8f225b515f gcc: match weird whack-a-mole per-version hash algorithm 2023-08-20 23:00:03 -07:00
Adam Joseph
de36365466 gcc: clean up version conditions 2023-08-20 23:00:03 -07:00
Adam Joseph
30171782b7 gcc: move version-map out of all-packages.nix, into pkgs/ 2023-08-20 23:00:02 -07:00
Adam Joseph
911452ccbd gcc: move patches attribute into patches/ subdirectory 2023-08-20 23:00:02 -07:00
Adam Joseph
95475034d5 gcc: if atLeast 4.8, use deduplicated version 2023-08-20 23:00:02 -07:00
Adam Joseph
beeb48d17a gcc: if atLeast 4.9, use deduplicated version 2023-08-20 23:00:02 -07:00
Adam Joseph
920df10ab7 gcc: if atLeast 6, use deduplicated version 2023-08-20 23:00:02 -07:00
Adam Joseph
33f7f2c5aa gcc: if atLeast 7, use deduplicated version 2023-08-20 23:00:01 -07:00
Adam Joseph
e7afebbc4c gcc: if atLeast 8, use deduplicated version 2023-08-20 23:00:01 -07:00
Adam Joseph
4116fc3e6f gcc: if atLeast 9, use deduplicated version 2023-08-20 23:00:01 -07:00
Adam Joseph
10ee71f582 gcc: if atLeast 10, use deduplicated version 2023-08-20 23:00:01 -07:00
Adam Joseph
72fe04286e gcc: if atLeast 11, use deduplicated version 2023-08-20 23:00:00 -07:00
Adam Joseph
e9ece66a80 gcc: if atLeast 12, use deduplicated version 2023-08-20 23:00:00 -07:00
Adam Joseph
93d63aaa05 gcc: if atLeast 13, use deduplicated version 2023-08-20 23:00:00 -07:00
Adam Joseph
9dc9872922 gcc: default.nix: parameterize by version 2023-08-20 23:00:00 -07:00
Adam Joseph
57a2dfe646 gcc: default.nix: replace ../ with ./ 2023-08-20 23:00:00 -07:00
Adam Joseph
671b761d05 gcc: cp ./13/default.nix ./default.nix 2023-08-20 22:59:59 -07:00
Adam Joseph
39b20be057 gcc: resolve merge conflict from staging 2023-08-20 22:59:20 -07:00
Adam Joseph
fa0fc88e0c gcc: match weird whack-a-mole per-version hash algorithm 2023-08-20 22:59:20 -07:00
Adam Joseph
869b639285 gcc: clean up version conditions 2023-08-20 22:59:20 -07:00
Adam Joseph
02198751fa gcc: move version-map out of all-packages.nix, into pkgs/ 2023-08-20 22:59:20 -07:00
Adam Joseph
7367bb691d gcc: move patches attribute into patches/ subdirectory 2023-08-20 22:59:19 -07:00
Adam Joseph
da87387073 gcc: if atLeast 4.8, use deduplicated version 2023-08-20 22:59:16 -07:00
Adam Joseph
8a4148a538 gcc: if atLeast 4.9, use deduplicated version 2023-08-20 22:59:16 -07:00
Adam Joseph
b505fb4711 gcc: if atLeast 6, use deduplicated version 2023-08-20 22:59:16 -07:00
Adam Joseph
b3d07e87d2 gcc: if atLeast 7, use deduplicated version 2023-08-20 22:59:15 -07:00
Adam Joseph
942d7ecf08 gcc: if atLeast 8, use deduplicated version 2023-08-20 22:59:15 -07:00
Adam Joseph
01902c7b45 gcc: if atLeast 9, use deduplicated version 2023-08-20 22:59:15 -07:00
Adam Joseph
c72e136046 gcc: if atLeast 10, use deduplicated version 2023-08-20 22:59:15 -07:00
Adam Joseph
8a822d6e5d gcc: if atLeast 11, use deduplicated version 2023-08-20 22:59:14 -07:00
Adam Joseph
dc3eb566d1 gcc: if atLeast 12, use deduplicated version 2023-08-20 22:59:14 -07:00
Adam Joseph
c3bae705a9 gcc: if atLeast 13, use deduplicated version 2023-08-20 22:59:11 -07:00
Adam Joseph
59daa06947 gcc: default.nix: parameterize by version 2023-08-20 22:52:41 -07:00
Adam Joseph
2e16ac593a gcc: default.nix: replace ../ with ./ 2023-08-20 22:52:40 -07:00
Adam Joseph
0f7bf37e5a gcc: cp ./13/default.nix ./default.nix 2023-08-20 22:52:40 -07:00
Vladimír Čunát
636fd56f69
Merge #248552: gcc10, gcc13: patch-version bumps
...into staging-next
2023-08-18 06:48:53 +02:00
Vladimír Čunát
5ecef4a6af
gcc13: update aarch64-darwin patch 2023-08-17 08:15:43 +02:00
Adam Joseph
92186a49bf gcc: factor out forceLibgccToBuildCrtStuff 2023-08-14 15:08:28 -07:00
Vladimír Čunát
dc1e382f94
gcc13: 13.1.0 -> 13.2.0
The patch would no longer apply, as the the changed part is no longer
exactly at the end of the file.  There's more content now, but it
suffices to just add a preserved empty line into the diff.
2023-08-11 17:27:37 +02:00
Vladimír Čunát
287a5b6baa
gcc10: apply a patch more often
As usual, just to earlier detect when it stops applying.
2023-08-11 17:05:11 +02:00
Vladimír Čunát
bab20c7df7
gcc10: 10.4.0 -> 10.5.0
This dropped file now seems unused.
2023-08-11 16:51:03 +02:00
Sergei Trofimovich
3d66844c2d gcc: revert "do not install sys-include headers for cross-compilers."
The change reverts commit 7df4387ebd

A few reasons to revert the commit:
1. The change was not enough to restore `-idirafter` override semantic
   to match unwrapped compiler.
2. The change broke override semantics for cross-compilers
3. The change made override semantics different between cross-compiler
   and native compiler

All of three have some overlap between, but I think it's important
to call all of them out.

The main fallout is the uboot builds, reported by cynerd.

Used the following test to check the override recovery:

    $ nix shell github:NixOS/nixpkgs/release-22.05#pkgsCross.aarch64-multiplatform.stdenv.cc
    $$ cat stdio.h
    # empty
    $$ printf "#include <stdio.h>" | aarch64-unknown-linux-gnu-gcc -E - -o - -idirafter . >/dev/null; echo $?
    0

It failed before the change and succeded after.
2023-07-26 16:40:42 +01:00
Adam Joseph
7621636030 gcc: use Nix instead of bash for conditional
Now that we use the standard builder, the commands produced by
pre-configure.nix are wrapped in a bash function.  Inside of a bash
function, `export foo=` will still add `foo` to the environment of
any child processes forked after that point, but those variables
will *not* be visible to bash code which is outside of the
function-scope in which the `export` occurs.

Weird crap like this is yet another reason why we need to move away
from using bash for logic.  Let's switch.
2023-07-07 05:56:46 -07:00
Adam Joseph
e99f6372fa gcc: use callFile instead of callPackage for builder.nix 2023-07-07 05:56:46 -07:00
Adam Joseph
5eaf17927e gcc: add -g to declare
The bash `declare` builtin works differently when it occurs inside
function, as it now does due to breaking up the monolithic
`builder.sh` into separate phases.  We have to add `-g` in order to
get the outside-of-a-bash-function behavior when using `declare`
within a bash function.
2023-07-07 05:56:46 -07:00
Adam Joseph
67da7b9a1f gcc: remove builder.sh 2023-07-07 05:56:44 -07:00
Adam Joseph
e3f05c22aa gcc: use common/builder.nix
This commit replaces `stdenv.mkDerivation` with `(callPackage
../common/builder.nix {})` in all versions of gcc.
2023-07-07 05:55:15 -07:00
Adam Joseph
c413f5a6c1 gcc: remove builder = ../builder.sh from gcc/${version}/default.nix
This commit deletes the custom builder attribute from all gcc versions.
2023-07-07 05:55:15 -07:00
Adam Joseph
1157e1d856 gcc: add args to common/builder.nix, split up script into phases
This commit adds arguments to `builder.nix`, making it a callable
function, and splits up the single massive shell script into
separate attributes for each phase.  It also drops the first two
lines and the last line because these are part of the default
builder.

All script lines which were not part of a phase function have been
moved into `preUnpack` since this is the first phase that runs.
Subsequent commits will move parts of this to more sensible
locations.
2023-07-07 05:55:15 -07:00
Adam Joseph
72284b0d40 gcc: make common/builder.nix into valid Nix syntax
This commit performs two search-and-replace operations:

- replace all `${` with `''${`
- replace `''` with `""` in shell scripts

This commit is left unsquashed to make review of the subsequent
commits easier.
2023-07-07 05:55:15 -07:00
Adam Joseph
caf22a33eb gcc: copy gcc/builder.sh to gcc/common/builder.nix
This commit is left unsquashed to make review of the subsequent
commits easier.
2023-07-07 05:55:15 -07:00
github-actions[bot]
b6ae9ef2db
Merge master into staging-next 2023-07-20 06:01:21 +00:00
github-actions[bot]
e048c645c9
Merge master into staging-next 2023-07-20 00:02:29 +00:00
Adam Joseph
07494a467a
Merge pull request #243615 from amjoseph-nixpkgs/pr/gcc/fix-m68k
gcc: if isM68k, look for libgcc_s.so.2 (instead of .so.1)
2023-07-19 22:10:25 +00:00
github-actions[bot]
972652b656
Merge staging-next into staging 2023-07-14 12:02:21 +00:00
Vladimír Čunát
c4c0e2e2ec
gnat11: avoid the new "fortify3" hardening
It broke build: https://hydra.nixos.org/build/227264335
Motivation: coreboot-toolchain.* depend on gnat11.

It's just a hack-fix.  gnat12 seems OK, just as other languages on 11,
at least those built on Hydra.  /cc PR #224822 which enabled the flag.
2023-07-14 09:04:12 +02:00
John Ericson
badbdfd88d
Merge pull request #243194 from amjoseph-nixpkgs/pr/gcc/crossStageStatic-undo-the-hack
gcc: revert "kludge to prevent mass-rebuild" from #238154
2023-07-13 21:40:51 -04:00
github-actions[bot]
c796e255b3
Merge staging-next into staging 2023-07-14 00:03:13 +00:00
github-actions[bot]
7f792be99d
Merge staging-next into staging 2023-07-13 12:01:50 +00:00
github-actions[bot]
e4fb0591c3
Merge staging-next into staging 2023-07-11 18:01:45 +00:00
Sergei Trofimovich
bc1e68558b
Merge pull request #241980 from trofi/gcc-print-configure-flags
gcc: restore 'Configured with:' output on 'gcc -v' output
2023-07-10 19:23:58 +01:00
Randy Eckenrode
937f472e92
Revert "gcc: fix build on x86_64-darwin"
This reverts commit b39481bc09.
2023-07-09 13:29:11 -06:00
Sergei Trofimovich
41b146ff40 gcc: restore 'Configured with:' output on 'gcc -v' output
When reporting 'gcc' bugs upstream I'm occasionally asked for the actual
configure flags I used to build gcc.

Before the change `gcc -v` always reported empty string:

    $ gcc -v
    ...
    Target: x86_64-unknown-linux-gnu
    Configured with:

After the change `gcc -v` contains original options with slightly
mangled nix store paths to avoid build-only dependency retention:

    $ gcc -v
    ...
    Target: x86_64-unknown-linux-gnu
    Configured with: ../source/configure --prefix=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gcc-14.0.0 --with-gmp-include=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gmp-6.2.1-dev/include --with-gmp-lib=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-gmp-6.2.1/lib --with-mpfr-include=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-mpfr-4.2.0-dev/include --with-mpfr-lib=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-mpfr-4.2.0/lib --with-mpc=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-libmpc-1.3.1 --with-native-system-header-dir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-glibc-2.37-8-dev/include --with-build-sysroot=/ --program-prefix= --enable-lto --disable-libstdcxx-pch --without-included-gettext --with-system-zlib --enable-checking=release --enable-static --enable-languages=c,c++ --disable-multilib --enable-plugin --disable-libcc1 --with-isl=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-isl-0.20 --disable-bootstrap --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu

While a bit verbose I think it's useful to see how we build gcc.
2023-07-08 14:17:51 +01:00
Weijia Wang
b39481bc09 gcc: fix build on x86_64-darwin 2023-07-08 11:03:41 +03:00
Adam Joseph
926c920c12 gcc: tighten condition for inhibit_libc=true
The situation described in the comment preceding `export
inhibit_libc=true` does not match the conditional which follows it.
Specifically, the comment says that this line is meant for "clang
builds gcc" situations, yet it is enabled even when
`!stdenv.cc.isClang`.

This commit tightens the conditional to make it match the situation
described in the comment.
2023-07-07 03:02:47 -07:00
Adam Joseph
424952b7b4 gccWithoutTargetLibc: link libgcc_s.so using -mnewlib if isPower
Closes #244405

Also adds considerably more commenting to document what is going on.
2023-07-06 05:50:26 -07:00
Adam Joseph
a35e1694a8 gcc: if isM68k, look for libgcc_s.so.2 (instead of .so.1)
Closes #243613
2023-07-01 16:45:44 -07:00
Adam Joseph
96a2f1b4e1 gcc: kludge to prevent mass-rebuild
This commit is reverted in #240596 (which must go to staging).
2023-07-01 13:12:41 -07:00
Adam Joseph
63305d00d3 gcc: withoutTargetLibc: build libgcc_s.so
We want a `libgcc_s.so` to be built by the first stage
cross-compiler (withoutTargetLibc), since that is the compiler which
will compile the target libc.

This commit accomplishes that, by making three changes:

1. Replacing the `targetPlatform.libc == "msvcrt" &&` conditional
   with `enableShared`, so that the code which cross-build
   `libgcc_s.so` is used for all cross compilers capable of emitting
   shared libraries.

2. Removing the `targetPlatform == hostPlatform` guard from the code
   which produces the `libgcc` output.

3. Looking for build products in in "lib/${targetPlatform.config}/"
   rather than "lib/", so we will find them when cross compiling.
2023-07-01 13:12:41 -07:00
Adam Joseph
443dfc4b05 gcc: s_crossStageStatic_withoutTargetLibc_
This commit renames the `crossStageStatic` argument to the `gcc`
expression to `withoutTargetLibc`.  See previous commit for details.
2023-07-01 13:12:41 -07:00
Adam Joseph
2affd455a4 gccCrossStageStatic: enable dynamic libraries, rename to gccWithoutTargetLibc
This commit allows `gccCrossStageStatic` to build dynamically-linked
libraries.  Since is no longer restricted to building static
libraries its name is no longer appropriate, and this commit also
renames it to the more-accurate `gccWithoutTargetLibc`.

By default, you can't build a gcc that knows how to create dynamic
libraries unless you have already built the targetPlatform libc.

Because of this, our gcc cross-compiler is built in two stages:

  1. Build a cross-compiler (gccCrossStageStatic) that can build
     only static libraries.

  2. Use gccCrossStageStatic to compile the targetPlatform libc.

  3. Use the targetPlatform libc to build a fully-capable cross
     compiler.

You might notice that this pattern looks very similar to what we do
with `xgcc` in the stdenv bootstrap.  Indeed it is!  I would like to
work towards getting the existing stdenv bootstrap to handle cross
compilers as well.  However we don't want to cripple `stdenv.xgcc`
by taking away its ability to build dynamic libraries.

It turns out that the only thing gcc needs the targetPlatform libc
for is to emit a DT_NEEDED for `-lc` into `libgcc.so`.  That's it!
And since we don't use `gccCrossStageStatic` to build anything other
than libc, it's safe to omit the `DT_NEEDED` because that `libgcc`
will never be loaded by anything other than `libc`.  So `libc` will
already be in the process's address space.

Other people have noticed this; crosstool-ng has been using this
approach for a very long time:

  36ad0b17a7/scripts/build/cc/gcc.sh (L638-L640)
2023-07-01 13:12:40 -07:00
Adam Joseph
e41f217257 gcc: use hasSharedLibraries instead of isStatic 2023-07-01 13:12:22 -07:00
Adam Joseph
c04c1a1777 Revert "gcc: kludge to prevent mass-rebuild"
This reverts commit 8dce1f7383b064ae5adee7702a8eeed06346dd24.
2023-06-30 02:28:13 -07:00
Adam Joseph
91ef45c98a gcc: disable glibc<->libgcc circularity workaround for windows and LLVM
This essentially reverts #238154 if `isWindows` or `useLLVM`, the
two cases where it caused breakage:

  https://github.com/NixOS/nixpkgs/pull/238154#issuecomment-1633752094

Since #238154 exists mainly for `isGNU` (i.e. due to the
glibc<->libgcc circular dependency) disabling it here isn't a big deal.
2023-06-30 01:39:58 -07:00
Adam Joseph
0344bcbcf4 gcc: deduplicate boilerplate
This commit deduplicates libgcc-related boilerplate which appears in
every version of our gcc expression, by moving it into libgcc.nix.

I will be submitting a separate PR which changes this boilerplate,
but that PR will be much easier to review if I can make the change
in just one place.

Meanwhile, *this* commit has no effect on eval:

$ for A in 10  11  12  13  4.8  4.9  6  7  8  9; do nix-instantiate . -A gcc$(echo $A | tr -d .); done 2>/dev/null | sort | tee before
/nix/store/1a37lnzpnz0dhm3lphiy2gcdrxgqa7ma-gcc-wrapper-4.8.5.drv
/nix/store/5szdivc8il0c3g94dq4wqnq5j77a9h6p-gcc-wrapper-11.4.0.drv
/nix/store/bmmc717wmnp1j2xkd3if5dfxicnflvn5-gcc-wrapper-7.5.0.drv
/nix/store/fc1ggpixv3wqcazchhl2hnn5zl5ds30l-gcc-wrapper-13.1.0.drv
/nix/store/j9c2b20w35r3ag5nxmklhagbwsgjhds2-gcc-wrapper-4.9.4.drv
/nix/store/nq7q57bxmsk2g457wr4b9449as3f216w-gcc-wrapper-12.3.0.drv
/nix/store/sqmkkfapzykapcs4azvxm83n786ga7q1-gcc-wrapper-10.4.0.drv
/nix/store/vxnz30i23mkl4ldsq485kxn7q0p2y4nf-gcc-wrapper-8.5.0.drv
/nix/store/yfhv0bv15cg5kj2xsb9fcgb6pdlw42v0-gcc-wrapper-6.5.0.drv
/nix/store/yi5gr75pb6kddnll10jg25hhndhkba7s-gcc-wrapper-9.5.0.drv

$ for A in 10  11  12  13  4.8  4.9  6  7  8  9; do nix-instantiate . -A gcc$(echo $A | tr -d .); done | sort | tee after
/nix/store/1a37lnzpnz0dhm3lphiy2gcdrxgqa7ma-gcc-wrapper-4.8.5.drv
/nix/store/5szdivc8il0c3g94dq4wqnq5j77a9h6p-gcc-wrapper-11.4.0.drv
/nix/store/bmmc717wmnp1j2xkd3if5dfxicnflvn5-gcc-wrapper-7.5.0.drv
/nix/store/fc1ggpixv3wqcazchhl2hnn5zl5ds30l-gcc-wrapper-13.1.0.drv
/nix/store/j9c2b20w35r3ag5nxmklhagbwsgjhds2-gcc-wrapper-4.9.4.drv
/nix/store/nq7q57bxmsk2g457wr4b9449as3f216w-gcc-wrapper-12.3.0.drv
/nix/store/sqmkkfapzykapcs4azvxm83n786ga7q1-gcc-wrapper-10.4.0.drv
/nix/store/vxnz30i23mkl4ldsq485kxn7q0p2y4nf-gcc-wrapper-8.5.0.drv
/nix/store/yfhv0bv15cg5kj2xsb9fcgb6pdlw42v0-gcc-wrapper-6.5.0.drv
/nix/store/yi5gr75pb6kddnll10jg25hhndhkba7s-gcc-wrapper-9.5.0.drv

$ diff -u after before
$
2023-06-27 19:21:49 -07:00
Alyssa Ross
0f2191f3b2
Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
	pkgs/development/compilers/gcc/11/default.nix
2023-06-22 06:23:16 +00:00
Janne Heß
61e5bba2b7
gcc11: 11.3.0 -> 11.4.0 2023-06-19 07:48:37 +02:00
Arnout Engelen
f6a7658c51
gcc: disable parallelism when installing
to avoid missing sections in the info pages due
the index being overwritten by parallel `install-info`
invocations
2023-06-13 17:16:23 +02:00
Arnout Engelen
e8d0aa9d19
Revert "gcc: install info files serially"
Because the build still uses a pre-4.4 version of GNU Make,
this option makes the whole build serial rather than only
the installation.

See also https://gcc.gnu.org/PR109898

This reverts commit f3995cee01.
2023-06-13 17:16:20 +02:00
github-actions[bot]
9f2767ce37
Merge staging-next into staging 2023-06-10 18:01:41 +00:00
Daniel Nagy
ca2cb9f644 treewide: "libary" -> "library" 2023-06-10 14:54:08 +01:00
Artturi
69b154f738
Merge pull request #234204 from vcunat/p/gcc-nofetch-patch 2023-06-08 17:53:58 +03:00
Sergei Trofimovich
aaf4f4acca
Merge pull request #234887 from trofi/mingw-w64-gcc-13-fix
gcc13: drop already upstreamed mingwW64 patch
2023-06-06 08:05:23 +01:00
Sergei Trofimovich
9de90335f9 gcc13: drop already upstreamed mingwW64 patch
Without the change the patch failed to apply as:

```
$ nix build -f. pkgsCross.mingwW64.stdenv.cc.cc
...
x86_64-w64-mingw32-stage-final-gcc> applying patch /nix/store/sb9irfs83qvdgkf23agvv1vn96n9z31p-Added-mcf-thread-model-support-from-mcfgthread.patch
x86_64-w64-mingw32-stage-final-gcc> patching file config/gthr.m4
x86_64-w64-mingw32-stage-final-gcc> Reversed (or previously applied) patch detected!  Assume -R? [n]
x86_64-w64-mingw32-stage-final-gcc> Apply anyway? [n]
x86_64-w64-mingw32-stage-final-gcc> Skipping patch.
...
```

The patch is apready present in gcc-13.1.0.
2023-05-29 22:40:07 +01:00
Sergei Trofimovich
e1356f9958
Merge pull request #232075 from trofi/gcc12-update
gcc12: 12.2.0 -> 12.3.0
2023-05-29 10:05:32 +01:00
Sergei Trofimovich
c78434b2cd gcc12: 12.2.0 -> 12.3.0
Added an ICE backport for `ccache` build failure.
2023-05-27 09:42:47 +01:00
Vladimír Čunát
c98d687fd6
gcc{6..11}: import a patch into nixpkgs
fetchurl can't be used on generated patches this way.
The hash doesn't match anymore.  fetchpatch would be an alternative.
2023-05-26 12:55:25 +02:00
Elias Naur
8d2846edbb
gcc: only disable aligned_alloc for darwin build/host/target platforms (#226290)
Before this change a Darwin gcc would output binaries that avoid
aligned_alloc, regardless of target platform. That's fine for Darwin
targets, but not for non-darwin targets such as pkgsCross.raspberryPi.

This change replaces the single configure flag with a flag for
each of build, host, target.

Idea by @trofi.
2023-05-16 19:43:17 -04:00
Sergei Trofimovich
e86e25fd5d
Merge pull request #228388 from trofi/gcc13
gcc13, gccgo13, gfortran13, gnat13: init at 13.1.0
2023-05-13 21:16:40 +01:00
Sergei Trofimovich
4b8b00f56c gcc13, gccgo13, gfortran13, gnat13: init at 13.1.0
It's a copy of `gcc12.cc` implementation. Nothing special added here.

Note that gccgo13 does not build yet (similar to existing gccgo12).
The failure is related to libgcc_s.so lookup problems. Not specific
to gcc-13 release.

Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-05-13 13:18:08 +01:00
Vladimír Čunát
ae3f6c9c6d
Merge #229898: gcc: install info files serially
...into staging
2023-05-10 08:39:57 +02:00
Arnout Engelen
f3995cee01
gcc: install info files serially
installing info files in parallel is dangerous, because
`install-info` will write to a `dir-file` as a side-effect,
and it has no protection against multiple `install-info`
processes running in parallel and overwriting each others'
changes.

Local fix until we can fix the `Makefile.in` generation
upstream

Fixes #229470
2023-05-09 19:02:41 +02:00
Adam Joseph
e1842769ae
Merge pull request #228296 from amjoseph-nixpkgs/pr/gcc/libsanitizer/mips64n32
gcc: disable libsanitizer on mips64n32
2023-05-05 06:54:41 +00:00
Alyssa Ross
7f4280c538 pkgsStatic.gcc: fix build
There's no libgcc.so in a static-only build.
2023-05-03 18:35:51 +00:00
Vladimír Čunát
586616fd4b
Merge #228606: gcc: fix fastStdenv breakage from #209870 2023-05-01 17:21:42 +02:00
Adam Joseph
cfc4c95770 gcc: fix fastStdenv breakage from #209870
Apparently gcc has these `Makefile` targets:

- `""`
- `"bootstrap"`
- `"profiledbootstrap"`

... but no `"profiled"`.  So if you want a profiled compiler, at the
moment, it should be bootstrapped.

If we ever decide to make the nixpkgs bootstrap use a profiled
compiler (which at the moment means nondeterminism) a Nix-driven
profile loop is certainly possible, but would take some work.

Closes #228597.
2023-04-27 15:22:06 -07:00
Elias Naur
c10a195ab1 gcc: tighten platform flags special-case for aarch64-darwin
The 4aa95e3312 commit added support for
aarch64-darwin but also ignored platform flags if the build platform
is aarch64-darwin. This leads to confusing errors such as
`pkgsCross.raspberryPi` packages compiled with soft-float even though
the platform supports hard-float (and is built as such on other
platforms).

The correct way to ignore platform flags is to check `targetPlatform`,
not the build platform. This change fixes that.

While we're here, tigthen the special-case to cover only the problematic
flags: `-with-cpu` and `-with-arch`.
2023-04-27 15:57:17 -06:00
Weijia Wang
5378f9a6c2 gccgo: fix build 2023-04-27 10:52:46 +03:00
Adam Joseph
c289fc341b gcc: disable libsanitizer on mips64n32
On MIPS, libsanitizer appears to have very detailed knowledge of the
Linux system call ABI manually encoded, by hand, into the library.
This encoding covers the o32 and 64 abis, but does not cover n32.
Adding support for n32 would be a major undertaking.

Without adding this encoding, builds of gcc will fail with errors
including (but not limited to) the following:

```
In file included from ../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp:21:
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp:75:38: error: static assertion failed
   75 | COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));
      |                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:348:44: note: in definition of macro 'COMPILER_CHECK'
  348 | #define COMPILER_CHECK(pred) static_assert(pred, "")
      |                                            ^~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp:75:38: note: the comparison reduces to '(144 == 160)'
   75 | COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));
      |                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:348:44: note: in definition of macro 'COMPILER_CHECK'
  348 | #define COMPILER_CHECK(pred) static_assert(pred, "")
      |                                            ^~~~
...
In file included from ../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:184:
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp: In function '__sanitizer::uptr __sanitizer::internal_mmap(void*, uptr, int, int, int, u64)':
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc:19:24: error: '__NR_mmap2' was not declared in this scope
   19 | # define SYSCALL(name) __NR_ ## name
      |                        ^~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:198:27: note: in expansion of macro 'SYSCALL'
  198 |   return internal_syscall(SYSCALL(mmap2), addr, length, prot, flags, fd,
      |                           ^~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp: In function 'void __sanitizer::stat64_to_stat(stat64*, stat*)':
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:279:23: error: 'struct stat64' has no member named 'st_atim'; did you mean 'st_atime'?
  279 |   out->st_atime = in->st_atime;
      |                       ^~~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:280:23: error: 'struct stat64' has no member named 'st_mtim'; did you mean 'st_mtime'?
  280 |   out->st_mtime = in->st_mtime;
      |                       ^~~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:281:23: error: 'struct stat64' has no member named 'st_ctim'; did you mean 'st_ctime'?
  281 |   out->st_ctime = in->st_ctime;
      |                       ^~~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp: In function '__sanitizer::uptr __sanitizer::internal_stat(const char*, void*)':
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc:19:24: error: '__NR_stat64' was not declared in this scope
   19 | # define SYSCALL(name) __NR_ ## name
      |                        ^~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:353:30: note: in expansion of macro 'SYSCALL'
  353 |   int res = internal_syscall(SYSCALL(stat64), path, &buf64);
      |                              ^~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp: In function '__sanitizer::uptr __sanitizer::internal_lstat(const char*, void*)':
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc:19:24: error: '__NR_lstat64' was not declared in this scope
   19 | # define SYSCALL(name) __NR_ ## name
      |                        ^~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:378:30: note: in expansion of macro 'SYSCALL'
  378 |   int res = internal_syscall(SYSCALL(lstat64), path, &buf64);
      |                              ^~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp: In function '__sanitizer::uptr __sanitizer::internal_fstat(fd_t, void*)':
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc:19:24: error: '__NR_fstat64' was not declared in this scope
   19 | # define SYSCALL(name) __NR_ ## name
      |                        ^~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:397:30: note: in expansion of macro 'SYSCALL'
  397 |   int res = internal_syscall(SYSCALL(fstat64), fd, &buf64);
      |                              ^~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp: At global scope:
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_linux.cpp:303:13: warning: 'void __sanitizer::kernel_stat_to_stat(kernel_stat*, stat*)' defined but not used [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-function-Wunused-function8;;]
  303 | static void kernel_stat_to_stat(struct kernel_stat *in, struct stat *out) {
      |             ^~~~~~~~~~~~~~~~~~~
mv -f .deps/sanitizer_mutex.Tpo .deps/sanitizer_mutex.Plo
make[4]: *** [Makefile:617: sanitizer_linux.lo] Error 1
mv -f .deps/sancov_flags.Tpo .deps/sancov_flags.Plo
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_posix.cpp: In function '__sanitizer::fd_t __sanitizer::OpenFile(const char*, FileAccessMode, error_t*)':
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_posix.cpp:162:27: warning: 'flags' may be used uninitialized [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmaybe-uninitialized-Wmaybe-uninitialized8;;]
  162 |   fd_t res = internal_open(filename, flags, 0660);
      |              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../../../../gcc-12.2.0/libsanitizer/sanitizer_common/sanitizer_posix.cpp:156:7: note: 'flags' was declared here
  156 |   int flags;
      |       ^~~~~
```
2023-04-26 21:50:15 -07:00
github-actions[bot]
3d3f04baba
Merge staging-next into staging 2023-04-17 00:02:39 +00:00
Vladimír Čunát
cdf4c593d8
Merge #170215: powerpc64*: use --with-long-double-format=ieee
...into staging
2023-04-16 09:20:57 +02:00
Manuel Mendez
31d6802773 gnatboot: rename to gnat-bootstrap
Most other bootstrap compilers are named -bootstrap so lets follow that
pattern.
2023-04-15 18:52:14 -04:00
Artturi
a2da3d62a6
Merge pull request #225220 from amjoseph-nixpkgs/pr/gfortran/do-not-disable-bootstrap 2023-04-11 22:33:14 +03:00
Adam Joseph
e199e42538
Merge pull request #225595 from trofi/gcc-no-statx-fix
gcc: drop include-fixed/bits/statx.h
2023-04-11 17:45:49 +00:00
Adam Joseph
f06ab170fa gcc: never disableBootstrap for gfortran
As suggested by @trofi here:

  https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500635687

This should fix failures among packages which use gfortran:

  https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500550903
  https://hydra.nixos.org/build/215195834
2023-04-11 20:19:58 +03:00
Artturin
b1d4dfddaf Revert "julia{18,19,}: fix build by a temporary hack"
This reverts commit e2691227cd.
2023-04-11 20:19:58 +03:00
Sergei Trofimovich
84822c43fc gcc: drop include-fixed/bits/statx.h
At least on armv7l-linux bootstrapTools fixed version of bits/statx.h
breaks the header:
    https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1501201452

Drop the header along with other already cleaned ones.
2023-04-10 17:04:03 +01:00
Vladimír Čunát
e2691227cd
julia{18,19,}: fix build by a temporary hack
This is a low-rebuild version of PR #225273
/cc the proper and hopefully complete fix in PR #225220
2023-04-10 16:36:55 +02:00
Adam Joseph
1b771711b6 gcc: do not --disable-bootstrap, create libgcc output, or create checksum output on Darwin 2023-04-05 21:36:09 -07:00
Adam Joseph
deda18bae8 gcc: only pass --with-long-double-format if gcc allows it 2023-04-05 15:54:38 -07:00