Commit graph

990 commits

Author SHA1 Message Date
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
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
Yureka 3a2b7bd7d7 gcc: add missing libucontext buildInput for pkgsMusl.gccgo12 2023-02-18 23:51:32 +01:00
Sergei Trofimovich 2ea3482502
Merge pull request #216136 from amjoseph-nixpkgs/pr/gcc/enableBootstrap
gcc: expose --disable-bootstrap as disableBootstrap
2023-02-18 08:51:38 +00:00
Robert Scott 0eedcfc3f4
Merge pull request #212498 from risicle/ris-fortify3
hardening flags: add `FORTIFY_SOURCE=3` support
2023-02-16 21:19:30 +00:00
Adam Joseph 37fe1613cf gcc: expose --disable-bootstrap as disableBootstrap 2023-02-15 23:32:19 -08:00
Felix Buehler cdb39a86e0 treewide: use optionalString 2023-02-13 21:52:34 +01:00
Vladimír Čunát a6767ed934
Merge #212363: gcc11: apply upstream patch
...into staging-next
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103910
2023-02-13 13:36:01 +01:00
github-actions[bot] 87f957b5e2
Merge master into staging-next 2023-02-12 16:02:45 +00:00
Adam Joseph b83f032ffc gcc/11: apply upstream fix 103910 so openjdk builds
Our openjdk derivations fail to build with `-march=opteron` (via
either `NIX_CFLAGS_COMPILE` or `hostPlatform.gcc.arch`).  This was
fixed upstream in gcc12 but not carried back to gcc11:

  https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=d243f4009d8071b734df16cd70f4c5d09a373769

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103910

Since gcc11 is still nixpkgs' primary compiler, this PR cherry-picks
the fix out of gcc12.

Unfortunately since `-march=` can be added after the `gcc11`
derivation is built we can't apply this patch conditionally (which
we don't usually do anyways).
2023-02-12 07:40:05 -08:00
Artturin 6986717510 gcc: add common/meta.nix
inherit has to be used otherwise makeOverridable attributes are added
2023-02-12 05:44:34 +02:00
Artturin e277984d0b gcc: add callFile to make it more convenient to call files
inherit generated with 'nix eval --json --impure --expr "with import ./. {}; lib.attrNames (lib.functionArgs gccX.cc.override)" | jq '.[]' --raw-output'
2023-02-11 21:17:30 +02:00
github-actions[bot] c76e040c19
Merge master into staging-next 2023-02-09 12:01:30 +00:00
Artturin 951c2fb2dd gcc10,gcc11,gcc12: move dependencies to common/dependencies.nix 2023-02-08 04:07:48 +02:00
Artturin c4269cd7bf gcc7,gcc8: move dependencies to common/dependencies.nix 2023-02-08 04:07:48 +02:00
Artturin 18f9f26a79 gcc6: move dependencies to common/dependencies.nix
the (vc4 redox) flex conditional was missing in all other gcc version
because gcc6 was the default at the time it was added

that is one of the problems common/dependencies.nix fixes
2023-02-08 04:06:21 +02:00
Artturin 5564beebfe gcc: add common/dependencies.nix
there is a duplication issue in the gcc's so this will help with that

gcc49,gcc48: move dependencies to common/dependencies.nix
2023-02-08 04:03:55 +02:00
Vladimír Čunát 9e2af38827
Merge branch 'staging' into staging-next 2023-02-01 17:05:25 +01:00
Sergei Trofimovich b8b5fc1463 gcc: revert "provide both native and cross forms of gcc.libs libraries"
This reverts commit 2c931bd5f4.

The https://github.com/NixOS/nixpkgs/pull/209153 reverted --sysroot=/
change as it broke other astects of library search paths.

While it might still be useful to pull in gcc libraries when
non-standard --sysroot= is passed there are no meaningful use cases of
it in `nixpkgs` yet. Let's revert it for now.
2023-02-01 07:42:11 +00:00
Sergei Trofimovich 8212ae0455
Merge pull request #213909 from amjoseph-nixpkgs/pr/gcc/comment
gcc/common/configure-flags.nix: fix comment
2023-02-01 07:30:32 +00:00
Adam Joseph b02da45b3c gcc/common/configure-flags.nix: fix comment
On a native (host==build==target) build, `${with_build_sysroot}` can
be omitted.  In that case, the line modified by this commit is
correct.

However, if `--with-build-sysroot=` is passed to `./configure`, then
`${with_build_sysroot}` will be used, similar to the cross case, and
the headers will be taken from:

  ${with_build_sysroot}${native_system_header_dir}

See:

  https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/configure.ac;h=62bc908b991ff0b700225aef32743cd3d7c4daaf;hb=HEAD#l2439

This commit adjusts the comment to account for the case where
`--with-build-sysroot` is passed to a native compiler.
2023-01-31 21:40:48 -08:00
Robert Scott c09e1fa406 gcc: mark hardeningUnsupportedFlags fortify3 for all but gcc 12 2023-01-24 21:52:12 +00:00
github-actions[bot] cd6a5f6c46
Merge staging-next into staging 2023-01-24 00:02:42 +00:00
github-actions[bot] 727e365f02
Merge master into staging-next 2023-01-24 00:02:11 +00:00
Sandro 2696d7e4a6
Merge pull request #208657 from tpwrules/darwin-fix-avr 2023-01-23 23:48:21 +01:00
John Ericson 791c80ae74
Merge pull request #212271 from alyssais/gcc-uclibc-libgomp
gcc: don't disable libgomp for uclibc targets
2023-01-23 16:59:17 -05:00
John Ericson 8240bc77e8
Merge pull request #212275 from alyssais/libdl
treewide: remove -ldl linker flags
2023-01-23 16:28:21 -05:00
Alyssa Ross 12d2821bf5
treewide: remove -ldl linker flags
With all libcs I'm aware of, libdl is now either empty (Glibc, musl,
uclibc, illumos), a symlink to libc or equivalent (Apple), or does not
exist (FreeBSD, NetBSD).  So explicitly linking libdl now does nothing
for the former platforms, and breaks the build for the latter
platforms.

With this patch I've removed -ldl from all overridden linker flags for
all free packages in Nixpkgs.  Everything still seems to build.
2023-01-23 15:34:53 +00:00
Alyssa Ross 5b22ff71e1
gcc: don't disable libgomp for uclibc targets
I'm reasonably confident this is no longer necessary, as uclibc's
libdl.a is empty, and I can cross-build stdenv.cc.cc for
x86_64-unknown-linux-uclibc with libgomp enabled.
2023-01-23 14:44:06 +00:00
Sergei Trofimovich b9b1d958d0 Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
	pkgs/development/libraries/qt-6/modules/qtbase.nix
	pkgs/stdenv/linux/make-bootstrap-tools.nix
2023-01-20 21:56:57 +00:00
Alyssa Ross 4ed0e1a743 gcc: use as(1) from binutils with LLVM bintools
LLVM does not provide a drop-in replacement for as(1).

This makes it possible to build a GNU Fortran cross compiler from GNU
to LLVM — e.g. buildPackages.gfortran for
{ system = "aarch64-linux"; useLLVM = true; }
2023-01-20 18:35:25 +01:00
John Ericson 2c48770293
Merge pull request #210816 from obsidiansystems/gcc-fix-bug-80431
gcc: Backport fix of GCC Issue 80431 from version 12
2023-01-17 11:45:29 -05:00
John Ericson d6d1897904 gcc: Backport fix of GCC Issue 80431 from version 12
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80431

This bug annoys me because I hit it when working on Nix. It causes
miscompilations in such a way that I am hard-pressed to think how a
program could inadvertainly rely on the bug (such that it would be
broken by the fix).

The bug is longstanding, and the (quite small) applies without
modification to many older GCCs. I have confirmed by running the test in
that commit that does indeed fix the bug with the backports too.
2023-01-14 22:33:57 -05:00
Sergei Trofimovich ca4da963f8 Merge remote-tracking branch 'origin/staging-next' into staging
Conflicts:
    pkgs/development/libraries/audio/roc-toolkit/default.nix
2023-01-14 11:07:42 +00:00
Sergei Trofimovich 1bc0b7ad62
Merge pull request #209153 from trofi/gcc-libs-cross-link
gcc: provide both native and cross forms of gcc.libs libraries
2023-01-14 08:18:19 +00:00
github-actions[bot] 49722fd14a
Merge master into staging-next 2023-01-13 18:01:34 +00:00
Boey Maun Suang c7ce0c86a6 gnat12: Fix GNAT Darwin dylib install names 2023-01-11 09:03:43 +11:00
Boey Maun Suang 3d64e7edbb gnat12: Add support for x86_64-darwin 2023-01-07 18:32:12 +11:00
Sergei Trofimovich b18eedcdab
Merge pull request #208859 from trofi/gcc-builder-cleanup
gcc/builder.sh: drop dead RPATH clobbering code
2023-01-05 18:42:01 +00:00
Sergei Trofimovich 2c931bd5f4 gcc: provide both native and cross forms of gcc.libs libraries
I would like to use --sysroot=/nix/store/does/not/exist hack
for both `gcc` and `clang` drivers to remove default include
(and library) search paths when we override them with libc.

For `gcc` it works as is. But for `clang` it also drops some of
`gcc` search paths`. Let'sconsider 2 lookups.

Successful lookup (no `--sysroot`):

    $ printf "int main(){}" | clang++ -x c++ - -Wl,--verbose |& grep -F stdc++
    attempt to open /nix/store/...-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib/libstdc++.so failed
    attempt to open /nix/store/...-clang-11.1.0-lib/lib/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64/libstdc++.so failed
    /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64/libstdc++.a

Failed lookup (has `--sysroot`):

    $ printf "int main(){}" | clang++ --sysroot=/does/not/exist -x c++ - -Wl,--verbose |& grep -F stdc++
    attempt to open /nix/store/...-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib/libstdc++.so failed
    attempt to open /nix/store/...-clang-11.1.0-lib/lib/libstdc++.so failed
    attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed
    /nix/store/...-binutils-2.39/bin/ld: cannot find -lstdc++: No such file or directory

Note how `clang` starts the search roughly from
`gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib` in both cases. I think
it's our preferred location for both native and cross cases.

The change adds such a symlink:

    `gcc-11.3.0-lib` -> `gcc-11.3.0-lib/x86_64-unknown-linux-gnu`
2023-01-05 14:41:35 +00:00
github-actions[bot] 789ae2c93d
Merge staging-next into staging 2023-01-04 18:01:36 +00:00
Yureka 0319a561ec pkgsMusl.gccgo: fix build 2023-01-04 13:21:20 +01:00
Sergei Trofimovich 99b56a9139 gcc/builder.sh: drop dead RPATH clobbering code
The code was intended to use something like
    [ $buildConfig == *linux* ]
but never did and use always-false
    [ buildConfig == *linux* ]

As it's in nixpkgs for a few years let's just delete it instead of
restoring.
2023-01-03 10:30:30 +00:00
Thomas Watson 1f4feb7c6f avr-gcc: fix build on Darwin
Adds a patch which fixes a compilation error generated by Clang 11
compiling GCC 11.3.
2023-01-01 11:12:23 -06:00
github-actions[bot] dc7ebb0163
Merge staging-next into staging 2022-12-18 18:01:41 +00:00
figsoda ec8cb34358 treewide: fix typos 2022-12-17 19:39:44 -05:00
Artturin adc8900df1 treewide: fix some core package structuredAttrs 2022-12-08 21:05:28 +02:00
Vladimír Čunát befa1f2dc6
Merge #196565: gcc11: Update back to 11.3 on Darwin
...into staging
2022-11-22 12:42:23 +01:00
Jörg Thalheim 890d0576c5 cross/mingw: make threading library configureable 2022-11-14 12:50:04 +01:00
Zhaofeng Li ddb5ea3e69 gcc11: Update back to 11.3 on Darwin 2022-10-28 00:54:35 -06:00
Martin Weinelt 21c552eaf6
gcc12: fix build with libxcrypt 2022-10-09 18:10:38 +02:00
Martin Weinelt aac6de8d31
gcc10: fix build with libxcrypt 2022-10-09 18:10:38 +02:00
Franz Pletz 0097f57b1f
gcc11: fix build with libxcrypt 2022-10-09 18:07:54 +02:00
Theodore Ni 816cb20bd3
gcc12: switch to Homebrew patch on aarch64-darwin
We can presume that this patch is better tested and better maintained.
2022-09-04 11:07:54 -07:00
Martin Weinelt 249398ffa8 Merge remote-tracking branch 'origin/staging-next' into staging 2022-08-25 00:32:27 +02:00
github-actions[bot] 9179666d33
Merge master into staging-next 2022-08-23 12:01:12 +00:00
Vladimír Čunát f8eb3f491f
Merge #187418: gcc12: 12.1.0 -> 12.2.0 2022-08-23 07:52:03 +02:00
Sergei Trofimovich 657075f9fa gcc12: 12.1.0 -> 12.2.0
Co-authored-by: Robert Scott <github@humanleg.org.uk>
2022-08-21 13:56:21 +01:00
github-actions[bot] a6c886b7fd
Merge master into staging-next 2022-08-21 06:01:17 +00:00
Theodore Ni 1b0a51cbb7
gcc49: mark unsupported on aarch64-darwin
It's not supported and likely too old to be supported.
2022-08-20 15:11:53 -07:00
github-actions[bot] 77394c111b
Merge staging-next into staging 2022-08-20 18:02:00 +00:00
Sergei Trofimovich 1f7186ab5c libgccjit: don't try to enter into non-existent $lib output
Fixes build failure on `staging-next` introduced by commit c817efe6
("gcc: extend stripping of .a libraries and .o objects"):

    ...-bootstrap-stage3-stdenv-linux/setup: line 106: pushd: no other directory

Build failure happens because `libgccjit` has different `outputs` layout
compared to the rest of `gcc` derivations:

     outputs = [ "out" "man" "info" ] ++ lib.optional (!langJit) "lib";

The change carves out `$lib` lib handling part to avoid `gcc` rebuild
in `staging-next`.
2022-08-20 12:51:36 +01:00
Sergei Trofimovich 7f458e5c50
Merge pull request #187234 from trofi/drop-libelf-from-gcc
gcc: drop unused libelf dependency
2022-08-19 19:16:35 +01:00
Artturi 9adf0c2035
Merge pull request #185972 from Artturin/gccstrictdeps
gcc/: correct gnused conditionals
2022-08-19 20:50:23 +03:00
github-actions[bot] c00ace1204
Merge master into staging-next 2022-08-19 12:01:31 +00:00
Sergei Trofimovich 3b60b31d60 gcc: drop unused libelf dependency
gcc stopped using libelf in commit 48215350c24 ("re PR lto/46273 (Failed
to bootstrap)") around 2010, before gcc-4.6.0.
2022-08-18 08:35:41 +01:00
Artturin f16be229dc gcc/: correct gnused conditionals and move to nativeBuildInputs
hostPlatform changes were done in commits like 7a13457253

it should have been buildPlatform instead according to the comment
2022-08-17 21:03:40 +03:00
Vladimír Čunát ddc75d1843
Merge #185284: gcc: fix bootstrapTools.mips64el-linux-gnuabin32
...into staging
2022-08-16 13:12:01 +02:00
Theodore Ni 74b420b612
gcc12: apply working patch for darwin-aarch64 2022-08-13 12:04:03 -07:00
Theodore Ni cf206e9d00
gcc11: pick up bugfixes for darwin-aarch64
Amongst others, this picks up the fix for:

    https://github.com/iains/gcc-darwin-arm64/issues/54
2022-08-13 11:37:09 -07:00
github-actions[bot] 67f5b5a85d
Merge staging-next into staging 2022-08-08 18:02:11 +00:00
adisbladis 5cc12aa8cb
Merge pull request #182187 from adisbladis/newlib-nano-cc
newlib-nano: Set same flags as regular newlib in cc-wrapper/gcc config
2022-08-08 22:07:57 +08:00
Adam Joseph a6daffb118 gcc: factor out $linkLib64toLib, move it from bash to nix
This commit factors out the conditional which creates the `lib64->lib`
symlink in the `preInstall` phase, and calculates its value in nix
code rather than bash code so touching it doesn't cause a global
rebuild on every platform.
2022-08-05 13:52:25 -07:00
Adam Joseph dfba0bf93b gcc: do not create lib64->lib links on mips64n32
On mips, gcc follows the somewhat awkward IRIX convention of putting
mips64 binaries in `lib64` and mips64n32 binaries in `lib32`.  So on
mips64n32 we do not want the `lib64` symlinks.
2022-08-05 11:07:16 -07:00
Adam Joseph cbc80ff32b gcc: add linkLib32toLib to create lib32->lib links
Our gcc builder creates lib64->lib links to ensure that the "primary"
libraries for the targetPlatform wind up in $PREFIX/lib.  This is
required in order for make-bootstrap-files.nix to work correctly.

On mips, gcc follows the somewhat awkward IRIX convention of putting
mips32 binaries in `lib` and mips64n32 binaries in `lib32`.  So we
need similar symlinks there.  This may come up on other ILP32
platforms as well, so a general-purpose variable name is provided.
2022-08-05 11:07:14 -07:00
Sergei Trofimovich c817efe660 gcc: extend stripping of .a libraries and .o objects
The initial intent was to strip .a and .o files, not .a.o files.
While at it expanded stripping for $lib output as well.

Without the change `libgcc.a` was not stripped and `.debug*` sections
made into final binaries. It's not a problem on it's own, but it's an
unintended side-effect. Noticed on `crystal_1_0` test failure where
`crystal` was not able to handle `dwarf-5`.

While at it allowed absolute file names to be passed to stripDebugList
and friends.
2022-08-03 22:28:47 +01:00
Bernardo Meurer 88c63ca65a
Merge pull request #182513 from trofi/strip-for-host-and-target
gcc: enable stripping for cross-compilers
2022-07-28 00:30:49 -07:00
Sergei Trofimovich eece5d0dc0 gcc: enable stripping for cross-compilers
With explicit support for distinction between Host and Target strip paths
we can now safely strip ELF binaries with their according strip tools
without fear of damaging binaries due to architecture mismatch.

Closure size change for `pkgsCross.mingwW64.gcc12Stdenv.cc.cc`:

    # before:
    $ nix path-info -Sh $(nix-build -A pkgsCross.mingwW64.gcc12Stdenv.cc.cc) | unnix
    /<<NIX>>/x86_64-w64-mingw32-stage-final-gcc-debug-12.1.0           2.5G

    # after:
    $ nix path-info -Sh $(nix-build -A pkgsCross.mingwW64.gcc12Stdenv.cc.cc) | unnix
    /<<NIX>>/x86_64-w64-mingw32-stage-final-gcc-12.1.0         1.5G
2022-07-25 11:06:58 +01:00
Sergei Trofimovich c7062b9769
Merge pull request #181994 from trofi/gcc-drop-outdated-sed
gcc: drop outdated sed for system headers clobber
2022-07-24 15:01:22 +01:00
Sergei Trofimovich ea8e124000 gcc: always enable inhibit_libc=true for --without-headers builds
It's a follow-up to the breakage caused by 21966e13d2
("gcc: pass --with-build-sysroot=/"). It caused `pkgsLLVM`
cross-toolchain bootstrap breakage:

    $ nix build --no-link -f. pkgsLLVM.hello
    ...
    failed: /nix/store/...-x86_64-unknown-linux-gnu-stage-static-gcc-13.0.0.drv:
    ...
    configure flags: ... --enable-languages=c --disable-multilib \
      --disable-shared --enable-plugin ... --disable-libssp --disable-nls \
      --without-headers --disable-threads --disable-libgomp --disable-libquadmath \
      --disable-shared --disable-libatomic --disable-decimal-float --disable-libmpx \
      --disable-bootstrap \
      \
      --build=x86_64-unknown-linux-gnu \
      --host=x86_64-unknown-linux-gnu \
      --target=x86_64-unknown-linux-gnu
    ...
    The directory that should contain system headers does not exist:
      /usr/include
    make[2]: *** [Makefile:3279: stmp-fixinc] Error 1 shuffle=1658621302
    rm gfdl.pod gcc.pod gcov-dump.pod gcov-tool.pod fsf-funding.pod gpl.pod cpp.pod gcov.pod lto-dump.pod
    make[2]: Leaving directory '/build/build/gcc'

Note: it's a no-libc build. It's not expected to use any libc headers.
But in this case fixincludes tries to run and uses default /usr/include
location.

Fixinsludes is not normally expected to run during cross-compilation
on --without-headers. gcc/configure.ac:

    : ${inhibit_libc=false}
    if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
           test x$with_newlib = xyes ; } &&
         { test "x$with_headers" = xno || test ! -f "$target_header_dir/stdio.h"; } ; then
           inhibit_libc=true
    fi

The change explicitly passes inhibit_libc=true to configure to disable
include fixing on such cases.

Fixed `nix build --no-link -f. pkgsLLVM.hello` toolchain bootstrap.
2022-07-24 09:54:49 +01:00
John Ericson 21966e13d2
Merge pull request #181943 from trofi/fix-cross-built-gcc
gcc: pass --with-build-sysroot=/
2022-07-23 23:52:07 -04:00
Sergei Trofimovich 34636efced gcc: pass --with-build-sysroot=/ for gcc builds
Without this change cross-built gcc fails to detect stack protector style:

    $ nix log -f pkgs/stdenv/linux/make-bootstrap-tools-cross.nix powerpc64le.bootGCC | fgrep __stack_chk_fail
    checking __stack_chk_fail in target C library... no
    checking __stack_chk_fail in target C library... no

It happens because gcc treats search paths differently:

    https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/configure.ac;h=446747311a6aec3c810ad6aa4190f7bd383b94f7;hb=HEAD#l2458

     if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x ||
        test x$build != x$host || test "x$with_build_sysroot" != x; then
       ...
       if test "x$with_build_sysroot" != "x"; then
         target_header_dir="${with_build_sysroot}${native_system_header_dir}"
       elif test "x$with_sysroot" = x; then
         target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include"
       elif test "x$with_sysroot" = xyes; then
         target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}"
       else
         target_header_dir="${with_sysroot}${native_system_header_dir}"
       fi
     else
       target_header_dir=${native_system_header_dir}
     fi

By passing --with-build-sysroot=/ we trick cross-case to use
`target_header_dir="${with_sysroot}${native_system_header_dir}"`
which makes it equivalent to non-cross
`target_header_dir="${with_build_sysroot}${native_system_header_dir}"`

Tested the following setups:
- cross-compiler without libc headers (powerpc64le-static)
- cross-compiler with libc headers (powerpc64le-debug)
- cross-build compiler with libc headers (powerpc64le bootstrapTools)

Before the change only 2 of 3 compilers detected libc headers.
After the change all 3 compilers detected libc headers.

For darwin we silently ignore '-syslibroot //' argument as it does not
introduce impurities.

While at it dropped mingw special case for no-libc build. Before the change
we passed both '--without-headers --with-native-system-headers-dir' for
no-libc gcc-static builds. This tricked darwin builds to find sys/sdt.h
and fail inhibid_libc builds. Now all targets avoid passing native headers
for gcc-static builds.

While at it fixed correct headers passing to
--with-native-system-headers-dir= in host != target case: we were passing
host's headers where intention was to pass target's headers.
Noticed the mismatch as a build failure on pkgsCross.powernv.stdenv.cc
on darwin where `sys/sdt.h` is present in host's headers (libSystem)
but not target's headers (`glibc`).

Co-authored-by: Adam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com>
2022-07-23 18:40:07 +01:00
Sergei Trofimovich cb63ee9ff8
Merge pull request #181999 from trofi/gcc-clean-up-configureFlags
gcc: turn configureFlags into a sigle list, not nested list
2022-07-20 15:46:36 +01:00
adisbladis facbbae4b7 gcc: Set --with-newlib when using newlib-nano 2022-07-20 16:41:48 +08:00
Sergei Trofimovich 69da37a8fd gcc: turn configureFlags into a sigle list, not nested list
Before the change:

    $ nix repl pkgs/stdenv/linux/make-bootstrap-tools-cross.nix
    nix-repl> :p powerpc64le.bootGCC.configureFlags
    [ ... "--enable-targets=powerpcle-linux" [ "--with-long-double-128" ] "--target=powerpc64le-unknown-linux-gnu" ]

After the change:

    nix-repl> :p powerpc64le.bootGCC.configureFlags
    [ ... "--enable-targets=powerpcle-linux" "--with-long-double-128" "--target=powerpc64le-unknown-linux-gnu" ]
2022-07-18 19:10:22 +01:00
Sergei Trofimovich 769956d65b gcc: drop outdated sed for system headers clobber
When reviewing https://github.com/NixOS/nixpkgs/pull/181802#issuecomment-1186834504
I noticed outdated code that attempted to override /usr/include.

    sed -i \
        -e "s,glibc_header_dir=/usr/include,glibc_header_dir=$libc_dev/include", \
        gcc/configure

`glibc_header_dir` was removed from `gcc-4.6` and later in
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6961669f48aa18168b2d7daa7e2235fbec7cb636
(Dec 2010, "(gcc_cv_ld_eh_frame_hdr): Only check GNU ld for  --eh-frame-hdr.").

Since then gcc got `--with-native-system-header-dir=` which `nixpkgs` uses
for all packaged `gcc` versions.

The change should be a no-op.
2022-07-18 18:55:58 +01:00
github-actions[bot] 05798fee88
Merge staging-next into staging 2022-07-10 18:01:55 +00:00
Sergei Trofimovich 8f00857bf9 pkgsMusl.gcc12: backport build fix (PR106102)
Without the change gcc-12 on musl fails to build due to system headers
poisoning:

    /build/build/./prev-gcc/xg++ ... ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc
        In file included from /<<NIX>>/musl-1.2.3-dev/include/pthread.h:30,
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/x86_64-unknown-linux-musl/bits/gthr-default.h:35,
                 ....
                 from /build/build/prev-x86_64-unknown-linux-musl/libstdc++-v3/include/memory:77,
                 from ../../gcc-13-20220626/gcc/../libcody/cody.hh:24,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.h:25,
                 from ../../gcc-13-20220626/gcc/cp/../../c++tools/resolver.cc:23,
                 from ../../gcc-13-20220626/gcc/cp/mapper-resolver.cc:32:
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:84:7: error: attempt to use poisoned "calloc"
       84 | void *calloc(size_t, size_t);
          |       ^
    /<<NIX>>/musl-1.2.3-dev/include/sched.h:124:36: error: attempt to use poisoned "calloc"
      124 | #define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
          |                                    ^

The change pulls upstream fix as is.
2022-07-09 09:35:25 +01:00
Vladimír Čunát 43f9c191bf
Merge #110571: treewide: migrate to -fno-common
...into staging
2022-07-07 10:06:38 +02:00
Gaelan Steele 5b47eb13ac gcc, clang11: don't force -fcommon on GCC 10 or clang11
GCC 10 sets -fno-common by default. This broke some packages, so
when moving to GCC 10 we initially disabled this behavior. This
commit reverts that, bringing us closer to the standard and
upstream.

Co-authored-by: Sergei Trofimovich <slyich@gmail.com>
2022-07-06 08:37:00 +01:00
Vladimír Čunát 3f88d51e02
gcc10: 10.3.0 -> 10.4.0
Patches: the two seemed included in the release;
I also checked that the conditional patches still all apply.
2022-06-29 10:07:32 +02:00
Shea Levy 8e6206f9c9
gcc49: Fix build on darwin 2022-06-23 10:42:39 -04:00
Vladimír Čunát 06b472c49f
gcc9: 9.3.0 -> 9.5.0
The issue from 9.4.0 on aarch64-linux seems gone.
2022-06-05 23:24:46 +02:00
Vladimír Čunát cb4e7fd9bc
gdc: nicer eval failure from versions >= 12
12 will also be copied into future versions;
these parts seem OK to be copied by default.
2022-05-23 16:24:25 +02:00
Francesco Gazzetta 6436bdeb7f gcc: add langD support to gcc 10 2022-05-23 16:09:25 +02:00
Sergei Trofimovich 857a06674d
Merge pull request #173817 from trofi/fix-gcc-12-on-darwin
gcc12: fix substituteInPlace on darwin
2022-05-21 06:42:58 +00:00
Sergei Trofimovich 5d2d60e3e2 gcc12: fix substituteInPlace on darwin
gcc-12 did a mass rename from .c to .cc c++ files. As a result build fails as:

    substitute(): ERROR: file 'gcc/config/darwin-c.c' does not exist

Closes: https://github.com/NixOS/nixpkgs/issues/172877
2022-05-20 23:59:36 +01:00