Commit Graph

83 Commits

Author SHA1 Message Date
Emily
86b5f88a2f {gcc8{,Stdenv},gfortran8}: drop
Release branch from 6½ years ago, no update in 3½ years, unsupported
upstream, and unused in tree.

This finally resolves the tangled conditionals in `all.nix`, albeit in
a way I assume amjoseph wouldn’t have been too fond of. `default.nix`
still has some gnarly stuff in there. So it goes…
2024-11-22 18:03:01 +00:00
Emily
d3d474e85c {gcc7{,Stdenv},gfortran7}: drop
Release branch from 7½ years ago, no update in 5 years, unsupported
upstream, and unused in tree.
2024-11-22 18:03:01 +00:00
piegames
ae207af82b treewide: More string indentation fixes
Follow-up on #350296 with the packages that cause big rebuilds and need
to go through staging.
2024-10-23 21:52:18 +02:00
Randy Eckenrode
e50074418d
gcc: set up sysroot for the Darwin SDK
The GCC bootstrap builds each stage with an unwrapped GCC, which needs
to correctly handle looking for libraries and headers in sysroot.
Setting the native header folder to `/usr/include` will actually cause
GCC to search `<sysroot>/usr/include`, which is the SDKROOT in nixpkgs.
2024-10-10 17:04:36 -04:00
Emily
de4388c609 {cc-wrapper,gcc}: drop unused logic and patches 2024-09-15 02:45:00 +01:00
Sergei Trofimovich
88950412bc gcc49, gcc49Stdenv, gfortran49: remove old implementation
gcc-4.9.4 was released in Aug 3, 2016, 8 years ago. It's a branch that
went out of support years ago. Numerous bugs never get backported to
this version.

Let's remove it.
2024-09-12 10:32:19 +01:00
Sergei Trofimovich
1db443abb7 gcc48: remove old implementation
gcc-4.8.5 was released in June 23, 2015, 9 years ago. It's a branch that
went out of support years ago. Numerous bugs never get backported to
this version.

Let's remove it.
2024-09-10 22:05:47 +01:00
github-actions[bot]
e80257fbed
Merge master into staging-next 2024-08-07 00:02:22 +00:00
Daniel Nagy
4f85840d25 gcc: provide build support for gccrs
Patches from the gccrs project are being upstreamed into gcc. With
these changes we are now able to build a gcc with rust support like
this:

```nix
wrapCC (gcc14.cc.override {
  langRust = true;
});
```

More info:

https://rust-gcc.github.io/

https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608387.html
2024-08-06 20:26:34 +02:00
Robert Scott
48bde3a189 cc-wrapper: add support for pacret hardening flag on aarch64 2024-07-28 19:27:14 +01:00
Emily
8a837af302
Merge pull request #326819 from risicle/ris-shadowstack
cc-wrapper: add support for `shadowstack` hardening flag
2024-07-28 19:07:52 +01:00
Vladimír Čunát
64c6a981fe
Merge branch 'master' into staging-next 2024-07-27 09:18:58 +02:00
Randy Eckenrode
151776fbfc
gcc10: enable build on aarch64-darwin 2024-07-22 13:34:38 -04:00
Randy Eckenrode
33f416e434
gcc6: add x86_64-darwin to badPlatforms
ld64 crashes when trying to link during the GCC bootstrap.
2024-07-22 12:17:06 -04:00
Randy Eckenrode
f9b7f4ec09
tree-wide: use top-level cctools 2024-07-17 22:36:19 -04:00
Robert Scott
b207b6ef74 cc-wrapper: add support for shadowstack hardening flag 2024-07-14 21:25:47 +01:00
Franz Pletz
3db93c351d cc-wrapper: add stack clash protection hardening flag
Most Linux distributions are enabling this these days and it does
protect against real world vulnerabilities as demonstrated by
CVE-2018-16864 and CVE-2018-16865.

Fix #53753.

Information on llvm version support gleaned from
6609892a2d
68e07da3e5
092507a730

Information on gcc version support a lot harder to gather,
but both 32bit and 64bit arm do appear to be supported
based on the test suite.
2024-06-07 20:23:46 +01:00
Weijia Wang
d851de2647 gcc14: add aarch64-darwin support 2024-05-21 12:08:26 +02:00
Sergei Trofimovich
75104490c0 gcc14, gfortran14, gnat14, gccgo14: init at 14.1.0
Changes: https://gcc.gnu.org/gcc-14/changes.html
2024-05-21 12:08:26 +02:00
Philip Taron
64f4bdb7e1 Avoid top-level with ...; in pkgs/development/compilers/gcc/default.nix
I didn't fix the whitespace and indenting, but I really wanted to.

The global `with` was masking that `fetchFromGitHub` wasn't injected!
2024-03-28 03:04:49 +01:00
Adam Joseph
b81284ec71 gcc: link $lib/lib -> $lib/$targetConfig correctly and consistently
When native-compiling, gcc will install libraries into:

  /nix/store/...-$targetConfig-gcc-$version-lib/lib

When cross-compiling, gcc will install libraries into:

  /nix/store/...-$targetConfig-gcc-$version-lib/$targetConfig

When cross-compiling, we intended to create a link from $lib/lib to
$lib/$targetConfig, so that downstream users can always safely
assume that "${lib.getLib stdenv.cc.cc}/lib" is where the gcc
libraries are, regardless of whether `stdenv.cc.cc` is a cross
compiler or a native compiler.

Unfortunately, there were two problems with how we were trying to
create these links:

1. The link would be created only when `enableLibGccOutput==true`

2. The link was being created from the incorrect source
   `$lib/lib/lib` instead of `$lib/lib`.

Both of these mistakes are my fault.  This commit corrects them by
creating the link using `ln -Ts` (which is more predictable) and by
creating the link from `gcc/common/builder.nix` rather than from
`gcc/common/libgcc.nix`.
2024-03-15 18:18:24 +00:00
Robert Scott
4a91b3e798 cc-wrapper: add trivialautovarinit hardening flag support
this equates to -ftrivial-auto-var-init=pattern

clang has removed support for -ftrivial-auto-var-init=zero and
are unlikely to re-add it, so use -ftrivial-auto-var-init=pattern
on both compilers if only to make behaviour more consistent
between the two.

add to pkgsExtraHardening's defaultHardeningFlags.
2024-02-24 12:00:09 +00:00
Robert Scott
40868719b0 cc-wrapper: add zerocallusedregs hardening flag
this uses the value `used-gpr` which seems to be a commonly
chosen value for general use
2024-01-20 13:48:33 +00:00
Robert Scott
1a5bd697ad mkDerivation, bintools-wrapper: move defaultHardeningFlags determination to bintools-wrapper
this makes it a lot easier to create a modified stdenv with a
different set of defaultHardeningFlags and as a bonus allows us
to inject the correct defaultHardeningFlags into toolchain wrapper
scripts, reducing repetition.

while most hardening flags are arguably more of a compiler thing,
it works better to put them in bintools-wrapper because cc-wrapper
can easily refer to bintools but not vice-versa.

mkDerivation can still easily refer to either when it is constructed.

this also switches fortran-hook.sh to use the same defaults for
NIX_HARDENING_ENABLE as for C. previously NIX_HARDENING_ENABLE
defaults were apparently used to avoid passing problematic flags
to a fortran compiler, but this falls apart as soon as mkDerivation
sets its own NIX_HARDENING_ENABLE - cc.hardeningUnsupportedFlags
is a more appropriate mechanism for this as it actively filters
out flags from being used by the wrapper, so switch to using that
instead.

this is still an imperfect mechanism because it doesn't handle a
compiler which has both langFortran *and* langC very well - applying
the superset of the two's hardeningUnsupportedFlags to either
compiler's invocation. however this is nothing new - cc-wrapper
already poorly handles a langFortran+langC compiler, applying two
setup hooks that have contradictory options.
2023-12-09 16:30:45 +00:00
Emily Trau
f6e48acfa2 gcc8: support avr cross compilation on aarch64-darwin 2023-12-04 06:32:32 +11:00
Randy Eckenrode
f2a7764cab
gcc{6,7,8,9,10,11}: fix cross-compiler build on x86_64-darwin
Building a cross-compiler fails due to register storage class specifier
errors when building with clang 16 due to its defaulting to C++17.
Downgrading the error allows the older cross-compilers to build.
2023-12-02 18:43:00 -05:00
Randy Eckenrode
4a538d6b3d
gcc11: mark as bad on aarch64-darwin when building a cross-compiler 2023-12-02 18:42:00 -05:00
Randy Eckenrode
fe27958aed
gcc{6,7,8,9}: use target bintools on Darwin
Using the host bintools results in evaluation errors when building an
AVR cross-compiler due to trying to build cctools for AVR.
2023-12-02 18:32:15 -05:00
Adam Joseph
62dbf14a30 gcc: put environment variables in drvAttrs.env 2023-12-01 22:03:09 +00:00
github-actions[bot]
d49b3ff9e3
Merge staging-next into staging 2023-11-08 12:02:19 +00:00
Randy Eckenrode
299c06a0f5 gcc{48,49,6,7,8,9,10}: improve cctools-llvm compatibility
darwin.cctools defaults to `llvm-strip` when the version of LLVM in the
stdenv is 12 or newer. This strip implementation does not support the
`-c` flag required by older versions of GCC. Use the cctools-port
version for compatibility when building older versions of GCC.
2023-11-08 10:50:07 +00:00
Randy Eckenrode
b09f87fb0d gcc48: disable on x86_64-darwin
According to Hydra, the last time GCC 4.8 successfully built on Darwin
was October 2014. It is possible to make the first stage build
successfully with clang, but the resulting GCC is not capable of reading
the Darwin SDK headers due to their use of `__can_include`.

It’s been broken for almost a decade, so just disable it.
2023-11-08 07:32:47 +00:00
github-actions[bot]
599850da55
Merge staging-next into staging 2023-11-07 12:01:25 +00:00
Adam Joseph
78706a9184 gcc: move version information to gcc/versions.nix 2023-11-07 09:57:54 +00:00
Adam Joseph
1904125877 gcc: change "-stage-static" to "-nolibc" and "-stage-final" to ""
This commit changes the target suffix for the first-stage cross
compiler from `-stage-static` to `-nolibc`, and eliminates the
target suffix from the final-stage cross compiler (previously
`-stage-final`).

Co-authored-by: Artturi <Artturin@artturin.com>
Co-authored-by: John Ericson <git@JohnEricson.me>
2023-10-26 20:07:18 -07:00
github-actions[bot]
ab895db907
Merge staging-next into staging 2023-09-22 00:02:40 +00:00
Adam Joseph
ea61be413c gcc: set GFORTRAN_FOR_TARGET on cross-built native compilers
For a cross-built native compiler, i.e. build!=(host==target), the
bundled libgfortran needs a gfortran which can run on the
buildPlatform and emit code for the targetPlatform.  The compiler
which is built alongside gfortran in this configuration doesn't meet
that need: it runs on the hostPlatform.

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

The two libgccs are:

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

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

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

Closes #249680
2023-09-08 16:07:50 +03:00
Moritz Angermann
a81e3dcd75 treewide: replace libc == "msvcrt" with isMinGW
msvcrt is only one of the libcs in MinGW. We therefore
replace explictly testing for msvcrt with the isMinGW
predicate. This lays the foundation for ucrt64 support.
2023-09-08 10:56:08 +00:00
Adam Joseph
af319af225 gcc: unescapify backslash 2023-08-23 21:47:12 -07:00
Adam Joseph
80198b835b gcc: remove backticks-used-as-quotes (error prone) 2023-08-23 21:47:12 -07:00
Adam Joseph
040cf4248d gcc: simplify expression by applying workarounds more broadly
This commit simplifies our gcc expression by applying various
workarounds unconditionally, rather than only to exactly the
versions which applied them prior to the deduplication cleanup.

Unlike its predecessors https://github.com/NixOS/nixpkgs/pull/249707
and https://github.com/NixOS/nixpkgs/pull/250489 this commit *does*
affect eval.
2023-08-23 21:47:12 -07:00
Adam Joseph
8f225b515f gcc: match weird whack-a-mole per-version hash algorithm 2023-08-20 23:00:03 -07:00
Adam Joseph
de36365466 gcc: clean up version conditions 2023-08-20 23:00:03 -07:00
Adam Joseph
30171782b7 gcc: move version-map out of all-packages.nix, into pkgs/ 2023-08-20 23:00:02 -07:00
Adam Joseph
911452ccbd gcc: move patches attribute into patches/ subdirectory 2023-08-20 23:00:02 -07:00
Adam Joseph
95475034d5 gcc: if atLeast 4.8, use deduplicated version 2023-08-20 23:00:02 -07:00
Adam Joseph
beeb48d17a gcc: if atLeast 4.9, use deduplicated version 2023-08-20 23:00:02 -07:00