Commit Graph

661 Commits

Author SHA1 Message Date
a-n-n-a-l-e-e
d7425f0f21
Merge pull request #288250 from trofi/make-bootstrap-tools-cross-new-target
pkgs/stdenv/linux/make-bootstrap-tools-cross.nix: allow entries for t…
2024-03-04 05:18:39 -08:00
Vladimír Čunát
e81960770a
Merge #288866: pkgs/stdenv/linux: update x86_64-unknown-linux-gnu bootstrap-files
...into staging
2024-02-17 10:38:31 +01:00
Sergei Trofimovich
a0f80e965c pkgs/stdenv/linux/make-bootstrap-tools-cross.nix: allow entries for to-be uplaoded targets
Newly added targets should be fine to be added as hudra jobs before the
first uplaod happens.

Co-authored-by: Cosima Neidahl <opna2608@protonmail.com>
2024-02-15 09:08:58 +00:00
Sergei Trofimovich
74c4e93541 pkgs/stdenv/linux: update x86_64-unknown-linux-gnu bootstrap-files
sha256sum of files to be uploaded:

$ sha256sum /nix/store/dw6vr6m5w7ysrdrbs0s5wdgbjmbnr7gx-stdenv-bootstrap-tools/on-server/*
61096bd3cf073e8556054da3a4f86920cc8eca81036580f0d72eb448619b50cd  /nix/store/dw6vr6m5w7ysrdrbs0s5wdgbjmbnr7gx-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz
87627883b1517087d1c34fadc340bc8deafb3782eb0c60035271822c64dd3401  /nix/store/dw6vr6m5w7ysrdrbs0s5wdgbjmbnr7gx-stdenv-bootstrap-tools/on-server/busybox

Suggested commands to upload files to 'tarballs.nixos.org':

    $ nix-store --realize /nix/store/dw6vr6m5w7ysrdrbs0s5wdgbjmbnr7gx-stdenv-bootstrap-tools
    $ aws s3 cp --recursive --acl public-read /nix/store/dw6vr6m5w7ysrdrbs0s5wdgbjmbnr7gx-stdenv-bootstrap-tools/on-server/ s3://nixpkgs-tarballs/stdenv/x86_64-unknown-linux-gnu/82b583ba2ba2e5706b35dbe23f31362e62be2a9d
    $ aws s3 cp --recursive s3://nixpkgs-tarballs/stdenv/x86_64-unknown-linux-gnu/82b583ba2ba2e5706b35dbe23f31362e62be2a9d ./
    $ sha256sum bootstrap-tools.tar.xz busybox
    $ sha256sum /nix/store/dw6vr6m5w7ysrdrbs0s5wdgbjmbnr7gx-stdenv-bootstrap-tools/on-server/*
2024-02-13 09:10:00 +00:00
Bernardo Meurer
d73b17633c
Merge pull request #285906 from trofi/update-x86_64-unknown-linux-musl-bootstrap-files
pkgs/stdenv/linux: update x86_64-unknown-linux-musl bootstrap-files
2024-02-05 14:18:03 -05:00
Sergei Trofimovich
5de19bf709 pkgs/stdenv/linux: update x86_64-unknown-linux-musl bootstrap-files
sha256sum of files to be uploaded:

$ sha256sum /nix/store/b0x0qcbf1gsp50jzw52sbbgdp3jlwcjf-stdenv-bootstrap-tools/on-server/*
b745b6311ed4c2d3f260419c468f543ae5df68fe2e5192995c499819c04eb8e0  /nix/store/b0x0qcbf1gsp50jzw52sbbgdp3jlwcjf-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz
f4ae6a814d5053b396af788cd47629385cbfa17df5197ff3c33de62dc1dd9116  /nix/store/b0x0qcbf1gsp50jzw52sbbgdp3jlwcjf-stdenv-bootstrap-tools/on-server/busybox

Suggested commands to upload files to 'tarballs.nixos.org':

    $ nix-store --realize /nix/store/b0x0qcbf1gsp50jzw52sbbgdp3jlwcjf-stdenv-bootstrap-tools
    $ aws s3 cp --recursive --acl public-read /nix/store/b0x0qcbf1gsp50jzw52sbbgdp3jlwcjf-stdenv-bootstrap-tools/on-server/ s3://nixpkgs-tarballs/stdenv/x86_64-unknown-linux-musl/125cefd4cf8f857e5ff1aceaef9230ba578a033d
    $ aws s3 cp --recursive s3://nixpkgs-tarballs/stdenv/x86_64-unknown-linux-musl/125cefd4cf8f857e5ff1aceaef9230ba578a033d ./
    $ sha256sum bootstrap-tools.tar.xz busybox
    $ sha256sum /nix/store/b0x0qcbf1gsp50jzw52sbbgdp3jlwcjf-stdenv-bootstrap-tools/on-server/*
2024-02-02 20:32:44 +00:00
Bernardo Meurer
f228f378e3
Merge pull request #284542 from trofi/i686-linux-bootstrap-update 2024-01-29 21:21:40 -05:00
Sergei Trofimovich
46dae33dd9 pkgs/stdenv/linux: update i686-unknown-linux-gnu bootstrap-files
sha256sum of files to be uploaded:

$ sha256sum /nix/store/5x6dldhza7if5s6wsicaxa8fbndyixps-stdenv-bootstrap-tools/on-server/*
293021dedf7568932230effb3453a3533e9f5c8f48bbe1fb72e383ade5b3f4df  /nix/store/5x6dldhza7if5s6wsicaxa8fbndyixps-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz
d5bffc3231c9f95699ee34118e26bc788e09c608735e5edb2b433057011fddd1  /nix/store/5x6dldhza7if5s6wsicaxa8fbndyixps-stdenv-bootstrap-tools/on-server/busybox

Suggested commands to upload files to 'tarballs.nixos.org':

    $ nix-store --realize /nix/store/5x6dldhza7if5s6wsicaxa8fbndyixps-stdenv-bootstrap-tools
    $ aws s3 cp --recursive --acl public-read /nix/store/5x6dldhza7if5s6wsicaxa8fbndyixps-stdenv-bootstrap-tools/on-server/ s3://nixpkgs-tarballs/stdenv/i686-unknown-linux-gnu/125cefd4cf8f857e5ff1aceaef9230ba578a033d
    $ aws s3 cp --recursive s3://nixpkgs-tarballs/stdenv/i686-unknown-linux-gnu/125cefd4cf8f857e5ff1aceaef9230ba578a033d ./
    $ sha256sum bootstrap-tools.tar.xz busybox
    $ sha256sum /nix/store/5x6dldhza7if5s6wsicaxa8fbndyixps-stdenv-bootstrap-tools/on-server/*
2024-01-28 14:49:11 +00:00
Weijia Wang
4354538139 Merge branch 'staging-next' into staging 2024-01-27 04:17:36 +01:00
Alyssa Ross
ea67e455d3 stdenvBootstrapTools: update aarch64 musl
The aarch64 musl bootstrap tools are woefully outdated.  Just getting
them to the point of being able to build new versions of themselves
required a number of hacks[1] that can be reverted once we have new
bootstrap tools, and before that it stdenv didn't even build for the
preceding three years.

[1]: https://github.com/NixOS/nixpkgs/pull/169764

So, following the script established by previous bootstrap tools
updates:

Files came from this Hydra build:

	https://hydra.nixos.org/build/246470544

…which used nixpkgs revision dd5621df6d
to instantiate:

	/nix/store/g480ass2vjmakaq03z7k2j95xnxh206a-stdenv-bootstrap-tools.drv

…and then built:

	/nix/store/95lm0y33dayag4542s8bi83s31bw68dr-stdenv-bootstrap-tools

I downloaded these files from Hydra and prefetched them into the Nix
store with the following commands:

	STOREPATH=95lm0y33dayag4542s8bi83s31bw68dr-stdenv-bootstrap-tools
	OPTIONS="--option binary-caches https://cache.nixos.org --option trusted-public-keys cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
	nix --extra-experimental-features nix-command store prefetch-file \
	  file://$(nix --extra-experimental-features nix-command store add-file --name bootstrap-tools.tar.xz  $(nix-store ${OPTIONS} -r /nix/store/${STOREPATH})/on-server/bootstrap-tools.tar.xz)
	nix --extra-experimental-features nix-command store prefetch-file --executable \
	  file://$(nix --extra-experimental-features nix-command store add-path --name busybox $(nix-store ${OPTIONS} -r /nix/store/${STOREPATH})/on-server/busybox)

These commands produced the following output:

	warning: you did not specify '--add-root'; the result might be removed by the garbage collector
	Downloaded 'file:///nix/store/fm8ys5bb737j82xgyiciyzpcwmzyi9b2-bootstrap-tools.tar.xz' to '/nix/store/jml0gh0q2rnc9sgr87irz0jfbl0fq545-fm8ys5bb737j82xgyiciyzpcwmzyi9b2-bootstrap-tools.tar.xz' (hash 'sha256-ZY9IMOmx1VOn6uoFDpdJbTnPX59TEkrVCzWNtjQ8/QE=').
	warning: you did not specify '--add-root'; the result might be removed by the garbage collector
	Downloaded 'file:///nix/store/rn9fx55mw2s0qg90zdjxa9xn11nlmjpg-busybox' to '/nix/store/9qylz8gqll63pprwkwlyfs9g4zilak2m-rn9fx55mw2s0qg90zdjxa9xn11nlmjpg-busybox' (hash 'sha256-WuOaun7U5enbOy8SuuCo6G1fbGwsO16jhy/oM8K0lAs=').

I used the hashes from the output above to create the fetchurl
invocation which is part of this commit.

I then started the bootstrap with the following command:

	nix --extra-experimental-features nix-command build -L -f . --arg localSystem '(import ./lib).systems.examples.aarch64-multiplatform-musl' hello

As @lovesegfault requested, here are the the sha256sums of all the
on-server components for extra verification:

	sha256sum /nix/store/${STOREPATH}/on-server/*

…which produced the following output:

	658f4830e9b1d553a7eaea050e97496d39cf5f9f53124ad50b358db6343cfd01  /nix/store/95lm0y33dayag4542s8bi83s31bw68dr-stdenv-bootstrap-tools/on-server/bootstrap-tools.tar.xz
	20cdfecb084ddb6b6b958f2b78fd2cc1d9641632f81ec7d5a48fae0a963ad0fa  /nix/store/95lm0y33dayag4542s8bi83s31bw68dr-stdenv-bootstrap-tools/on-server/busybox
2024-01-25 18:13:54 +01:00
github-actions[bot]
7af142cf2c
Merge staging-next into staging 2024-01-22 00:02:41 +00:00
Francesco Gazzetta
0d7c62f5c9 pkgs/stdenv/linux: update riscv64 bootstrap-files
This PR updates the bootstrap tarballs for riscv64-linux with new Hydra-generated ones.

Fixes #275848 (bootstrap assembler too old to build gcc 13).

I'll be following the script used in #151399, #168199, #183487, and #188334.

Files came from [this](https://hydra.nixos.org/build/246376732#tabs-summary) Hydra build, which used nixpkgs revision 160cedc144 to instantiate:

```
/nix/store/cpiajh4l83b08pynwiwkpxj53d78pcxr-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu.drv
```

and then built:

```
/nix/store/8a92pj40awdw585mcb9dvm4nyb03k3q3-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu
```

I downloaded these files from Hydra and prefetched them into the nix store with the following commands:

```
STOREPATH=8a92pj40awdw585mcb9dvm4nyb03k3q3-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu
OPTIONS="--option binary-caches https://cache.nixos.org --option trusted-public-keys cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
nix store prefetch-file \
  file://$(nix store add-file --name bootstrap-tools.tar.xz  $(nix-store ${OPTIONS} -r /nix/store/${STOREPATH})/on-server/bootstrap-tools.tar.xz)
nix store prefetch-file --executable \
  file://$(nix store add-path --name busybox $(nix-store ${OPTIONS} -r /nix/store/${STOREPATH})/on-server/busybox)
```

These commands produced the following output:

```
Downloaded 'file:///nix/store/xs74wcxq3qc12plfc70fds8inbndhcfm-bootstrap-tools.tar.xz' to '/nix/store/3fal4gikp92013kac6rdmfbrch2s859b-xs74wcxq3qc12plfc70fds8inbndhcfm-bootstrap-tools.tar.xz' (hash 'sha256-0LxRd7fdafQezNJ+N2tuOfm0KEwgfRSts5fhP0e0r0s=').
Downloaded 'file:///nix/store/9ndpna6jrlac4y9fappdjm0sxx0g2bja-busybox' to '/nix/store/kb7wyy30y1gxcmdajljr26kxxac606qa-9ndpna6jrlac4y9fappdjm0sxx0g2bja-busybox' (hash 'sha256-OGO96QUzs2n5pGipn/V87AxzUY9OWKZl417nE8HdZIE=').
```

I used the hashes from the output above to create the `fetchurl` invocation which is part of this commit.

I then started the bootstrap with the following command:

```
nix build -L -f . --arg localSystem '(import ./lib).systems.examples.riscv64' hello
```

As @lovesegfault requested, here are the the `sha256sum`s of all the `on-server` components for extra verification:

```
sha256sum /nix/store/${STOREPATH}/on-server/*
```

which produced the following output:

```
d0bc5177b7dd69f41eccd27e376b6e39f9b4284c207d14adb397e13f47b4af4b  /nix/store/8a92pj40awdw585mcb9dvm4nyb03k3q3-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/bootstrap-tools.tar.xz
65f9433abb598f63c932d33351b14f686551512b1cece1e64c2d0e76aa0ec52e  /nix/store/8a92pj40awdw585mcb9dvm4nyb03k3q3-stdenv-bootstrap-tools-riscv64-unknown-linux-gnu/on-server/busybox
```
2024-01-20 16:27:22 +01:00
Robert Scott
40868719b0 cc-wrapper: add zerocallusedregs hardening flag
this uses the value `used-gpr` which seems to be a commonly
chosen value for general use
2024-01-20 13:48:33 +00:00
Sergei Trofimovich
3f3e74bc93 stdenv: fix eval of pkgsMusl packages with platform constraints
Before the change `pkgsMusl.adobe-reader` was failing the interpreter:

    $ nix-instantiate --eval --strict --expr 'with import ./. {}; builtins.tryEval pkgsMusl.adobe-reader'
error:
       error: evaluation aborted with the following error message: 'unsupported platform for the pure Linux stdenv'

After the change `pkgsMusl.adobe-reader` returns catchable excation:

    $ nix-instantiate --eval --strict --expr 'with import ./. {}; builtins.tryEval pkgsMusl.adobe-reader'
    { success = false; value = false; }

Noticed when was exploring `nixpkgs` for uncatchable evaluation errors.
Ideally those should only happen when there is a code bug in the use
site. In this case it's just a package with incompatible constraints for
`musl`.

Changed uncatchable `abort` to `throw`.
2023-12-28 15:29:29 +00:00
Artturin
1b3831f1e6 stdenv: fix typo 2023-10-21 00:26:57 +03:00
Artturin
1270ef59e9 bootstrap-tools-cross: Rename bootstrap file jobs to be more descriptive
Rename files in `bootstrap-files/` to match jobs in `make-bootstrap-tools-cross`.

Should make automating the bootstrap files easier.

```nix
$ nix repl --file ./pkgs/top-level/release-cross.nix
nix-repl> bootstrapTools
{ aarch64-unknown-linux-gnu = { ... }; aarch64-unknown-linux-musl = { ... }; armv5tel-unknown-linux-gnueabi = { ... }; armv6l-unknown-linux-gnueabihf = { ... }; armv6l-unknown-linux-musleabihf = { ... }; armv7l-unknown-linux-gnueabihf = { ... }; mips64el-unknown-linux-gnuabi64 = {... }; mips64el-unknown-linux-gnuabin32 = { ... }; mipsel-unknown-linux-gnu = { ... }; powerpc64le-unknown-linux-gnu = { ... }; riscv64-unknown-linux-gnu = { ... }; x86_64-unknown-linux-musl = { ... }; }
```

Additionally if non-linux bootstrap files are added to
`make-bootstrap-tools-cross` then there won't be any renaming needed.
2023-10-03 23:34:40 +03:00
Artturi
ece37b8aa4
Merge pull request #258476 from Artturin/bootstrapthingies2 2023-10-02 09:10:31 +03:00
Artturin
0848edf7a0 bootstrap-tools-cross: Add a note about what should be here 2023-10-02 01:30:11 +03:00
Artturin
46ecf91843 stdenv: remove unused loongson2f bootstrap files
The last use of it was removed in (linux/default.nix: use mipsel.nix instead of longson.nix for mips32)[e8b10284f3].
2023-10-02 00:35:57 +03:00
Artturin
a1c2c50cbc bootstrap-tools-cross: sort 2023-10-01 23:54:45 +03:00
Artturin
df7bf17643 bootstrap-tools-cross: remove bootstrap files for systems which are not used in stdenv/linux/default.nix 2023-10-01 23:53:15 +03:00
Artturin
d0efa70d81 Revert "Revert "Merge pull request #253760 from chivay/bootstrap-scrt""
This reverts commit 3f46cdcb5b.
2023-09-30 15:17:47 -04:00
Bernardo Meurer
3f46cdcb5b
Revert "Merge pull request #253760 from chivay/bootstrap-scrt"
This reverts commit ab66640da3, reversing
changes made to c08b005e0f.

The changes were merged without the associated bootstrap updates.
2023-09-08 15:15:07 -03:00
Hubert Jasudowicz
3cc00c9502 stdenvBootstrapTools: Bundle all *.o files from libc
Include all runtime object files in output package, enabling different
kinds of build modes - non-PIE, PIE, static PIE and profile-generated.

Suggested by @trofi:
https://github.com/NixOS/nixpkgs/pull/252310#issuecomment-1709425791
2023-09-07 23:22:02 +02:00
Robert Scott
95c4a1fe96 cc-wrapper: include fortify-headers before libc includes for musl 2023-08-06 17:52:28 +01:00
Adam Joseph
b9c1ae2a5f stdenv: eliminate duplicate gnu-config in extraNativeBuildInputs
Accidentally omitted from #237968.
2023-06-16 02:33:57 -07:00
Adam Joseph
3b8e3c1f3d stdenv: updateAutotoolsGnuConfigScriptsHook unconditionally
Unlike autoreconfHook, updateAutotoolsGnuConfigScriptsHook adds
almost no compilations.  Therefore, in the interest of building the
same source code on every platform wherever possible, let's
eliminate the conditional guards around
updateAutotoolsGnuConfigScriptsHook in stdenv.
2023-06-15 19:47:38 -07:00
Weijia Wang
91b69f8555
Merge pull request #228714 from helsinki-systems/upd/gnugrep
[staging] gnugrep: 3.7 -> 3.11
2023-05-24 12:47:48 +03:00
Sergei Trofimovich
c3bdae6ce5
Merge pull request #223861 from eliasnaur/no-nix-lib64-in-self-rpath
stdenv: don't set NIX_LIB*_IN_SELF_RPATH by default
2023-05-17 07:08:57 +01:00
Janne Heß
11c8f46850
gnugrep/stdenv: Fix PCRE support by replacing PCRE lib 2023-05-15 10:21:34 +02:00
Weijia Wang
e2adc3a3a2 bootstrap-tools-cross: add loongarch64-linux 2023-05-04 09:51:11 +03:00
Weijia Wang
658f507622
Merge pull request #229289 from wegank/loongarch64-cross-bootstrap
pkgsCross.loongarch64-linux.freshBootstrapTools.bootstrapFiles: fix build
2023-05-02 22:39:14 +03:00
Weijia Wang
c78d0d9d39 pkgsCross.loongarch64-linux.freshBootstrapTools.bootstrapFiles: fix build 2023-05-02 20:25:05 +03:00
Weijia Wang
e6e3e4da34
Merge pull request #229372 from wegank/loongarch64-native-bootstrap
stdenv: always update config script on loongarch64-linux
2023-05-02 18:49:43 +03:00
Weijia Wang
b017e29705 stdenv: always update config script on loongarch64-linux 2023-05-02 01:02:57 +03:00
Alyssa Ross
5130c4f4ef freshBootstrapTools: enable musl on RISC-V
musl now supports RISC-V.  Let's centralise musl availability checks
in musl.meta.platforms, so we don't have to keep cleaning up ad-hoc
checks like this all over the tree.
2023-05-01 11:25:04 +00:00
Adam Joseph
bc024e10ef
Merge pull request #228281 from amjoseph-nixpkgs/pr/bootstrapFiles/cross/fix
stdenvBootstrapTools: drop no-longer-needed, now-broken cross clause
2023-04-27 03:58:30 +00:00
Adam Joseph
38f41a27b4 stdenvBootstrapTools: drop no-longer-needed, now-broken cross clause
The comment stating that "GCC has certain things built in
statically" is no longer true as of
https://github.com/NixOS/nixpkgs/pull/209870.  Moreover, as pointed
out in https://github.com/NixOS/nixpkgs/pull/228130 this
optionalString block no longer builds for
pkgsCross.*.freshBootstrapTools.

It is safe to drop this clause now.
2023-04-26 00:02:00 -07:00
github-actions[bot]
9dd2031c08
Merge staging-next into staging 2023-04-06 16:11:47 +00:00
Adam Joseph
3778e07994 stdenv: fix pkgsMusl
I broke `pkgsMusl` with #209870.

Something odd is happening with `xgcc` (the temporary compiler that
should be used only to compile `gcc`, although we are using it to
compile a temporary `patchelf` too) and `libstdc++`.

The temporary fix in this commit is to use `-static-libstdc++` for
the ephemeral `patchelf` built by `xgcc`.  It isn't pretty, but it
appears to work.

Incorporates:

- https://github.com/NixOS/nixpkgs/pull/224945
2023-04-06 03:16:31 -07:00
Adam Joseph
1847b1bc15 stdenv/linux: fix patchelf confusion
The stage before `xgcc` creates the first compiled patchelf
(i.e. not from bootstrapFiles).

The `xgcc` stage was inadvertently switching *back* to using the
patchelf *from* the bootstrapFiles.

The first commit in this PR adds self-checking comments (assertions)
to make it clear where each stage's patchelf comes from.

The second commit fixes the bug, and updates the self-checking
comments.
2023-04-05 22:18:27 -07:00
Adam Joseph
2abf285e2b stdenv/linux: add is{From,BuiltBy} assertions for patchelf 2023-04-05 22:18:22 -07:00
Sergei Trofimovich
c2e14a73e6 xgcc: avoid libc.so mix between gcc and binutils-ld linker plugin
Without the change when I attempt to built `nixpkgs` with weekly
`gcc-13` (it pulls in `flex` as a build input`) I am getting build
failure related to glibc mix caused by glibc loading:

    ...-binutils-patchelfed-ld-2.40/bin/ld: ...-xgcc-13.0.0/libexec/gcc/x86_64-unknown-linux-gnu/13.0.1/liblto_plugin.so:
    error loading plugin: ...-bootstrap-tools/lib/libpthread.so.0: undefined symbol: __libc_vfork, version GLIBC_PRIVATE

The change disables LTO plugin entirely to avoid loading of `glibc` mix.
2023-04-05 07:43:22 +01:00
Bernardo Meurer
f1f6ca8bcd
Merge pull request #209870 from amjoseph-nixpkgs/pr/stdenv/external-gcc-bootstrap 2023-04-03 08:19:03 -07:00
Adam Joseph
96588eb3de gcc: add common/checksum.nix
This commit adds `gcc/common/checksum.nix`, which contains code
common to both gcc11 and gcc12, implementing the `enableChecksum`
feature.

When gcc's built-in bootstrap (`--enable-bootstrap`) is used, gcc
compiles itself three times and compares a hash of the unlinked `.o`
files from the second and third compilation.  The
`enableChecksum=true` parameter performs the same comparison as part
of the `postInstall` phase.

Notably, `enableChecksum=true` can be used with `enableBootstrap=false`.

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-04-02 13:49:53 -07:00
Adam Joseph
fed2300bea unpack-bootstrap-tools.sh: patchelf libgcc_s.so.1 2023-04-02 13:49:53 -07:00
Adam Joseph
d7fe0a5548 make-bootstrap-tools.nix: use a patchelf built with -static-{libgcc,libstdc++}
Our bootstrap-files unpacker has always relied on a lot of unstated
assumptions, one of them being that every library has a DT_NEEDED
for librt.so, so patchelf'ing something into the RUNPATH into
librt.so means that it will be searched for every library load in
all of the bootstrap-files.

Unfortunately that assumption is not true for libgcc.

This causes problems, because patchelf links against libgcc (and
against libstdc++, which links against libgcc).  So we can't use
patchelf on libgcc, because it needs libgcc, so patchelf doesn't
work until libgcc is patchelfed.

The robust solution here is to use static linking for the copy of
patchelf that is shipped with the bootstrap-files.  We don't have to
go all the way to a statically linked libc; just -static-libgcc and
-static-libstdc++ are enough to break the circular dependency.
2023-04-02 13:49:53 -07:00
Adam Joseph
86ca0faff7 make-bootstrap-tools.nix: cp libgcc_s without -d
We do not want to preserve the symlinks from libgcc_s, since they
point to another outpath.  We want to copy from that outpath rather
than link to it.
2023-04-02 13:49:53 -07:00
Adam Joseph
c6bd37a691 make-bootstrap-tools.nix: ship libisl.so
Now that we've dropped the
gcc-links-statically-to-lib{isl,mpfr,mpc,gmp} hack, our gcc needs
libisl.so.  Let's add it to the bootstrap-files.
2023-04-02 13:49:53 -07:00
Adam Joseph
7553d0fe29 stdenv: Nix-driven bootstrap of gcc
#### Summary

By default, when you type `make`, GCC will compile itself three
times.  This PR inhibits that behavior by configuring GCC with
`--disable-bootstrap`, and reimplements the triple-rebuild using
Nix rather than `make`/`sh`.

 #### Immediate Benefits

- Allow `gcc11` and `gcc12` on `aarch64` (without needing new
  `bootstrapFiles`)
- Faster stdenv rebuilds: the third compilation of gcc
  (i.e. stageCompare) is no longer a `drvInput` of the final stdenv.
  This allows Nix to build stageCompare in parallel with the rest of
  nixpkgs instead of in series.
- No more copying `libgcc_s` out of the bootstrap-files or other
  derivations
- No more Frankenstein compiler: the final gcc and the libraries it
  links against (mpfr, mpc, isl, glibc) are all built by the same
  compiler (xgcc) instead of a mixture of the bootstrapFiles'
  compiler and xgcc.
- No more [static lib{mpfr,mpc,gmp,isl}.a hack]
- Many other small `stdenv` hacks eliminated
- `gcc` and `clang` share the same codepath for more of `cc-wrapper`.

 #### Future Benefits

- This should allow using a [foreign] `bootstrap-files` so long as
  `hostPlatform.canExecute bootstrapFiles`.
- This should allow each of the libraries that ship with `gcc`
  (lib{backtrace, atomic, cc1, decnumber, ffi, gomp, iberty,
  offloadatomic, quadmath, sanitizer, ssp, stdc++-v3, vtv}) to be
  built in separate (one-liner) derivations which `inherit src;`
  from `gcc`, much like https://github.com/NixOS/nixpkgs/pull/132343

 #### Incorporates

- https://github.com/NixOS/nixpkgs/pull/210004
- https://github.com/NixOS/nixpkgs/pull/36948 (unreverted)
- https://github.com/NixOS/nixpkgs/pull/210325
- https://github.com/NixOS/nixpkgs/pull/210118
- https://github.com/NixOS/nixpkgs/pull/210132
- https://github.com/NixOS/nixpkgs/pull/210109
- https://github.com/NixOS/nixpkgs/pull/213909
- https://github.com/NixOS/nixpkgs/pull/216136
- https://github.com/NixOS/nixpkgs/pull/216237
- https://github.com/NixOS/nixpkgs/pull/210019
- https://github.com/NixOS/nixpkgs/pull/216232
- https://github.com/NixOS/nixpkgs/pull/216016
- https://github.com/NixOS/nixpkgs/pull/217977
- https://github.com/NixOS/nixpkgs/pull/217995

 #### Closes

- Closes #108305
- Closes #108111
- Closes #201254
- Closes #208412

 #### Credits

This project was made possible by three important insights, none of
which were mine:

1. @ericson2314 was the first to advocate for this change, and
   probably the first to appreciate its advantages.  Nix-driven
   (external) bootstrap is "cross by default".

2. @trofi has figured out a lot about how to get gcc to not mix up
   the copy of `libstdc++` that it depends on with the copy that it
   builds, by moving the `bootstrapFiles`' `libstdc++` into a
   [versioned directory].  This allows a Nix-driven bootstrap of gcc
   without the final gcc would still having references to the
   `bootstrapFiles`.

3. Using the undocumented variable [`user-defined-trusted-dirs`]
   when building glibc.  When glibc `dlopen()`s `libgcc_s.so`, it
   uses a completely different and totally special set of rules for
   finding `libgcc_s.so`.  This trick is the only way we can put
   `libgcc_s.so` in its own separate outpath without creating
   circular dependencies or dependencies on the bootstrapFiles.  I
   would never have guessed to use this (or that it existed!) if it
   were not for a [comment in guix] which @Mic92 [mentioned].

My own role in this PR was basically: being available to go on a
coding binge at an opportune moment, so we wouldn't waste a
[crisis].

[aarch64-compare-ofborg]: https://github.com/NixOS/nixpkgs/pull/209870/checks?check_run_id=10662822938
[amd64-compare-ofborg]: https://github.com/NixOS/nixpkgs/pull/209870/checks?check_run_id=10662825857
[nonexistent sysroot]: https://github.com/NixOS/nixpkgs/pull/210004
[versioned directory]: https://github.com/NixOS/nixpkgs/pull/209054
[`user-defined-trusted-dirs`]: https://sourceware.org/legacy-ml/libc-help/2013-11/msg00026.html
[comment in guix]: 5e4ec82181/gnu/packages/gcc.scm (L253)
[mentioned]: https://github.com/NixOS/nixpkgs/pull/210112#issuecomment-1379608483
[crisis]: https://github.com/NixOS/nixpkgs/issues/108305
[foreign]: https://github.com/NixOS/nixpkgs/pull/170857#issuecomment-1170558348
[static lib{mpfr,mpc,gmp,isl}.a hack]: 2f1948af9c/pkgs/stdenv/linux/default.nix (L380)
2023-04-02 13:49:41 -07:00