Commit graph

885 commits

Author SHA1 Message Date
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
Adam Joseph 29b395309f gcc: make --with-long-double-format configurable by targetPlatform.gcc 2023-04-05 15:54:37 -07:00
Adam Joseph 40f7300227 gcc: if isPower64 && !isMusl use --with-long-double-format=ieee
Use IEEE-standard floating point on `powerpc64le` instead of
IBM-proprietary formats.  The GCC wiki has more details on the history
here:

  https://gcc.gnu.org/wiki/Ieee128PowerPC

Nixpkgs' stdenv has no legacy `powerpc64le` installs to deal with
(stdenv did not bootstrap on powerpc64le until very recenty), so it's
much easier decision for us.

Red Hat (i.e. IBM) has tried to do this in each of the last *six*
releases:

  https://fedoraproject.org/wiki/Changes/PPC64LE_Float128_Transition

they and finally shipped it in May with Fedora 36:

  https://bugzilla.redhat.com/show_bug.cgi?id=1649936

Apparently glibc 2.35 fixes the last blocker.

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-04-05 15:52:43 -07:00
Vladimír Čunát 4eaca2b138
Merge #188492: glibc: 2.35-224 -> 2.37-8
...into staging
2023-04-03 20:29:07 +02:00
Adam Joseph 5f57c2e0f9 pkgs/test/stdenv/default.nix: add gcc-stageCompare
This commit adds a derivation `gcc-stageCompare` to
`pkgs/test/stdenv/default.nix`.

It is important to always build this derivation whenever building
`stdenv`!  Because we are using a Nix-driven bootstrap instead of
gcc's built-in `--enable-bootstrap`, the `gcc` derivation no longer
performs the post-self-compilation sanity check.  You must build
this derivation in order to perform that sanity check.

The major benefit of this new approach is that the sanity check
(which involves a third compilation of gcc) can be performed
*concurrently* with all packages that depend on `stdenv`, rather
than serially.  Since `stdenv` has very little derivation-level
parallelism it cannot take advantage of more than one or perhaps two
builders.  If you have three or more builders this commit will
reduce the time-to-rebuild-stdenv by around 20% (one of three gcc
rebuilds is removed from the critical path, and stdenv's build time
is dominated by roughly 3*gcc + 1*binutils + 1*bison-test-suite).

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-04-02 13:49:53 -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 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
Adam Joseph fdd49f1bcd gcc/{11,12}: use lib.pipe
This commit has no effect on eval.  It simply reorganizes the
`gcc11` and `gcc12` expressions so they apply a list of
`overrideAttrs`.  The list is currently empty.
2023-04-02 03:04:21 -07:00
Maximilian Bosch 89fda21fae
gccgo6: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/193810432
2023-03-29 09:50:29 +02:00
Maximilian Bosch 2a2cd02cb6
gcc49: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/193330218
2023-03-29 09:50:26 +02:00
Maximilian Bosch 9bb6dc1bc3
gcc6: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/193371579
2023-03-29 09:50:26 +02:00
Maximilian Bosch 0ed55ff3ca
gcc7: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/193340626
2023-03-29 09:50:26 +02:00
Maximilian Bosch b0d673c794
gcc8: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/193370420
2023-03-29 09:50:25 +02:00
Maximilian Bosch 531a1965de
gcc9: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/193342322
Patch from gcc11 requires some minor adjustments to properly apply.
2023-03-29 09:50:25 +02:00
Maximilian Bosch b0265aadac
gcc10: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/193327405
Same fix as for gcc11.
2023-03-29 09:50:25 +02:00
Maximilian Bosch 019f605cd7
gcc: exclude malformed sys/mount.h from fixed headers directory
Previously, builds such as `cmake` would fail with errors like this:

    In file included from /nix/store/injyphmxqgi028skp28fsmdvbdb57nvl-glibc-2.36-48-dev/include/linux/fs.h:19,
                     from /build/cmake-3.24.2/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:56:
    /nix/store/injyphmxqgi028skp28fsmdvbdb57nvl-glibc-2.36-48-dev/include/linux/mount.h:95:6: error: redeclaration of 'enum fsconfig_command'
       95 | enum fsconfig_command {
          |      ^~~~~~~~~~~~~~~~

The reason behind that is that the kernel exports `linux/mount.h` via
kernel headers APIs that are also defined in `sys/mount.h` from glibc.
To avoid clashes, safeguards were implemented in glibc to prevent this
from happening[1][2].

However, these `#ifndef`-safeguards are removed by `fixincludes` during
gcc's build and the (broken) result is subsequently copied into
`include-fixed/sys/mount.h` which is added to each build via the
cc-wrapper. To work around this, I decided to simply drop the file: it
also exists in glibc's output and our gcc12 doesn't seem to expose this
anymore anyways.

[1] Commit bb1e8b0ca99b5cbedfae3e6245528a87d95ff3e2
[2] Commit 3bd3c612e98a53ce60ed972f5cd2b90628b3cba5
2023-03-29 09:50:25 +02:00
Maximilian Bosch b2a1ac4e99
gcc11: fix build w/glibc-2.36
Failing Hydra build: https://hydra.nixos.org/build/189053872
2023-03-29 09:50:24 +02:00
Sergei Trofimovich d65d457f68
Merge pull request #219811 from trofi/gcc-cross-no-sys-includes
gcc: do not install sys-include headers for cross-compilers.
2023-03-11 20:49:25 +00:00
Weijia Wang 042dd5c271
Merge pull request #217995 from amjoseph-nixpkgs/pr/gcc/disable-bootstrap-buildFlags-again
gcc/{11,12}: update buildFlags for `--disable-bootstrap` case
2023-03-08 09:36:51 +02:00
Adam Joseph 8a05f77b5d https://github.com/NixOS/nixpkgs/pull/217995#pullrequestreview-1318620540 2023-03-07 02:04:27 -08:00
Sergei Trofimovich 7df4387ebd gcc: do not install sys-include headers for cross-compilers.
Before the change include headers for cross-compilers like `pkgsStatic`
looked like this:

    $ nix build -L --impure --expr 'with import ./. {}; pkgsStatic.stdenv.mkDerivation { name = "probe"; buildCommand = "echo | $CXX -x c++ -E -v - |& fgrep -B10 search; exit 1"; }' |& unnix

    #include "..." search starts here:
    #include <...> search starts here:
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include/c++/13.0.1
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include/c++/13.0.1/x86_64-unknown-linux-musl
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include/c++/13.0.1/backward
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/sys-include
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/include
     /<<NIX>>/musl-static-x86_64-unknown-linux-musl-1.2.3-dev/include
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/include-fixed
    End of search list.

Note that `.../sys-include` inhibits the effect of `musl-static-x86_64-unknown-linux-musl-1.2.3-dev/include`.

After the change the paths look as expected:

    $ nix build -L --impure --expr 'with import ./. {}; pkgsStatic.stdenv.mkDerivation { name = "probe"; buildCommand = "echo | $CXX -x c++ -E -v - |& fgrep -B10 search; exit 1"; }' |& unnix

    #include "..." search starts here:
    #include <...> search starts here:
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include/c++/13.0.1
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include/c++/13.0.1/x86_64-unknown-linux-musl
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include/c++/13.0.1/backward
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/../../../../x86_64-unknown-linux-musl/include
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/include
     /<<NIX>>/musl-static-x86_64-unknown-linux-musl-1.2.3-dev/include
     /<<NIX>>/x86_64-unknown-linux-musl-stage-final-gcc-13.0.0/lib/gcc/x86_64-unknown-linux-musl/13.0.1/include-fixed
    End of search list.
2023-03-06 09:26:51 +00:00
github-actions[bot] de3f71e277
Merge staging-next into staging 2023-02-26 06:02:30 +00:00
Winter 3d0de0e8c8 gcc12: fix building foreign toolchain on aarch64-darwin
It seems that the patchset we apply to get some fixes for aarch64-darwin
support [0] breaks in unexpected ways when compiling a foreign toolchain [1].
Luckily, according to the branch's author, the patchset isn't required
for merely using aarch64-darwin as the build system [2], so let's only apply
it when hostPlatform == aarch64-darwin to fix cross.

[0]: https://github.com/iains/gcc-12-branch
[1]: https://github.com/iains/gcc-12-branch/issues/18
[2]: https://github.com/iains/gcc-12-branch/issues/18#issuecomment-1435792834
2023-02-26 00:48:03 -05:00
Adam Joseph c3547bc6eb gcc/{11,12}: update buildFlags for --disable-bootstrap case
This commit updates the `buildFlags`, which is a single string with
one of four possibilities:

  - ""
  - "profiled"
  - "bootstrap"
  - "profiledbootstrap"

Previously only the last two were possible.  Since
2ea3482502 all four are possible.
2023-02-23 23:22:19 -08:00
Adam Joseph 86a0e46ed4 gcc: fix implication order in assertion
In 6812dd98c4 I mistakenly had the
implication order reversed.  This commit corrects that mistake.

The original assertion (which is correct) was the following, which
asserts that if you enable the GDB plugin, you must enable plugins
generally (there is shared infrastructure):

```
assert enableGdbPlugin -> enablePlugin;
```

When the option name was changed to `disableGdbPlugin`, I
incorrectly wrote:

```
assert disableGdbPlugin -> enablePlugin;
```

And then again incorrectly wrote:

```
assert disableGdbPlugin -> !enablePlugin;
```

This commit uses the correct equivalent for the first statement,
which is the contrapositive:

```
assert !enablePlugin -> disableGdbPlugin;
```
2023-02-23 22:54:49 -08:00
github-actions[bot] 3cdd771820
Merge staging-next into staging 2023-02-23 18:01:49 +00:00
Adam Joseph 24b07fc9e5 gcc/common: add disableGdbPlugin option
This commit adds an option `disableGdbPlugin` which controls whether
or not the plugin *for* GDB will be built.  This plugin contains a
copy of `gcc`.

The configure flag that this option controls is called
`--disable-libcc1`.  This flag name is slightly confusing: it is
used only by GDB (and apparently unmaintained), yet the flag name
does not mention GDB.  This is why the option name is different from
the configure flag name.

The primary motivation for this commit is to allow the following PR
(which is not yet merged) to pass `--disable-libcc1` when building
the final native (build=host=target) compiler as part of the stdenv
bootstrap:

  https://github.com/NixOS/nixpkgs/pull/209870

We need to `--disable-libcc1` in this scenario because gcc's build
machinery links `libcc1` against the `libstdc++` that is part of the
*compiler used to compile gcc*, rather than against the `libstdc++`
that is built *by* gcc.  In an FHS distribution this distinction is
not terribly important because dynamically linked libraries are
late-bound (ld.so resolution).  However in nixpkgs this causes a
reference back to the bootstrapFiles to leak all the way through to
the final stdenv.

More details can be found in the comment in
`pkgs/stdenv/linux/default.nix` of the PR linked above.

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2023-02-22 19:30:34 -08:00
Artturin f9fdf2d402 treewide: move NIX_CFLAGS_COMPILE to the env attrset
with structuredAttrs lists will be bash arrays which cannot be exported
which will be a issue with some patches and some wrappers like cc-wrapper

this makes it clearer that NIX_CFLAGS_COMPILE must be a string as lists
in env cause a eval failure
2023-02-22 21:23:04 +02:00
github-actions[bot] 8c0220980d
Merge staging-next into staging 2023-02-19 00:03:03 +00:00