nixpkgs/pkgs
Adam Joseph 2affd455a4 gccCrossStageStatic: enable dynamic libraries, rename to gccWithoutTargetLibc
This commit allows `gccCrossStageStatic` to build dynamically-linked
libraries.  Since is no longer restricted to building static
libraries its name is no longer appropriate, and this commit also
renames it to the more-accurate `gccWithoutTargetLibc`.

By default, you can't build a gcc that knows how to create dynamic
libraries unless you have already built the targetPlatform libc.

Because of this, our gcc cross-compiler is built in two stages:

  1. Build a cross-compiler (gccCrossStageStatic) that can build
     only static libraries.

  2. Use gccCrossStageStatic to compile the targetPlatform libc.

  3. Use the targetPlatform libc to build a fully-capable cross
     compiler.

You might notice that this pattern looks very similar to what we do
with `xgcc` in the stdenv bootstrap.  Indeed it is!  I would like to
work towards getting the existing stdenv bootstrap to handle cross
compilers as well.  However we don't want to cripple `stdenv.xgcc`
by taking away its ability to build dynamic libraries.

It turns out that the only thing gcc needs the targetPlatform libc
for is to emit a DT_NEEDED for `-lc` into `libgcc.so`.  That's it!
And since we don't use `gccCrossStageStatic` to build anything other
than libc, it's safe to omit the `DT_NEEDED` because that `libgcc`
will never be loaded by anything other than `libc`.  So `libc` will
already be in the process's address space.

Other people have noticed this; crosstool-ng has been using this
approach for a very long time:

  36ad0b17a7/scripts/build/cc/gcc.sh (L638-L640)
2023-07-01 13:12:40 -07:00
..
applications alacritty: 0.12.1 -> 0.12.2 (#240962) 2023-07-01 21:31:51 +02:00
build-support
common-updater
data Merge pull request #240844 from r-ryantm/auto-update/lxgw-neoxihei 2023-07-01 12:42:52 +08:00
desktops gnome.evince: Change meta.platforms to unix 2023-07-01 12:21:37 +02:00
development gccCrossStageStatic: enable dynamic libraries, rename to gccWithoutTargetLibc 2023-07-01 13:12:40 -07:00
games
misc urbit: 2.9 -> 2.10 2023-06-30 12:35:49 +00:00
os-specific gccCrossStageStatic: enable dynamic libraries, rename to gccWithoutTargetLibc 2023-07-01 13:12:40 -07:00
pkgs-lib
servers Merge pull request #240896 from mweinelt/zigbee2mqtt-1.32.0 2023-07-01 17:37:30 +02:00
shells Merge pull request #240032 from giorgiga/fishPlugins-sdkman-for-fish-update 2023-06-30 18:31:12 +02:00
stdenv Merge pull request #239005 from Artturin/setorfunoverr 2023-07-01 15:27:23 +02:00
test Merge pull request #239005 from Artturin/setorfunoverr 2023-07-01 15:27:23 +02:00
tools Merge pull request #240483 from fabaff/pentestgpt 2023-07-01 20:33:36 +02:00
top-level gccCrossStageStatic: enable dynamic libraries, rename to gccWithoutTargetLibc 2023-07-01 13:12:40 -07:00