From f26c036320ae1a4a59fe6e3a8e588841abba2638 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 23 May 2026 13:00:09 +0000 Subject: [PATCH] diff, patch: add config.h and -I. to fix 'stdin does not exist' Both packages' source files include when HAVE_CONFIG_H is defined, but neither mkfile had -I. so cpp couldn't find config.h, causing the Plan9 'stdin does not exist' pipeline error. Add minimal config.h to each build directory with the HAVE_* flags appropriate for Plan9/APE (sigaction, fork, stat fields; no stack overflow recovery). Add -I. to CFLAGS so the build-dir config.h is found before any system headers. https://claude.ai/code/session_01WGAwvvTwDg2yknFkmZ3qzs --- sys/src/ape/cmd/diff/config.h | 32 ++++++++++++++++++++++++++++++++ sys/src/ape/cmd/diff/mkfile | 2 +- sys/src/ape/cmd/patch/config.h | 29 +++++++++++++++++++++++++++++ sys/src/ape/cmd/patch/mkfile | 2 +- 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 sys/src/ape/cmd/diff/config.h create mode 100644 sys/src/ape/cmd/patch/config.h diff --git a/sys/src/ape/cmd/diff/config.h b/sys/src/ape/cmd/diff/config.h new file mode 100644 index 000000000..0ac773eea --- /dev/null +++ b/sys/src/ape/cmd/diff/config.h @@ -0,0 +1,32 @@ +/* config.h for diffutils on Plan9/APE */ + +/* Package info */ +#define PACKAGE "diffutils" +#define PACKAGE_NAME "GNU diffutils" +#define PACKAGE_VERSION "3.10" +#define VERSION "3.10" + +/* Standard POSIX/APE capabilities */ +#define HAVE_FORK 1 +#define HAVE_WORKING_FORK 1 +#define HAVE_SIGACTION 1 +#define HAVE_SIGINTERRUPT 1 +#define HAVE_GETEUID 1 +#define HAVE_GETUID 1 + +/* struct stat fields present on Plan9/APE */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 +#define HAVE_STRUCT_STAT_ST_RDEV 1 +#undef HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC +#define HAVE_STRUCT_DIRENT_D_TYPE 1 +#define HAVE_TM_GMTOFF 1 + +/* c-stack / sigsegv: we don't have stack overflow recovery */ +#undef HAVE_GETRLIMIT +#undef HAVE_SIGALTSTACK +#undef HAVE_SIGSEGV_RECOVERY +#undef HAVE_STACKVMA +#undef HAVE_STACK_OVERFLOW_RECOVERY + +/* locale */ +#define LOCALEDIR "/sys/lib/ape/locale" diff --git a/sys/src/ape/cmd/diff/mkfile b/sys/src/ape/cmd/diff/mkfile index 9de79133e..cad67478b 100644 --- a/sys/src/ape/cmd/diff/mkfile +++ b/sys/src/ape/cmd/diff/mkfile @@ -45,7 +45,7 @@ RPLS= -Drpl_malloc=malloc -Drpl_free=free -Drpl_getopt_long=getopt_long\ -Drpl_optarg=optarg -Drpl_optind=optind CC=pcc -c -CFLAGS=-B -p -D_POSIX_SOURCE -DREGEX_MALLOC -I$DIFFSRC/src -I$DIFFSRC/lib \ +CFLAGS=-B -p -D_POSIX_SOURCE -DREGEX_MALLOC -I. -I$DIFFSRC/src -I$DIFFSRC/lib \ -DHAVE_CONFIG_H -DDIFF_PROGRAM="/bin/diff" $RPLS\ %.$O: $DIFFSRC/src/%.c diff --git a/sys/src/ape/cmd/patch/config.h b/sys/src/ape/cmd/patch/config.h new file mode 100644 index 000000000..086655850 --- /dev/null +++ b/sys/src/ape/cmd/patch/config.h @@ -0,0 +1,29 @@ +/* config.h for GNU patch on Plan9/APE */ + +/* Package info */ +#define PACKAGE "patch" +#define PACKAGE_NAME "GNU patch" +#define PACKAGE_VERSION "2.7.6" +#define VERSION "2.7.6" + +/* Standard POSIX/APE capabilities */ +#define HAVE_FORK 1 +#define HAVE_WORKING_FORK 1 +#define HAVE_SIGACTION 1 +#define HAVE_SIGFILLSET 1 +#define HAVE_GETEUID 1 +#define HAVE_GETUID 1 +#undef HAVE_SETMODE_DOS + +/* c-stack: no stack overflow recovery on Plan9 */ +#undef HAVE_GETRLIMIT +#undef HAVE_SIGALTSTACK +#undef HAVE_SIGSEGV_RECOVERY +#undef HAVE_STACKVMA +#undef HAVE_STACK_OVERFLOW_RECOVERY + +/* Enable merge mode (passed via -DENABLE_MERGE in CFLAGS too) */ +#define ENABLE_MERGE 1 + +/* locale */ +#define LOCALEDIR "/sys/lib/ape/locale" diff --git a/sys/src/ape/cmd/patch/mkfile b/sys/src/ape/cmd/patch/mkfile index 434ced71c..5db36e12e 100644 --- a/sys/src/ape/cmd/patch/mkfile +++ b/sys/src/ape/cmd/patch/mkfile @@ -30,7 +30,7 @@ BIN=$APEXPROOT/$objtype/bin/ape CC=pcc -c CFLAGS=-B -p -D_POSIX_SOURCE \ - -D_BSD_EXTENSION -I$PTCHSRC \ + -D_BSD_EXTENSION -I. -I$PTCHSRC \ -I$PTCHSRC/src -I$PTCHSRC/lib \ -DHAVE_CONFIG_H -DENABLE_MERGE\ -Ded_PROGRAM="/bin/ed"\