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>
This commit is contained in:
Adam Joseph 2023-02-13 14:36:08 -08:00
parent 2d285b1590
commit 24b07fc9e5
3 changed files with 9 additions and 3 deletions

View File

@ -27,6 +27,7 @@
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
, libxcrypt
, disableGdbPlugin ? !enablePlugin
}:
# Make sure we get GNU sed.
@ -115,6 +116,7 @@ let majorVersion = "11";
enableLTO
enableMultilib
enablePlugin
disableGdbPlugin
enableShared
disableBootstrap
fetchpatch

View File

@ -28,6 +28,7 @@
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
, libxcrypt
, disableGdbPlugin ? !enablePlugin
}:
# Make sure we get GNU sed.
@ -144,6 +145,7 @@ let majorVersion = "12";
cloog
crossStageStatic
disableBootstrap
disableGdbPlugin
enableLTO
enableMultilib
enablePlugin

View File

@ -11,6 +11,7 @@
, enableLTO
, enableMultilib
, enablePlugin
, disableGdbPlugin ? !enablePlugin
, enableShared
, langC
@ -26,6 +27,7 @@
, disableBootstrap ? stdenv.targetPlatform != stdenv.hostPlatform
}:
assert disableGdbPlugin -> !enablePlugin;
assert langJava -> lib.versionOlder version "7";
# Note [Windows Exception Handling]
@ -172,9 +174,9 @@ let
then ["--enable-multilib" "--disable-libquadmath"]
else ["--disable-multilib"])
++ lib.optional (!enableShared) "--disable-shared"
++ [
(lib.enableFeature enablePlugin "plugin")
]
++ lib.singleton (lib.enableFeature enablePlugin "plugin")
# Libcc1 is the GCC cc1 plugin for the GDB debugger which is only used by gdb
++ lib.optional disableGdbPlugin "--disable-libcc1"
# Support -m32 on powerpc64le/be
++ lib.optional (targetPlatform.system == "powerpc64le-linux")