Unverified Commit 218669e1 authored by Adam Joseph's avatar Adam Joseph Committed by GitHub
Browse files

Merge pull request #238154 from amjoseph-nixpkgs/pr/gcc/crossStageStatic

gccCrossStageStatic: enable dynamic libraries, rename it
parents f92c3239 96a2f1b4
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -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";
@@ -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`
+11 −8
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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";
@@ -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 {
@@ -99,7 +99,7 @@ let majorVersion = "10";
        binutils
        buildPackages
        cloog
        crossStageStatic
        withoutTargetLibc
        enableLTO
        enableMultilib
        enablePlugin
@@ -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 { })
@@ -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; })
]
+11 −8
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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 {
@@ -110,7 +110,7 @@ let majorVersion = "11";
        binutils
        buildPackages
        cloog
        crossStageStatic
        withoutTargetLibc
        enableLTO
        enableMultilib
        enablePlugin
@@ -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 { })
@@ -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; })
]
+11 −8
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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 {
@@ -152,7 +152,7 @@ let majorVersion = "12";
        binutils
        buildPackages
        cloog
        crossStageStatic
        withoutTargetLibc
        disableBootstrap
        disableGdbPlugin
        enableLTO
@@ -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;
@@ -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; })
]
+10 −7
Original line number Diff line number Diff line
@@ -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
@@ -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
@@ -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 {
@@ -146,7 +146,7 @@ let majorVersion = "13";
        binutils
        buildPackages
        cloog
        crossStageStatic
        withoutTargetLibc
        disableBootstrap
        disableGdbPlugin
        enableLTO
@@ -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;
@@ -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; })
]
Loading