unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#37483: [PATCH] macOS build error (aligned_alloc)
@ 2019-09-22 17:25 Mattias Engdegård
  2019-09-22 20:14 ` mituharu
  2019-09-23 20:02 ` Paul Eggert
  0 siblings, 2 replies; 7+ messages in thread
From: Mattias Engdegård @ 2019-09-22 17:25 UTC (permalink / raw)
  To: 37483

[-- Attachment #1: Type: text/plain, Size: 451 bytes --]

After upgrading the macOS system dev tools, building Emacs fails because aligned_alloc is present in the system headers and can be linked with but isn't actually in the dynamic library (macOS 10.14, Xcode 11).

This means that the configure check for that function needs to be strengthened a bit. Proposed patch attached; please say if it breaks on a different platform. I'm not the greatest fan of autoconf, and am likely to have made mistakes.


[-- Attachment #2: 0001-More-thorough-check-for-aligned_alloc-on-macOS.patch --]
[-- Type: application/octet-stream, Size: 1998 bytes --]

From 491b19f50014cf03a7cc9085568a10bbefed1812 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Sun, 22 Sep 2019 19:01:52 +0200
Subject: [PATCH] More thorough check for aligned_alloc on macOS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* configure.ac (HAVE_ALIGNED_ALLOC): Use a executing check for
aligned_alloc on macOS, since while that function is only available in
version ≥10.15, it may be present in the system headers and could be
linked with in earlier versions.
---
 configure.ac | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e822b0b7b0..dfc7bdb883 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4179,8 +4179,27 @@ AC_DEFUN
 cfmakeraw cfsetspeed __executable_start log2 prctl)
 LIBS=$OLD_LIBS
 
+if test "${opsys}" = darwin; then
+  dnl aligned_alloc is available in macOS 10.15 and later, but may be
+  dnl visible (but not functional) before that, and there is no
+  dnl telling without actually running a test.
+  AC_CACHE_CHECK([for aligned_alloc], [ac_cv_func_aligned_alloc],
+    [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
+                                    [[return !aligned_alloc (1, 1);]])],
+                   [ac_cv_func_aligned_alloc=yes],
+                   [ac_cv_func_aligned_alloc=no], [])])
+  if test $ac_cv_func_aligned_alloc = yes; then
+    AC_DEFINE([HAVE_ALIGNED_ALLOC], 1,
+              [Define to 1 if you have the 'aligned_alloc' function.])
+  fi
+else
+  AC_CHECK_FUNCS([aligned_alloc])
+fi
+
 dnl No need to check for posix_memalign if aligned_alloc works.
-AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
+if test "$ac_cv_func_aligned_alloc" != yes; then
+  AC_CHECK_FUNCS([posix_memalign])
+fi
 AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
 
 # Dump loading
-- 
2.21.0 (Apple Git-122)


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-09-24 11:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-22 17:25 bug#37483: [PATCH] macOS build error (aligned_alloc) Mattias Engdegård
2019-09-22 20:14 ` mituharu
2019-09-23  9:14   ` Mattias Engdegård
2019-09-23 18:37     ` Alan Third
2019-09-23 19:53       ` Mattias Engdegård
2019-09-23 20:02 ` Paul Eggert
2019-09-24 11:08   ` Mattias Engdegård

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).