Commit Graph

36 Commits

Author SHA1 Message Date
Eman Resu
5f7ff1085a gcc: pass result of lib.systems.equals around rather than recomputing 2026-05-11 19:27:43 -04:00
Ben Siraphob
0f420e96c4 gcc, libgcc: fix cross-compilation for SH4
- Pass --with-multilib-list=m4,m4-nofpu for SH4 so the kernel can use
  -m4-nofpu. Move libraries out of !m4/ multilib subdirectory in
  postInstall before moveToOutput.
- Generate sysroot-suffix.h for SH4 in the standalone libgcc builder.
- Add linux-kernel.target = "vmlinux" and installTarget for SH4.

All changes scoped to isSh4 to avoid rebuilds on other platforms.
2026-04-20 13:02:20 -07:00
David McFarland
f2ac4eef52 gcc: move cygwin DLLs to $target/bin 2026-02-08 19:47:26 -04:00
Emily
18bf03bc48 gcc: pass -Wno-complain-wrong-lang when using -fmacro-prefix-map
This will break GCC < 13 when compiled with LLVM, but those versions
are EOL and should be removed anyway, so I’m happy to do the nudge
rather than spend more effort on this hopefully‐temporary hack.
2025-08-08 17:48:58 +01:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
K900
7d36ee97e6 Merge remote-tracking branch 'origin/master' into staging-next 2025-03-14 09:56:27 +03:00
Stefan Frijters
be26b135bc gcc: use lib.systems.equals instead of direct equality checking 2025-03-13 11:37:05 +01:00
Stefan Frijters
54849e2fb8 gcc: fix inconsistency in isCross condition
In libgcc.nix, `targetPlatformSlash` is set by checking if hostPlatform == targetPlatform.
In default.nix, `targetConfig` (which is also going to be part of the path) is also set by checking if hostPlatform == targetPlatform.

However, in common.nix, the recently added `isCross` is set by checking if hostPlatform.config == targetPlatform.config.
This means that for platforms like '-nolibc' the paths in common.nix are not set up correctly for libgcc.nix to find and move libgcc_s.so .

Changing isCross to also check hostPlatform == targetPlatform fixes this issue.
2025-03-13 10:52:16 +01:00
K900
2b21c29f9a gcc: remove .la files 2025-03-11 21:07:32 +03:00
K900
a820a1b67b Revert "gcc: disable symlink checks on cross + nolibc for now"
This reverts commit 3fd43d5d74.

The proper fix is now in.
2025-02-08 13:26:15 +03:00
K900
5e2e98f3b7 gcc: document, clean up, undangle install symlink hacks 2025-02-08 13:26:15 +03:00
K900
17c01aad84 gcc: explicitly disallow cross + multilib, extract targetLibDir to variable 2025-02-08 12:07:15 +03:00
K900
536c98cb32 Revert "gcc: rework, clean up, and document the cursed symlink hack" 2025-02-08 11:54:21 +03:00
K900
97a3367a33 Revert "gcc: disable symlink checks on cross + nolibc for now"
This reverts commit 3fd43d5d74.

The proper fix is now in.
2025-02-02 22:12:49 +03:00
K900
c1907fbbf0 gcc: rework, clean up, and document the cursed symlink hack
Fixes dangling symlinks.

Also flips the direction of symlinks on cross
from $lib/$target/lib -> $lib/lib to $lib/lib -> $lib/$target/lib
2025-02-02 22:12:49 +03:00
K900
3fd43d5d74 gcc: disable symlink checks on cross + nolibc for now
This is a hack, but a proper fix requires an stdenv rebuild,
so it will have to go to staging.
2025-02-02 09:47:58 +03:00
Silvan Mosberger
84d4f874c2 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev 78e9caf153
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:23:58 +01:00
Wolfgang Walther
d86588d230 treewide: improve prepending and appending derivation arguments in bash code
Those would be problematic with __structuredAttrs turned on, because
they'd turn those nice bash arrays back into strings - and potentially
lose some of the values on the way.
2024-11-25 09:09:23 +01:00
Randy Eckenrode
a77d0eb819 gcc: fix extraLDFlags logic after undoing staging-next workaroud
The original logic was prepending to the array, but this one prepends
the array to itself, which breaks the x86_64-linux stdenv bootstrap. The
correct thing to do is build up the arguments in a temporary array and
prepend it like the original code was doing.
2024-10-10 17:04:36 -04:00
Randy Eckenrode
ac31fb7505 gcc: remove staging-next workaround 2024-10-10 01:07:29 -04:00
K900
5a9d1835e1 glibc: 2.39-52 -> 2.40-36 (#342073) 2024-09-20 19:42:37 +03:00
Maximilian Bosch
35d12c9cfc gcc: remove "fixed" pthread.h
Fixes

    /nix/store/8pq96x5qsczrmc926795lf7j4dzy2c8q-binutils-patchelfed-ld-2.43.1/bin/ld: ../../src/liblzma/.libs/liblzma.so: undefined reference to `__pthread_cond_timedwait64'
    collect2: error: ld returned 1 exit status

while building `xz` for `stdenv`. The root cause is that glibc replaced
`__USE_TIME_BITS64` with `__USE_TIME64_REDIRECTS`[1]. However, the
stage3 GCC seems to use the bootstrap headers from glibc for
`fixincludes`, i.e. headers w/o this change. Because of that, the xz
build with stage3 stdenv gets a header that looks like this:

    # ifndef __USE_TIME_BITS64
    /* ... */
    # else
    #  ifdef __REDIRECT
    /* ... */
    #  else
    #   define pthread_cond_timedwait __pthread_cond_timedwait64
    #  endif
    # endif

Since __USE_TIME_BITS64 doesn't exist anymore because a new glibc is used
for building, the preprocessor ends up in the condition defining
`__pthread_cond_timedwait64` even though it's not supposed to end up
there since __pthread_cond_timedwait64 doesn't exist on x86_64[2].

I decided to just kill the header here since GCC claims that all the
`pthread.h` only very old glibc versions or platform-specific libcs we
don't use[3].

[1] https://sourceware.org/git/?p=glibc.git%3Ba%3Dcommit%3Bh%3Ddd535f4f19ef2b5c367a362af445ecadcf45401e
[2] https://inbox.sourceware.org/libc-stable/50c0269d-b73c-4e8a-9816-65f72d6082c0@linaro.org/
[3] https://github.com/gcc-mirror/gcc/blob/releases/gcc-14.2.0/fixincludes/inclhack.def
2024-09-15 15:36:48 +02:00
Emily
de4388c609 {cc-wrapper,gcc}: drop unused logic and patches 2024-09-15 02:45:00 +01:00
Randy Eckenrode
ea889da7e6 gcc: drop rpath from build on platforms that don’t set rpaths
Darwin uses absolute path install names, so setting rpaths is unnecessary. This fixes breakage on older versions of GCC that try to set a deployment target that does not support rpaths.
2024-07-22 12:17:05 -04: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
Artturin
3d4e0708a0 gcc: move dll.a in lib64 to lib output too
same as c304c1e7d0
2023-08-29 01:04:15 +03:00
marius david
2eeb227d77 gcc: move dll to output 2023-08-27 21:40:34 +03:00
Adam Joseph
92186a49bf gcc: factor out forceLibgccToBuildCrtStuff 2023-08-14 15:08:28 -07:00
Sergei Trofimovich
3d66844c2d gcc: revert "do not install sys-include headers for cross-compilers."
The change reverts commit 7df4387ebd

A few reasons to revert the commit:
1. The change was not enough to restore `-idirafter` override semantic
   to match unwrapped compiler.
2. The change broke override semantics for cross-compilers
3. The change made override semantics different between cross-compiler
   and native compiler

All of three have some overlap between, but I think it's important
to call all of them out.

The main fallout is the uboot builds, reported by cynerd.

Used the following test to check the override recovery:

    $ nix shell github:NixOS/nixpkgs/release-22.05#pkgsCross.aarch64-multiplatform.stdenv.cc
    $$ cat stdio.h
    # empty
    $$ printf "#include <stdio.h>" | aarch64-unknown-linux-gnu-gcc -E - -o - -idirafter . >/dev/null; echo $?
    0

It failed before the change and succeded after.
2023-07-26 16:40:42 +01:00
Adam Joseph
7621636030 gcc: use Nix instead of bash for conditional
Now that we use the standard builder, the commands produced by
pre-configure.nix are wrapped in a bash function.  Inside of a bash
function, `export foo=` will still add `foo` to the environment of
any child processes forked after that point, but those variables
will *not* be visible to bash code which is outside of the
function-scope in which the `export` occurs.

Weird crap like this is yet another reason why we need to move away
from using bash for logic.  Let's switch.
2023-07-07 05:56:46 -07:00
Adam Joseph
5eaf17927e gcc: add -g to declare
The bash `declare` builtin works differently when it occurs inside
function, as it now does due to breaking up the monolithic
`builder.sh` into separate phases.  We have to add `-g` in order to
get the outside-of-a-bash-function behavior when using `declare`
within a bash function.
2023-07-07 05:56:46 -07:00
Adam Joseph
67da7b9a1f gcc: remove builder.sh 2023-07-07 05:56:44 -07:00
Adam Joseph
1157e1d856 gcc: add args to common/builder.nix, split up script into phases
This commit adds arguments to `builder.nix`, making it a callable
function, and splits up the single massive shell script into
separate attributes for each phase.  It also drops the first two
lines and the last line because these are part of the default
builder.

All script lines which were not part of a phase function have been
moved into `preUnpack` since this is the first phase that runs.
Subsequent commits will move parts of this to more sensible
locations.
2023-07-07 05:55:15 -07:00
Adam Joseph
72284b0d40 gcc: make common/builder.nix into valid Nix syntax
This commit performs two search-and-replace operations:

- replace all `${` with `''${`
- replace `''` with `""` in shell scripts

This commit is left unsquashed to make review of the subsequent
commits easier.
2023-07-07 05:55:15 -07:00
Adam Joseph
caf22a33eb gcc: copy gcc/builder.sh to gcc/common/builder.nix
This commit is left unsquashed to make review of the subsequent
commits easier.
2023-07-07 05:55:15 -07:00