diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 78ccd50ba79a5..a3462d2d424b2 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -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` diff --git a/pkgs/development/compilers/gcc/10/default.nix b/pkgs/development/compilers/gcc/10/default.nix index c1f6f061f8cd1..d384298993728 100644 --- a/pkgs/development/compilers/gcc/10/default.nix +++ b/pkgs/development/compilers/gcc/10/default.nix @@ -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 @@ -295,5 +295,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 enableShared crossStageStatic; }) ] diff --git a/pkgs/development/compilers/gcc/11/default.nix b/pkgs/development/compilers/gcc/11/default.nix index 47662d5002c43..14073c6a05bcc 100644 --- a/pkgs/development/compilers/gcc/11/default.nix +++ b/pkgs/development/compilers/gcc/11/default.nix @@ -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 @@ -307,6 +307,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 enableShared crossStageStatic; }) (callPackage ../common/checksum.nix { inherit langC langCC; }) ] diff --git a/pkgs/development/compilers/gcc/12/default.nix b/pkgs/development/compilers/gcc/12/default.nix index e3ad55ae90ca8..be3fde0649e15 100644 --- a/pkgs/development/compilers/gcc/12/default.nix +++ b/pkgs/development/compilers/gcc/12/default.nix @@ -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 @@ -353,7 +353,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 enableShared crossStageStatic; }) (callPackage ../common/checksum.nix { inherit langC langCC; }) ] diff --git a/pkgs/development/compilers/gcc/13/default.nix b/pkgs/development/compilers/gcc/13/default.nix index b6f83f2662bfa..c1834ead11eee 100644 --- a/pkgs/development/compilers/gcc/13/default.nix +++ b/pkgs/development/compilers/gcc/13/default.nix @@ -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 @@ -347,7 +347,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 enableShared crossStageStatic; }) (callPackage ../common/checksum.nix { inherit langC langCC; }) ] diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 27fa2160c1299..36359b213c78d 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -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 @@ -323,5 +323,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 enableShared crossStageStatic; }) ] diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 2477f53b9caa0..d708d0d442449 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -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 @@ -350,5 +350,5 @@ lib.pipe (stdenv.mkDerivation ({ '';} )) [ - (callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; }) + (callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform enableShared crossStageStatic; }) ] diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 61874359b2a31..ba8bcf5342a32 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -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 , flex , perl ? null # optional, for texi2pod (then pod2man); required for Java @@ -368,5 +368,5 @@ lib.pipe (stdenv.mkDerivation ({ '';} )) [ - (callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform crossStageStatic; }) + (callPackage ../common/libgcc.nix { inherit version langC langCC langJit targetPlatform hostPlatform enableShared crossStageStatic; }) ] diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 19010a578ac4f..a93d3c491b584 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -7,8 +7,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 @@ -302,5 +302,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 enableShared crossStageStatic; }) ] diff --git a/pkgs/development/compilers/gcc/8/default.nix b/pkgs/development/compilers/gcc/8/default.nix index f06b60ba6df6d..1f913fe57d359 100644 --- a/pkgs/development/compilers/gcc/8/default.nix +++ b/pkgs/development/compilers/gcc/8/default.nix @@ -7,8 +7,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 @@ -277,5 +277,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 enableShared crossStageStatic; }) ] diff --git a/pkgs/development/compilers/gcc/9/default.nix b/pkgs/development/compilers/gcc/9/default.nix index d022349c73a1f..79ca57e2f72c3 100644 --- a/pkgs/development/compilers/gcc/9/default.nix +++ b/pkgs/development/compilers/gcc/9/default.nix @@ -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 @@ -292,5 +292,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 enableShared crossStageStatic; }) ] diff --git a/pkgs/development/compilers/gcc/common/libgcc.nix b/pkgs/development/compilers/gcc/common/libgcc.nix index 2477a6811aa11..29ec421555ed0 100644 --- a/pkgs/development/compilers/gcc/common/libgcc.nix +++ b/pkgs/development/compilers/gcc/common/libgcc.nix @@ -7,8 +7,11 @@ , targetPlatform , hostPlatform , crossStageStatic +, enableShared }: +assert !stdenv.targetPlatform.hasSharedLibraries -> !enableShared; + drv: lib.pipe drv ([