From 0d0f90765ea5a1e0d6d4e5b89787f4cdbb6b37be Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sat, 16 Apr 2022 16:32:08 -0700 Subject: [PATCH] stdenv: lib{gmp,mpc,mpfr,isl}-stage3: isPower64 -> no -fstack-protector Stage3 of the stdenv bootstrap attempts to link libraries compiled for static linkage (i.e. `*.a`) into a dynamically-linked executable. On powerpc64le this is not supported if the library compiled for static linkage was built using `-fstack-protector`, because that option requires `-lssp` for dynamically-linked executables but uses a different library (`-lssp_nonshared`) for statically-linked executables. As a workaround, we simply disable `-fstack-protector` in the statically-linked `lib{gmp,mpc,mpfr,isl}-stage3` derivations. These are not visible from outside of `stdenv`. --- pkgs/stdenv/linux/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 3670f8d8c2bc8..7cd523ce19a8b 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -308,7 +308,15 @@ in gcc-unwrapped = let makeStaticLibrariesAndMark = pkg: lib.makeOverridable (pkg.override { stdenv = self.makeStaticLibraries self.stdenv; }) - .overrideAttrs (a: { pname = "${a.pname}-stage3"; }); + .overrideAttrs (a: { + pname = "${a.pname}-stage3"; + } // lib.optionalAttrs self.stdenv.hostPlatform.isPower64 { + # On powerpc64, `-fstack-protector` requires `-lssp` for dynamically-linked + # executables and `-lssp_nonshared` for statically-linked executables. + # This means that you cannot link libaries built for static linkage (i.e. `*.a`) + # with `-fstack-protector` into a dynamically-linked executable. + hardeningDisable = (a.hardeningDisable or []) ++ [ "stackprotector" ]; + }); in super.gcc-unwrapped.override { # Link GCC statically against GMP etc. This makes sense because # these builds of the libraries are only used by GCC, so it