scsh: fix the build against gcc-14

Without the change `scsh` build fails on `master` as
https://hydra.nixos.org/build/294813946:

    c/syscalls.c: In function 'sleep_until':
    c/syscalls.c:711:18: error: implicit declaration of function 'time' []
      711 |     time_t now = time(0);
          |                  ^~~~
This commit is contained in:
Sergei Trofimovich 2025-04-28 22:47:45 +01:00
parent 917ee0af83
commit 0140aa3cb7
3 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,33 @@
https://github.com/scheme/scsh/pull/50.patch
From edced224436fa70cd7d885fe65996b9c3cfd33d7 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Mon, 28 Apr 2025 22:40:31 +0100
Subject: [PATCH] c/syscalls.c: add missing `<time.h>` icnlude
Without the change the build fails for me as:
c/syscalls.c: In function 'sleep_until':
c/syscalls.c:711:18: error: implicit declaration of function 'time' [-Wimplicit-function-declaration]
711 | time_t now = time(0);
| ^~~~
c/syscalls.c:41:1: note: 'time' is defined in header '<time.h>'; this is probably fixable by adding '#include <time.h>'
40 | #include "syscalls.h"
+++ |+#include <time.h>
41 |
---
c/syscalls.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/c/syscalls.c b/c/syscalls.c
index fe11e81..2be25a8 100644
--- a/c/syscalls.c
+++ b/c/syscalls.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <time.h> /* for time() */
#include <sys/signal.h>
#include <signal.h>
#include <sys/types.h>

View file

@ -0,0 +1,31 @@
https://github.com/scheme/scsh/pull/51.patch
From b2934abb68d6adab448f24787192c047e46cf17c Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Mon, 28 Apr 2025 22:39:55 +0100
Subject: [PATCH] configure.ac: add detection of `pty.h`
Without the change the build on modern autoconf fails as:
c/tty.c: In function 'allocate_master':
c/tty.c:398:14: error: implicit declaration of function 'openpty'; did you mean 'openat'? [-Wimplicit-function-declaration]
398 | rc = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
| ^~~~~~~
| openat
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 99779dc..1cd8b22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ CPPFLAGS="$CPPFLAGS -I$S48DIR/include"
# Checks for libraries.
# Checks for header files.
-AC_CHECK_HEADERS([fcntl.h limits.h netdb.h sgtty.h stdlib.h string.h sys/ioctl.h sys/param.h sys/time.h termios.h unistd.h utime.h])
+AC_CHECK_HEADERS([fcntl.h limits.h netdb.h pty.h sgtty.h stdlib.h string.h sys/ioctl.h sys/param.h sys/time.h termios.h unistd.h utime.h])
dnl We need the scheme48.h headers, so bomb out if we can't find them.
AC_CHECK_HEADERS([scheme48.h], [],

View file

@ -19,6 +19,15 @@ stdenv.mkDerivation {
fetchSubmodules = true;
};
patches = [
# Fix the build against gcc-14:
# https://github.com/scheme/scsh/pull/50
./gcc-14-p1.patch
# Fix the build against gcc-14:
# https://github.com/scheme/scsh/pull/51
./gcc-14-p2.patch
];
nativeBuildInputs = [ autoreconfHook ];
buildInputs = [ scheme48 ];
configureFlags = [ "--with-scheme48=${scheme48}" ];