Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccCrossStageStatic: enable dynamic libraries, rename it #238154

Merged
6 commits merged into from Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ rec {
# choice.
else "bfd";
extensions = rec {
sharedLibrary =
sharedLibrary = assert final.hasSharedLibraries;
/**/ if final.isDarwin then ".dylib"
else if final.isWindows then ".dll"
else ".so";
Expand Down Expand Up @@ -132,6 +132,25 @@ rec {
# uname -r
release = null;
};

# It is important that hasSharedLibraries==false when the platform has no
# dynamic library loader. Various tools (including the gcc build system)
# have knowledge of which platforms are incapable of dynamic linking, and
# will still build on/for those platforms with --enable-shared, but simply
# omit any `.so` build products such as libgcc_s.so. When that happens,
# it causes hard-to-troubleshoot build failures.
hasSharedLibraries = with final;
(isAndroid || isGnu || isMusl # Linux (allows multiple libcs)
|| isDarwin || isSunOS || isOpenBSD || isFreeBSD || isNetBSD # BSDs
|| isCygwin || isMinGW # Windows
) && !isStatic;

# The difference between `isStatic` and `hasSharedLibraries` is mainly the
# addition of the `staticMarker` (see make-derivation.nix). Some
# platforms, like embedded machines without a libc (e.g. arm-none-eabi)
# don't support dynamic linking, but don't get the `staticMarker`.
# `pkgsStatic` sets `isStatic=true`, so `pkgsStatic.hostPlatform` always
# has the `staticMarker`.
isStatic = final.isWasm || final.isRedox;

# Just a guess, based on `system`
Expand Down
19 changes: 11 additions & 8 deletions pkgs/development/compilers/gcc/10/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
, enableShared ? !stdenv.targetPlatform.isStatic
, enableLTO ? !stdenv.hostPlatform.isStatic
, enableShared ? stdenv.targetPlatform.hasSharedLibraries
, enableLTO ? stdenv.hostPlatform.hasSharedLibraries
, texinfo ? null
, perl ? null # optional, for texi2pod (then pod2man)
, gmp, mpfr, libmpc, gettext, which, patchelf, binutils
Expand All @@ -22,7 +22,7 @@
, name ? "gcc"
, libcCross ? null
, threadsCross ? null # for MinGW
, crossStageStatic ? false
, withoutTargetLibc ? false
, gnused ? null
, cloog ? null # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
Expand Down Expand Up @@ -69,7 +69,7 @@ let majorVersion = "10";
++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch

# Obtain latest patch with ../update-mcfgthread-patches.sh
++ optional (!crossStageStatic && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch
++ optional (!withoutTargetLibc && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch

++ optional (buildPlatform.system == "aarch64-darwin" && targetPlatform != buildPlatform) (fetchpatch {
url = "https://raw.githubusercontent.com/richard-vd/musl-cross-make/5e9e87f06fc3220e102c29d3413fbbffa456fcd6/patches/gcc-${version}/0008-darwin-aarch64-self-host-driver.patch";
Expand All @@ -78,7 +78,7 @@ let majorVersion = "10";

/* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-";

callFile = lib.callPackageWith {
Expand All @@ -99,7 +99,7 @@ let majorVersion = "10";
binutils
buildPackages
cloog
crossStageStatic
withoutTargetLibc
enableLTO
enableMultilib
enablePlugin
Expand Down Expand Up @@ -214,7 +214,10 @@ lib.pipe (stdenv.mkDerivation ({
)
'';

inherit noSysDirs staticCompiler crossStageStatic
# kludge to prevent a mass-rebuild; will be removed in a PR sent to staging
crossStageStatic = withoutTargetLibc;

inherit noSysDirs staticCompiler
libcCross crossMingw;

inherit (callFile ../common/dependencies.nix { })
Expand Down Expand Up @@ -295,5 +298,5 @@ lib.pipe (stdenv.mkDerivation ({
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared; })
]
19 changes: 11 additions & 8 deletions pkgs/development/compilers/gcc/11/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
, enableShared ? !stdenv.targetPlatform.isStatic
, enableLTO ? !stdenv.hostPlatform.isStatic
, enableShared ? stdenv.targetPlatform.hasSharedLibraries
, enableLTO ? stdenv.hostPlatform.hasSharedLibraries
, texinfo ? null
, perl ? null # optional, for texi2pod (then pod2man)
, gmp, mpfr, libmpc, gettext, which, patchelf, binutils
Expand All @@ -22,7 +22,7 @@
, name ? "gcc"
, libcCross ? null
, threadsCross ? null # for MinGW
, crossStageStatic ? false
, withoutTargetLibc ? false
, gnused ? null
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
Expand Down Expand Up @@ -82,14 +82,14 @@ let majorVersion = "11";
++ optional (stdenv.isDarwin && targetPlatform.isAvr) ./avr-gcc-11.3-darwin.patch

# Obtain latest patch with ../update-mcfgthread-patches.sh
++ optional (!crossStageStatic && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch
++ optional (!withoutTargetLibc && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch

# openjdk build fails without this on -march=opteron; is upstream in gcc12
++ [ ./gcc-issue-103910.patch ];

/* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-";

callFile = lib.callPackageWith {
Expand All @@ -110,7 +110,7 @@ let majorVersion = "11";
binutils
buildPackages
cloog
crossStageStatic
withoutTargetLibc
enableLTO
enableMultilib
enablePlugin
Expand Down Expand Up @@ -227,7 +227,10 @@ lib.pipe (stdenv.mkDerivation ({
)
'';

inherit noSysDirs staticCompiler crossStageStatic
# kludge to prevent a mass-rebuild; will be removed in a PR sent to staging
crossStageStatic = withoutTargetLibc;

inherit noSysDirs staticCompiler
libcCross crossMingw;

inherit (callFile ../common/dependencies.nix { })
Expand Down Expand Up @@ -307,6 +310,6 @@ lib.pipe (stdenv.mkDerivation ({
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared; })
(callPackage ../common/checksum.nix { inherit langC langCC; })
]
19 changes: 11 additions & 8 deletions pkgs/development/compilers/gcc/12/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
, enableShared ? !stdenv.targetPlatform.isStatic
, enableLTO ? !stdenv.hostPlatform.isStatic
, enableShared ? stdenv.targetPlatform.hasSharedLibraries
, enableLTO ? stdenv.hostPlatform.hasSharedLibraries
, texinfo ? null
, perl ? null # optional, for texi2pod (then pod2man)
, gmp, mpfr, libmpc, gettext, which, patchelf, binutils
Expand All @@ -23,7 +23,7 @@
, name ? "gcc"
, libcCross ? null
, threadsCross ? null # for MinGW
, crossStageStatic ? false
, withoutTargetLibc ? false
, gnused ? null
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
Expand Down Expand Up @@ -127,11 +127,11 @@ let majorVersion = "12";
++ optional (stdenv.isDarwin && langAda) ../gnat-darwin-dylib-install-name.patch

# Obtain latest patch with ../update-mcfgthread-patches.sh
++ optional (!crossStageStatic && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch;
++ optional (!withoutTargetLibc && targetPlatform.isMinGW && threadsCross.model == "mcf") ./Added-mcf-thread-model-support-from-mcfgthread.patch;

/* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-";

callFile = lib.callPackageWith {
Expand All @@ -152,7 +152,7 @@ let majorVersion = "12";
binutils
buildPackages
cloog
crossStageStatic
withoutTargetLibc
disableBootstrap
disableGdbPlugin
enableLTO
Expand Down Expand Up @@ -271,7 +271,10 @@ lib.pipe (stdenv.mkDerivation ({
)
'';

inherit noSysDirs staticCompiler crossStageStatic
# kludge to prevent a mass-rebuild; will be removed in a PR sent to staging
crossStageStatic = withoutTargetLibc;

inherit noSysDirs staticCompiler
libcCross crossMingw;

inherit (callFile ../common/dependencies.nix { }) depsBuildBuild nativeBuildInputs depsBuildTarget buildInputs depsTargetTarget;
Expand Down Expand Up @@ -353,7 +356,7 @@ lib.pipe (stdenv.mkDerivation ({
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared; })
(callPackage ../common/checksum.nix { inherit langC langCC; })
]

17 changes: 10 additions & 7 deletions pkgs/development/compilers/gcc/13/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
, enableShared ? !stdenv.targetPlatform.isStatic
, enableLTO ? !stdenv.hostPlatform.isStatic
, enableShared ? stdenv.targetPlatform.hasSharedLibraries
, enableLTO ? stdenv.hostPlatform.hasSharedLibraries
, texinfo ? null
, perl ? null # optional, for texi2pod (then pod2man)
, gmp, mpfr, libmpc, gettext, which, patchelf, binutils
Expand All @@ -23,7 +23,7 @@
, name ? "gcc"
, libcCross ? null
, threadsCross ? null # for MinGW
, crossStageStatic ? false
, withoutTargetLibc ? false
, gnused ? null
, cloog # unused; just for compat with gcc4, as we override the parameter on some places
, buildPackages
Expand Down Expand Up @@ -125,7 +125,7 @@ let majorVersion = "13";

/* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-";

callFile = lib.callPackageWith {
Expand All @@ -146,7 +146,7 @@ let majorVersion = "13";
binutils
buildPackages
cloog
crossStageStatic
withoutTargetLibc
disableBootstrap
disableGdbPlugin
enableLTO
Expand Down Expand Up @@ -265,7 +265,10 @@ lib.pipe (stdenv.mkDerivation ({
)
'';

inherit noSysDirs staticCompiler crossStageStatic
# kludge to prevent a mass-rebuild; will be removed in a PR sent to staging
crossStageStatic = withoutTargetLibc;

inherit noSysDirs staticCompiler
libcCross crossMingw;

inherit (callFile ../common/dependencies.nix { }) depsBuildBuild nativeBuildInputs depsBuildTarget buildInputs depsTargetTarget;
Expand Down Expand Up @@ -347,7 +350,7 @@ lib.pipe (stdenv.mkDerivation ({
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared; })
(callPackage ../common/checksum.nix { inherit langC langCC; })
]

17 changes: 10 additions & 7 deletions pkgs/development/compilers/gcc/4.8/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
, profiledCompiler ? false
, langJit ? false
, staticCompiler ? false
, enableShared ? !stdenv.targetPlatform.isStatic
, enableLTO ? !stdenv.hostPlatform.isStatic
, enableShared ? stdenv.targetPlatform.hasSharedLibraries
, enableLTO ? stdenv.hostPlatform.hasSharedLibraries
, texinfo ? null
, perl ? null # optional, for texi2pod (then pod2man); required for Java
, gmp, mpfr, libmpc, gettext, which, patchelf, binutils
Expand All @@ -26,7 +26,7 @@
, name ? "gcc"
, libcCross ? null
, threadsCross ? null # for MinGW
, crossStageStatic ? false
, withoutTargetLibc ? false
, gnused ? null
, buildPackages
, callPackage
Expand Down Expand Up @@ -109,7 +109,7 @@ let majorVersion = "4";

/* Cross-gcc settings (build == host != target) */
crossMingw = targetPlatform != hostPlatform && targetPlatform.libc == "msvcrt";
stageNameAddon = if crossStageStatic then "stage-static" else "stage-final";
stageNameAddon = if withoutTargetLibc then "stage-static" else "stage-final";
crossNameAddon = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-${stageNameAddon}-";

callFile = lib.callPackageWith {
Expand All @@ -135,7 +135,7 @@ let majorVersion = "4";
boehmgc
buildPackages
cloog
crossStageStatic
withoutTargetLibc
enableLTO
enableMultilib
enablePlugin
Expand Down Expand Up @@ -232,7 +232,10 @@ lib.pipe (stdenv.mkDerivation ({
''
else null;

inherit noSysDirs staticCompiler langJava crossStageStatic
# kludge to prevent a mass-rebuild; will be removed in a PR sent to staging
crossStageStatic = withoutTargetLibc;

inherit noSysDirs staticCompiler langJava
libcCross crossMingw;

inherit (callFile ../common/dependencies.nix { })
Expand Down Expand Up @@ -323,5 +326,5 @@ lib.pipe (stdenv.mkDerivation ({
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
))
[
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; })
(callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform withoutTargetLibc enableShared; })
]
Loading