summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2019-10-21 03:14:31 +0200
committerNiklas Hambüchen <mail@nh2.me>2019-10-30 13:29:53 +0100
commit08ec575c93c00d1751e3a5df55b438073393aa69 (patch)
tree73f56c5b68218f861967fd04b7742e843f54fdcf
parentc7e1fde9dc0fa17fb09301f8db352bec7e54fac0 (diff)
downloadnixpkgs-08ec575c93c00d1751e3a5df55b438073393aa69.tar
nixpkgs-08ec575c93c00d1751e3a5df55b438073393aa69.tar.gz
nixpkgs-08ec575c93c00d1751e3a5df55b438073393aa69.tar.bz2
nixpkgs-08ec575c93c00d1751e3a5df55b438073393aa69.tar.lz
nixpkgs-08ec575c93c00d1751e3a5df55b438073393aa69.tar.xz
nixpkgs-08ec575c93c00d1751e3a5df55b438073393aa69.tar.zst
nixpkgs-08ec575c93c00d1751e3a5df55b438073393aa69.zip
glibc: Fix building with musl on GCC 8.
GCC 8 introduced new warnings that were picked up by -Werror;
this commit makes them non-errors until fixed upstream.

See

* https://github.com/NixOS/nixpkgs/pull/68244#issuecomment-544307798
* https://github.com/nh2/static-haskell-nix/issues/56

This commit takes care to not change the derivation for non-musl builds.
-rw-r--r--pkgs/development/libraries/glibc/common.nix2
-rw-r--r--pkgs/development/libraries/glibc/default.nix16
2 files changed, 16 insertions, 2 deletions
diff --git a/pkgs/development/libraries/glibc/common.nix b/pkgs/development/libraries/glibc/common.nix
index 8e8e445f017..5a9f18f167b 100644
--- a/pkgs/development/libraries/glibc/common.nix
+++ b/pkgs/development/libraries/glibc/common.nix
@@ -98,7 +98,7 @@ stdenv.mkDerivation ({
     ++ lib.optional stdenv.buildPlatform.isDarwin ./darwin-cross-build.patch
 
     # Remove after upgrading to glibc 2.28+
-    ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) (fetchpatch {
+    ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform || stdenv.hostPlatform.isMusl) (fetchpatch {
       url = "https://sourceware.org/git/?p=glibc.git;a=patch;h=780684eb04298977bc411ebca1eadeeba4877833";
       name = "correct-pwent-parsing-issue-and-resulting-build.patch";
       sha256 = "08fja894vzaj8phwfhsfik6jj2pbji7kypy3q8pgxvsd508zdv1q";
diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix
index eda71af5978..50b359da96c 100644
--- a/pkgs/development/libraries/glibc/default.nix
+++ b/pkgs/development/libraries/glibc/default.nix
@@ -40,7 +40,21 @@ callPackage ./common.nix { inherit stdenv; } {
     #      limit rebuilds by only disabling pie w/musl
       ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "pie";
 
-    NIX_CFLAGS_COMPILE = if withGd then "-Wno-error=stringop-truncation" else null;
+    NIX_CFLAGS_COMPILE =
+      if !stdenv.hostPlatform.isMusl
+        # TODO: This (returning a string or `null`, instead of a list) is to
+        #       not trigger a mass rebuild due to the introduction of the
+        #       musl-specific flags below.
+        #       At next change to non-musl glibc builds, remove this `then`
+        #       and the above condition, instead keeping only the `else` below.
+        then (if withGd then "-Wno-error=stringop-truncation" else null)
+        else
+          builtins.concatLists [
+            (stdenv.lib.optional withGd "-Wno-error=stringop-truncation")
+            # Fix -Werror build failure when building glibc with musl with GCC >= 8, see:
+            # https://github.com/NixOS/nixpkgs/pull/68244#issuecomment-544307798
+            (stdenv.lib.optional stdenv.hostPlatform.isMusl "-Wno-error=attribute-alias")
+          ];
 
     # When building glibc from bootstrap-tools, we need libgcc_s at RPATH for
     # any program we run, because the gcc will have been placed at a new