Commit Graph

760 Commits

Author SHA1 Message Date
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
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
Francesco Gazzetta
c6ea401438 gdc: match gcc version
Programs compiled with gdc (such as tumiki-fighters and torus-trooper)
that depend on c++ libraries were failing with errors such as

/nix/store/3fqi6nigj8dkbvjnw8y4dy59gkq8vsj4-binutils-2.38/bin/ld: /nix/store/36960p41h83cwkcs2vpzg8ni39w4sc5m-bulletml-0.0.6/lib/libbulletml.so: undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'

because of the mismatch with the gcc version used to compile the
libraries.

This commit unpins the gcc version gdc is based on, so they are kept in
sync.

gdc9 was removed since no other package depends specifically on that
version
2022-05-20 13:49:55 +02:00
Vladimír Čunát
148df9e42e
Merge #171830: gcc12, gfortran12, gnat12: init at 12.1.0 2022-05-10 10:59:28 +02:00
Sergei Trofimovich
c34a8024bf gcc12, gfortran12, gnat12: init at 12.1.0
A copy of gcc11 with minor patch changes:
- follow .c/.cc rename upstream
- made patches unconditional

Changes: https://www.gnu.org/software/gcc/gcc-12/changes.html
2022-05-07 13:50:47 +01:00
Vladimír Čunát
005e2edc05
Merge #171792: gcc11: downgrade to 11.2.0 on x86_64-darwin
...into staging-next
2022-05-07 08:19:02 +02:00
github-actions[bot]
6e0aca3c43
Merge master into staging-next 2022-05-06 12:02:02 +00:00
Vladimír Čunát
976e65456a
gcc11: downgrade to 11.2.0 also on x86_64-darwin
https://hydra.nixos.org/build/175546330
2022-05-06 11:43:07 +02:00
Thomas Watson
ec87e38d65 Revert "gcc: 11.2.0 -> 11.3.0" for aarch64-darwin
Patches to support GCC 11.3.0 on aarch64-darwin are not available. Homebrew
also is skipping the 11.3.0 upgrade.
2022-05-05 08:11:09 -05:00
Sergei Trofimovich
cb03b37927 pkgsCross.mingw32.gcc11Stdenv: update mcfgthread patches for gcc-11
Without the change mingw32-gcc fails to build as:

    In file included from /build/gcc-11.2.0/libstdc++-v3/libsupc++/cxxabi.h:49,
                     from ../../../../gcc-11.2.0/libstdc++-v3/libsupc++/atexit_thread.cc:24:
    ../../../../gcc-11.2.0/libstdc++-v3/libsupc++/atexit_thread.cc:36:3: error: 'int __cxxabiv1::__cxa_thread_atexit(void (*)(void*), void*, void*)' should have been declared inside '__cxxabiv1'
       36 |   _GLIBCXX_NOTHROW
          |   ^~~~~~~~~~~~~~~~
    ../../../../gcc-11.2.0/libstdc++-v3/libsupc++/atexit_thread.cc:34:1: error: conflicting declaration of C function 'int __cxxabiv1::__cxa_thread_atexit(void (*)(void*), void*, void*)'
       34 | __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
          | ^~~~~~~~~~

The change follows upstream change introduced in
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=7fc0f78c3f43af1967cb7b1ee8f4947f3b890aa2
2022-05-01 15:34:22 +01:00
Vladimír Čunát
cfcccfa572
Merge #170121: gcc: 11.2.0 -> 11.3.0 (into staging) 2022-04-29 08:18:04 +02:00
Sergei Trofimovich
e35682b207 gcc: 11.2.0 -> 11.3.0
Bug fix release.

Changes: https://gcc.gnu.org/gcc-11/changes.html (11.3 link below).
2022-04-24 19:12:51 +01:00
Malo Bourgon
0d0feaa4fc gcc{4..10}: add aarch64-darwin to badPlatforms 2022-04-14 10:02:19 -07:00
Simon Chatterjee
9b310e61b4 gcc10: fix cross-compilation from aarch64-darwin host
Without this patch, linking when cross-compiling fails:

    Undefined symbols for architecture arm64:
      "_host_hooks", referenced from:
          gt_pch_save(__sFILE*) in libbackend.a(ggc-common.o)
          gt_pch_restore(__sFILE*) in libbackend.a(ggc-common.o)
          toplev::main(int, char**) in libbackend.a(toplev.o)
    ld: symbol(s) not found for architecture arm64
2022-04-06 21:55:56 +01:00
Vladimír Čunát
f91a565fe3
gnat*: fixup build with glibc-2.34 2022-04-04 18:58:13 +02:00
John Ericson
ed07c3b1a2
Merge pull request #163489 from alyssais/gcc-static-lib
pkgsStatic.stdenv.cc.cc: put static libs in $lib
2022-03-22 22:07:50 -04:00
Alyssa Ross
12c37aec37
pkgsStatic.stdenv.cc.cc: put static libs in $lib
libtool requires the library files its .la files describe to be in the
same directory as those files.  We only do this for compilers without
shared libraries, so that the libraries in $lib are always the
libraries the package set is supposed to use.

Fixes: https://github.com/NixOS/nixpkgs/issues/76873
Fixes: https://github.com/NixOS/nixpkgs/issues/108534
2022-03-22 17:56:11 +00:00
Alyssa Ross
c6dd11ca39
Revert "gcc: Always pass --enable-shared by default"
This reverts commit 8e48232180.

Since pkgsStatic.stdenv.cc can only produce static binaries, there's
no reason to include that compilers e.g. libstdc++.so.
2022-03-22 17:56:08 +00:00
github-actions[bot]
e452d308f5
Merge staging-next into staging 2022-03-22 12:02:02 +00:00
Alyssa Ross
cb040db7ab pkgsStatic.gcc: fix build
LTO requires building a compiler plugin, which is a shared object.

The closure is a bit wild but it builds and can compile programs.
2022-03-22 10:52:36 +00:00
Maximilian Bosch
e10ea9608a
gcc{7,9,10}: apply patches for asan w/glibc-2.34
This should fix a few broken cc-wrapper tests that also check for
libasan[1][2][3]:

    [...]
    checking whether sanitizers are fully functional... ==243==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22)
    [...]

The underlying issue is that `SIGSTKSZ` isn't a compile-time constant
anymore, but in this case the uninitialized `kAltStackSize` was
initialized early enough to evalute to `0`[4].

The issue is already fixed in gcc11 and there's  GCC 8.5 which also
contains the patch, however the backports to v9 and v10 aren't released
yet, so we have to apply patches on our own here.

For GCC 7.5 I applied the patch from gcc8 as it doesn't seem as if
there's an official upstream backport.

[1] https://hydra.nixos.org/build/163102264
[2] https://hydra.nixos.org/build/163624687
[3] https://hydra.nixos.org/build/163619227
[4] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100114
2022-02-27 10:26:58 +01:00
Zhaofeng Li
2fca45565d
gcc9: Add no-sys-dir patch for RISC-V (#154230)
Same as in gcc{10,11} (#147942).
2022-01-12 06:27:48 -05:00
Dmitry Kalinkin
1a9297102c
Merge branch 'master' into staging-next 2021-12-23 16:58:33 -05:00
Vladimír Čunát
28e731742c
Revert "Merge #142792: gcc9: 9.3.0 -> 9.4.0"
This reverts commit d71611fb72, reversing
changes made to cae9272c92.

The update caused an issue on aarch64-linux where it's the default
compiler, many packages got broken (usually through `mariadb`; I think).
File lib/gcc/aarch64-unknown-linux-gnu/9.4.0/include/arm_acle.h
got unbalanced braces (look at `cplusplus` lines), e.g. see in
/nix/store/fvkdvx69sf8h99xgx0m42dzfd5ly5csr-gcc-9.4.0/

I don't know how exactly it happened, as in the source this header is OK
and hasn't even changed between 9.3.0 and 9.4.0.  I assume that some
post-processing on headers got broken.  Anyway, I don't have much
motivation to dig deeper here, but perhaps someone else will.
2021-12-19 10:36:57 +01:00
oxalica
0d1750e9c0
gcc{10,11}: add no-sys-dir patch for RiscV
RiscV has an individual STARTFILE_PREFIX_SPEC macro which also need to
be patched.
2021-11-30 16:58:45 +08:00
Vladimír Čunát
d71611fb72
Merge #142792: gcc9: 9.3.0 -> 9.4.0 (into staging) 2021-11-25 09:09:06 +01:00
Alyssa Ross
3f01b576af
Merge remote-tracking branch 'nixpkgs/staging-next' into staging
Conflicts:
	nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
	nixos/doc/manual/release-notes/rl-2111.section.md
2021-10-28 16:07:38 +00:00
ajs124
4080dff4f6 gcc8: 8.4.0 -> 8.5.0 2021-10-27 17:49:56 +02:00
ajs124
81394b0ad8 gcc9: 9.3.0 -> 9.4.0 2021-10-25 00:24:08 +02:00
Ivan Babrou
e8abd9cc16 gcc11: 11.1.0 -> 11.2.0
The cyclades patch has been applied upstream:

* https://github.com/gcc-mirror/gcc/commit/2bf34b9f4e4
2021-10-23 12:12:18 -07:00
Peter Simons
476635afe1 Drop myself from meta.maintainers for most packages.
I'd like to reduce the number of Github notifications and
review requests I receive.
2021-10-14 11:01:27 +02:00
Sergei Trofimovich
46951d9527
gcc48, gcc49: apply upstream fix for gcc-11 (#138979)
Without the change build fails against gcc-11 as:

```
../../gcc-4.8.5/gcc/reload1.c:89:24:
  error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
   89 |   (this_target_reload->x_spill_indirect_levels)
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
```

Co-authored-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>

Co-authored-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
2021-09-24 02:17:09 -04:00