From 94fda3c5d0e9fc729f40ccbf63518d40eb4206af Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Fri, 8 May 2026 11:06:42 +1000 Subject: [PATCH] ghc: fix c++ linkage and c standard for < 9.10 on darwin --- pkgs/development/compilers/ghc/common-hadrian.nix | 5 +++++ pkgs/development/compilers/ghc/common-make-native-bignum.nix | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 2b66c97aa3ae..405d8eafc91c 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -696,6 +696,11 @@ stdenv.mkDerivation ( configureFlags = [ "--datadir=$doc/share/doc/ghc" ] + # ghc 9.10 and later use c17 by default. we use gnu17 on darwin for older + # ghc versions to match this and fix build issues with newer clang. + ++ lib.optionals (hostPlatform.isDarwin && lib.versionOlder version "9.10") [ + "CFLAGS=-std=gnu17" + ] ++ lib.optionals enableTerminfo [ "--with-curses-includes=${lib.getDev targetLibs.ncurses}/include" "--with-curses-libraries=${lib.getLib targetLibs.ncurses}/lib" diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix index 84df764cbcc3..66925f9613ac 100644 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ b/pkgs/development/compilers/ghc/common-make-native-bignum.nix @@ -501,6 +501,11 @@ stdenv.mkDerivation ( configureFlags = [ "--datadir=$doc/share/doc/ghc" ] + # ghc 9.10 and later use c17 by default. we use gnu17 on darwin for older + # ghc versions to match this and fix build issues with newer clang. + ++ lib.optionals (hostPlatform.isDarwin && lib.versionOlder version "9.10") [ + "CFLAGS=-std=gnu17" + ] ++ lib.optionals enableTerminfo [ "--with-curses-includes=${lib.getDev targetLibs.ncurses}/include" "--with-curses-libraries=${lib.getLib targetLibs.ncurses}/lib"