In <https://bugs.gnu.org/81846> Jacob Faibussowitsch reported problems with 
pipe2 when he built GNU Emacs with a macOS 27 development kit but ran on macOS 26. In 
looking for similar issues I found reports that dup3 is reportably linkable but 
(unlike pipe2) isn't declared in macOS 27. I came up with the attached Gnulib patch 
but did not install it as I am no macOS expert. Comments would be welcome.

As I understand it macOS 27 won't be released until tomorrow, so I suppose this 
is jumping the gun a bit.
From 8e96d6199fdfc14b1274f6bf1f67ffb5f958942d Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sun, 13 Sep 2026 00:13:44 -0700
Subject: [PATCH] dup3, pipe2: port to macOS 27

Problem reported by Jacob Faibussowitsch for GNU Emacs in:
https://bugs.gnu.org/81846
* m4/dup3.m4 (gl_FUNC_DUP3): Also work around macOS glitches;
reportedly needed for macOS 27.  Without this patch, dup3 links in
its Autoconf test, but is not declared and crashes when you run it.
* m4/pipe2.m4 (gl_FUNC_PIPE2): Also work around macOS glitches,
reportedly needed when building with macOS 27 development kit
but running on macOS 26.  Without this patch, pipe2 links in
its Autoconf test, but is not declared and crashes when you run it.
pipe2 differs from dup3 in that it is officially in macOS 27
whereas dup3 is not.
---
 ChangeLog   | 15 +++++++++++++++
 m4/dup3.m4  |  4 ++--
 m4/pipe2.m4 |  4 ++--
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3ae4a8d568..5c69cee81a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2026-09-13  Paul Eggert  <[email protected]>
+
+	dup3, pipe2: port to macOS 27
+	Problem reported by Jacob Faibussowitsch for GNU Emacs in:
+	https://bugs.gnu.org/81846
+	* m4/dup3.m4 (gl_FUNC_DUP3): Also work around macOS glitches;
+	reportedly needed for macOS 27.  Without this patch, dup3 links in
+	its Autoconf test, but is not declared and crashes when you run it.
+	* m4/pipe2.m4 (gl_FUNC_PIPE2): Also work around macOS glitches,
+	reportedly needed when building with macOS 27 development kit
+	but running on macOS 26.  Without this patch, pipe2 links in
+	its Autoconf test, but is not declared and crashes when you run it.
+	pipe2 differs from dup3 in that it is officially in macOS 27
+	whereas dup3 is not.
+
 2026-09-12  Paul Eggert  <[email protected]>
 
 	GCC 16.2 fixed counted_by bug (GCC bug 125072)
diff --git a/m4/dup3.m4 b/m4/dup3.m4
index c4b7d67ddd..e6474d6a32 100644
--- a/m4/dup3.m4
+++ b/m4/dup3.m4
@@ -1,5 +1,5 @@
 # dup3.m4
-# serial 7
+# serial 8
 dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,7 @@ AC_DEFUN([gl_FUNC_DUP3]
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_CHECK_FUNCS_ONCE([setdtablesize])
-  gl_CHECK_FUNCS_ANDROID([dup3], [[#include <unistd.h>]])
+  gl_CHECK_FUNCS_ANDROID_MACOS([dup3], [[#include <unistd.h>]])
   if test $ac_cv_func_dup3 != yes; then
     HAVE_DUP3=0
     case "$gl_cv_onwards_func_dup3" in
diff --git a/m4/pipe2.m4 b/m4/pipe2.m4
index 340020f56e..77f26b86d6 100644
--- a/m4/pipe2.m4
+++ b/m4/pipe2.m4
@@ -1,5 +1,5 @@
 # pipe2.m4
-# serial 4
+# serial 5
 dnl Copyright (C) 2009-2026 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_PIPE2]
   dnl Persuade glibc <unistd.h> to declare pipe2().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  gl_CHECK_FUNCS_ANDROID([pipe2], [[#include <unistd.h>]])
+  gl_CHECK_FUNCS_ANDROID_MACOS([pipe2], [[#include <unistd.h>]])
   if test $ac_cv_func_pipe2 != yes; then
     HAVE_PIPE2=0
     case "$gl_cv_onwards_func_pipe2" in
-- 
2.55.0

Reply via email to