From ac6177eb1cef2fc410e9e6b16ef33d46d98b5917 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 25 Aug 2023 16:38:38 -0400 Subject: [PATCH] ghc: silence error on non-x86_64 with clang When the stdenv is using a newer clang, it fails on non-x86_64 platforms due to an unused `popcount16` function, which is treated as an error. This only affects GHC 9.4.x, which I assume is due to a quirk of its build system that GHC 8.8.x, 8.10.x, 9.2.x, and 9.6.x do not share. --- pkgs/development/compilers/ghc/9.4.2.nix | 4 ++++ pkgs/development/compilers/ghc/9.4.3.nix | 4 ++++ pkgs/development/compilers/ghc/9.4.4.nix | 4 ++++ pkgs/development/compilers/ghc/9.4.5.nix | 4 ++++ pkgs/development/compilers/ghc/9.4.6.nix | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/pkgs/development/compilers/ghc/9.4.2.nix b/pkgs/development/compilers/ghc/9.4.2.nix index afe78cbb87c06..5094c3c7c0540 100644 --- a/pkgs/development/compilers/ghc/9.4.2.nix +++ b/pkgs/development/compilers/ghc/9.4.2.nix @@ -288,6 +288,10 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Silence unused function warning due to `popcount16` being defined on all platforms but used only + # on x86_64. This results in an error due to `-Werror`. + env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && !targetPlatform.isx86_64) "-Wno-unused-function"; + # TODO(@Ericson2314): Always pass "--target" and always prefix. configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target"; diff --git a/pkgs/development/compilers/ghc/9.4.3.nix b/pkgs/development/compilers/ghc/9.4.3.nix index a2ae0cf400c7a..6aba2a7b0940d 100644 --- a/pkgs/development/compilers/ghc/9.4.3.nix +++ b/pkgs/development/compilers/ghc/9.4.3.nix @@ -288,6 +288,10 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Silence unused function warning due to `popcount16` being defined on all platforms but used only + # on x86_64. This results in an error due to `-Werror`. + env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && !targetPlatform.isx86_64) "-Wno-unused-function"; + # TODO(@Ericson2314): Always pass "--target" and always prefix. configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target"; diff --git a/pkgs/development/compilers/ghc/9.4.4.nix b/pkgs/development/compilers/ghc/9.4.4.nix index 13d01a3426377..d06bab66bde26 100644 --- a/pkgs/development/compilers/ghc/9.4.4.nix +++ b/pkgs/development/compilers/ghc/9.4.4.nix @@ -288,6 +288,10 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Silence unused function warning due to `popcount16` being defined on all platforms but used only + # on x86_64. This results in an error due to `-Werror`. + env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && !targetPlatform.isx86_64) "-Wno-unused-function"; + # TODO(@Ericson2314): Always pass "--target" and always prefix. configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target"; diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index da333a6138003..07809232b0b97 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -288,6 +288,10 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Silence unused function warning due to `popcount16` being defined on all platforms but used only + # on x86_64. This results in an error due to `-Werror`. + env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && !targetPlatform.isx86_64) "-Wno-unused-function"; + # TODO(@Ericson2314): Always pass "--target" and always prefix. configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target"; diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 95cb31a411ff1..5b264706c234a 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -284,6 +284,10 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Silence unused function warning due to `popcount16` being defined on all platforms but used only + # on x86_64. This results in an error due to `-Werror`. + env.NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.cc.isClang && !targetPlatform.isx86_64) "-Wno-unused-function"; + # TODO(@Ericson2314): Always pass "--target" and always prefix. configurePlatforms = [ "build" "host" ] ++ lib.optional (targetPlatform != hostPlatform) "target";