File 0474-hipe-Disable-if-non-glibc-libc-is-detected.patch of Package erlang
From 6941d3b666c41c3e4642bb5bc5acd8648d8fde07 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Thu, 29 Aug 2019 10:58:01 +0200
Subject: [PATCH 1/2] hipe: Disable if non-glibc libc is detected
We cannot guarantee that signals with not arrive on the
native stack without glibc, so we disable hipe.
---
erts/configure.in | 18 +++++++++++++++++-
erts/emulator/hipe/hipe_x86_signal.c | 14 ++------------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/erts/configure.in b/erts/configure.in
index 3a043c940d..1be53c24f2 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -2723,9 +2723,25 @@ if test X${enable_hipe} != Xno; then
AC_MSG_ERROR([HiPE needs mprotect() on $ARCH])
else
enable_hipe=no
- AC_MSG_WARN([Disable HiPE due to lack of mprotect()])
+ AC_MSG_WARN([HiPE disabled due to lack of mprotect()])
fi
fi
+ AC_MSG_CHECKING([for safe signal delivery])
+ AC_TRY_COMPILE([#include <signal.h>],
+ [#if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__)
+ #define __DARWIN__ 1
+ #endif
+
+ #if !(defined(__GLIBC__) || defined(__DARWIN__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__sun__))
+ /*
+ * Unknown libc -- assume musl, which does not allow safe signals
+ */
+ #error "HiPE does not work without a libc that can guarantee that sigaltstack works"
+ #endif /* !(__GLIBC__ || __DARWIN__ || __NetBSD__ || __FreeBSD__ || __sun__) */],
+ [AC_MSG_RESULT([yes])],
+ [enable_hipe=no
+ AC_MSG_RESULT([no, musl probably used. Need glibc to work properly])
+ AC_MSG_WARN([HiPE disabled due to lack of safe signal delivery])])
fi
dnl check to auto-enable hipe here...
diff --git a/erts/emulator/hipe/hipe_x86_signal.c b/erts/emulator/hipe/hipe_x86_signal.c
index d3b6933155..df8e1825bc 100644
--- a/erts/emulator/hipe/hipe_x86_signal.c
+++ b/erts/emulator/hipe/hipe_x86_signal.c
@@ -159,19 +159,9 @@
#if !(defined(__GLIBC__) || defined(__DARWIN__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__sun__))
/*
- * Unknown libc -- assume musl. Note: musl deliberately does not provide a musl-specific
- * feature test macro, so we cannot check for it.
- *
- * sigaction is a weak alias for __sigaction, which is a wrapper for __libc_sigaction.
- * There are libc-internal calls to __libc_sigaction which install handlers, so we must
- * override __libc_sigaction rather than __sigaction.
+ * Unknown libc -- assume musl, which does not allow safe signals
*/
-#define NEXT_SIGACTION "__libc_sigaction"
-#define LIBC_SIGACTION __libc_sigaction
-#define OVERRIDE_SIGACTION
-#ifndef _NSIG
-#define _NSIG NSIG
-#endif
+#error "HiPE does not work without a libc that can guarantee that sigaltstack works"
#endif /* !(__GLIBC__ || __DARWIN__ || __NetBSD__ || __FreeBSD__ || __sun__) */
#if defined(NEXT_SIGACTION)
--
2.16.4