From 25b049670b978568f6fe7f32a0fbb8c9f5f30661 Mon Sep 17 00:00:00 2001 From: matthewcroughan Date: Sun, 25 Jan 2026 13:38:36 +0000 Subject: [PATCH] bash: use -std=c23 when cross compiling with clang CC and CC_FOR_BUILD do not support the same -std level. For example gnu -> llvm cross compilation, which is fixed by using a higher -std when cross compiling Co-authored-by: Alyssa Ross --- pkgs/shells/bash/5.nix | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pkgs/shells/bash/5.nix b/pkgs/shells/bash/5.nix index 86d3727cd94f..573c2f24ab86 100644 --- a/pkgs/shells/bash/5.nix +++ b/pkgs/shells/bash/5.nix @@ -75,7 +75,7 @@ lib.warnIf (withDocs != null) -DSSH_SOURCE_BASHRC '' # Bash's configure script assumes that CC and CC_FOR_BUILD have the - # same default -std=... flags. But at this moment, for FreeBSD, we + # same default -std=... flags. But at this moment, for cross llvm and FreeBSD, we # have CC_FOR_BUILD that defaults to c23, and a CC that default to # something older, perhaps c17. This breaks the build because of # bash's faulty assumptions. @@ -83,13 +83,11 @@ lib.warnIf (withDocs != null) # To fix, we simply force the standard to be the higher for CC to # match CC_FOR_BUILD. # - # Once FreeBSD is built with a newer version of Clang, this hack - # should be removed. - + - lib.optionalString (stdenv.hostPlatform.isFreeBSD && stdenv.hostPlatform != stdenv.buildPlatform) - '' - -std=c23 - ''; + # Once FreeBSD and other contexts are built with a newer version of clang, + # this hack should be removed. + + lib.optionalString stdenv.cc.isClang '' + -std=c23 + ''; patchFlags = [ "-p0" ];