From 68d0dfd07b54692bc3172d12fe153671f69ff946 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sun, 8 Oct 2023 18:06:27 -0400 Subject: [PATCH] expect: fix build with clang 16 * Use patches from upstream issue tracker that fix most compilation issues and the configure script; and * Modify `exp_win.c` and `pty_termios.c` to build properly on Darwin. --- pkgs/tools/misc/expect/default.nix | 15 +++++++-- .../misc/expect/fix-darwin-clang16.patch | 31 +++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 pkgs/tools/misc/expect/fix-darwin-clang16.patch diff --git a/pkgs/tools/misc/expect/default.nix b/pkgs/tools/misc/expect/default.nix index 19ab5158a65b6..e2457ad63e137 100644 --- a/pkgs/tools/misc/expect/default.nix +++ b/pkgs/tools/misc/expect/default.nix @@ -6,18 +6,29 @@ tcl.mkTclDerivation rec { src = fetchurl { url = "mirror://sourceforge/expect/Expect/${version}/expect${version}.tar.gz"; - sha256 = "0d1cp5hggjl93xwc8h1y6adbnrvpkk0ywkd00inz9ndxn21xm9s9"; + hash = "sha256-Safag7C92fRtBKBN7sGcd2e7mjI+QMR4H4nK92C5LDQ="; }; patches = [ (fetchpatch { url = "https://raw.githubusercontent.com/buildroot/buildroot/c05e6aa361a4049eabd8b21eb64a34899ef83fc7/package/expect/0001-enable-cross-compilation.patch"; - sha256 = "1jwx2l1slidvcpahxbyqs942l81jd62rzbxliyd9lwysk38c8b6b"; + hash = "sha256-yyzE0Jjac5qaj7Svn4VpMiAqSNLYrw7VZbtFqgMVncs="; }) (substituteAll { src = ./fix-cross-compilation.patch; tcl = "${buildPackages.tcl}/bin/tclsh"; }) + # The following patches fix compilation with clang 15+ + (fetchpatch { + url = "https://sourceforge.net/p/expect/patches/24/attachment/0001-Add-prototype-to-function-definitions.patch"; + hash = "sha256-X2Vv6VVM3KjmBHo2ukVWe5YTVXRmqe//Kw2kr73OpZs="; + }) + (fetchpatch { + url = "https://sourceforge.net/p/expect/patches/_discuss/thread/b813ca9895/6759/attachment/expect-configure-c99.patch"; + hash = "sha256-PxQQ9roWgVXUoCMxkXEgu+it26ES/JuzHF6oML/nk54="; + }) + # Include `sys/ioctl.h` and `util.h` on Darwin, which are required for `ioctl` and `openpty`. + ./fix-darwin-clang16.patch ]; postPatch = '' diff --git a/pkgs/tools/misc/expect/fix-darwin-clang16.patch b/pkgs/tools/misc/expect/fix-darwin-clang16.patch new file mode 100644 index 0000000000000..9454769c99c8f --- /dev/null +++ b/pkgs/tools/misc/expect/fix-darwin-clang16.patch @@ -0,0 +1,31 @@ +diff -ur a/exp_win.c b/exp_win.c +--- a/exp_win.c 2018-02-02 14:15:52.000000000 -0500 ++++ b/exp_win.c 2023-10-10 07:47:33.082690432 -0400 +@@ -39,7 +39,8 @@ + /* Sigh. On AIX 2.3, termios.h exists but does not define TIOCGWINSZ */ + /* Instead, it has to come from ioctl.h. However, As I said above, this */ + /* can't be cavalierly included on all machines, even when it exists. */ +-#if defined(HAVE_TERMIOS) && !defined(HAVE_TIOCGWINSZ_IN_TERMIOS_H) ++/* Darwin also has termios.h, but it requires ioctl.h for `ioctl`. */ ++#if defined(HAVE_TERMIOS) && (defined(__APPLE__) || !defined(HAVE_TIOCGWINSZ_IN_TERMIOS_H)) + # include + #endif + +diff -ur d/pty_termios.c c/pty_termios.c +--- d/pty_termios.c 2023-10-10 07:59:23.244452442 -0400 ++++ c/pty_termios.c 2023-10-10 08:00:35.303231582 -0400 +@@ -7,7 +7,13 @@ + + */ + +-#include /* openpty */ ++/* openpty */ ++#ifdef __APPLE__ ++#include ++#else /* pty.h is Linux-specific */ ++#include ++#endif ++ + #include + #include +