From 227075c83ec9bf3311f86da7c7c1b376c01fbccd Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 19 May 2024 17:36:09 -0400 Subject: [PATCH] gettext: implement clang 18 on Darwin workaround --- .../development/libraries/gettext/default.nix | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index bd3070d82efe..c5ca4a932fe6 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -47,10 +47,25 @@ stdenv.mkDerivation rec { ]; postPatch = '' - substituteAllInPlace gettext-runtime/src/gettext.sh.in - substituteInPlace gettext-tools/projects/KDE/trigger --replace "/bin/pwd" pwd - substituteInPlace gettext-tools/projects/GNOME/trigger --replace "/bin/pwd" pwd - substituteInPlace gettext-tools/src/project-id --replace "/bin/pwd" pwd + # Older versions of gettext come with a copy of `extern-inline.m4` that is not compatible with clang 18. + # When a project uses gettext + autoreconfPhase, autoreconfPhase will invoke `autopoint -f`, which will + # replace whatever (probably compatible) version of `extern-inline.m4` with one that probalby won’t work + # because `autopoint` will copy the autoconf macros from the project’s required version of gettext. + # Fixing this requires replacing all the older copies of the problematic file with a new one. + # + # This is ugly, but it avoids requiring workarounds in every package using gettext and autoreconfPhase. + declare -a oldFiles=($(tar tf gettext-tools/misc/archive.dir.tar | grep '^gettext-0\.[19].*/extern-inline.m4')) + oldFilesDir=$(mktemp -d) + for oldFile in "''${oldFiles[@]}"; do + mkdir -p "$oldFilesDir/$(dirname "$oldFile")" + cp gettext-tools/gnulib-m4/extern-inline.m4 "$oldFilesDir/$oldFile" + done + tar uf gettext-tools/misc/archive.dir.tar -C "$oldFilesDir" "''${oldFiles[@]}" + + substituteAllInPlace gettext-runtime/src/gettext.sh.in + substituteInPlace gettext-tools/projects/KDE/trigger --replace "/bin/pwd" pwd + substituteInPlace gettext-tools/projects/GNOME/trigger --replace "/bin/pwd" pwd + substituteInPlace gettext-tools/src/project-id --replace "/bin/pwd" pwd '' + lib.optionalString stdenv.hostPlatform.isCygwin '' sed -i -e "s/\(cldr_plurals_LDADD = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in sed -i -e "s/\(libgettextsrc_la_LDFLAGS = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in