summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rts/IOManager.c2
-rw-r--r--rts/Linker.c2
-rw-r--r--rts/RtsSignals.h4
-rw-r--r--rts/RtsStartup.c2
-rw-r--r--rts/RtsSymbols.c2
-rw-r--r--rts/include/rts/Config.h25
-rw-r--r--rts/posix/Signals.h2
7 files changed, 32 insertions, 7 deletions
diff --git a/rts/IOManager.c b/rts/IOManager.c
index e9bf3fa70c..6606b82e06 100644
--- a/rts/IOManager.c
+++ b/rts/IOManager.c
@@ -21,7 +21,7 @@
#include "Capability.h"
#include "RtsFlags.h"
-#if !defined(mingw32_HOST_OS)
+#if !defined(mingw32_HOST_OS) && defined(HAVE_SIGNAL_H)
#include "posix/Signals.h"
#endif
diff --git a/rts/Linker.c b/rts/Linker.c
index 3121cc38df..ed60d14b62 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -36,7 +36,7 @@
#include "CheckUnload.h" // createOCSectionIndices
#include "ReportMemoryMap.h"
-#if !defined(mingw32_HOST_OS)
+#if !defined(mingw32_HOST_OS) && defined(HAVE_SIGNAL_H)
#include "posix/Signals.h"
#endif
diff --git a/rts/RtsSignals.h b/rts/RtsSignals.h
index b0add6727d..c143737474 100644
--- a/rts/RtsSignals.h
+++ b/rts/RtsSignals.h
@@ -8,7 +8,7 @@
#pragma once
-#if !defined(mingw32_HOST_OS)
+#if !defined(mingw32_HOST_OS) && defined(HAVE_SIGNAL_H)
#include "posix/Signals.h"
@@ -22,7 +22,7 @@
#endif
-#if RTS_USER_SIGNALS
+#if defined(RTS_USER_SIGNALS)
#include "BeginPrivate.h"
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
index 5b0cc9f712..46749163dc 100644
--- a/rts/RtsStartup.c
+++ b/rts/RtsStartup.c
@@ -659,7 +659,7 @@ shutdownHaskellAndExit(int n, int fastExit)
stg_exit(n);
}
-#if !defined(mingw32_HOST_OS)
+#if !defined(mingw32_HOST_OS) && defined(HAVE_SIGNAL_H)
static void exitBySignal(int sig) STG_NORETURN;
void
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 64545d2e09..96a8d1cdb3 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -18,7 +18,7 @@
#include "sm/NonMovingMark.h"
#include <stdbool.h>
-#if !defined(mingw32_HOST_OS)
+#if !defined(mingw32_HOST_OS) && defined(HAVE_SIGNAL_H)
#include "posix/Signals.h"
#endif
diff --git a/rts/include/rts/Config.h b/rts/include/rts/Config.h
index c5f34638e0..0f923205f5 100644
--- a/rts/include/rts/Config.h
+++ b/rts/include/rts/Config.h
@@ -44,7 +44,32 @@
Signals - supported on non-PAR versions of the runtime. See RtsSignals.h.
-------------------------------------------------------------------------- */
+/*
+Note [Lack of signals on wasm32-wasi]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In the wasm32-wasi spec, there is no process/thread model, no
+preemptive execution, and no posix-style asynchronous signals. See
+WASI ticket #166 for upstream discussion about signal handling.
+
+In wasi-libc, signal.h includes an #error pragma in the default
+setting that says: "wasm lacks signal support; to enable minimal
+signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with
+-lwasi-emulated-signal". It is possible to enable these flags when
+configuring wasm32-wasi-ghc, but it still makes little sense, since
+the emulation is really primitive and we might as well just stop
+pretending signals exist at all.
+
+Therefore, in the entire GHC tree, whenever we define functionality
+related to posix signals, we should add the CPP guards. When the
+target lacks signals, we can't set signal handlers at all, and raising
+a signal should degrade to exiting with the signal number as the exit
+code.
+*/
+
+#if defined(HAVE_SIGNAL_H)
#define RTS_USER_SIGNALS 1
+#endif
/* Profile spin locks */
diff --git a/rts/posix/Signals.h b/rts/posix/Signals.h
index 8203f28b34..f1941727b3 100644
--- a/rts/posix/Signals.h
+++ b/rts/posix/Signals.h
@@ -18,7 +18,7 @@
bool anyUserHandlers(void);
-#if !defined(THREADED_RTS)
+#if !defined(THREADED_RTS) && defined(RTS_USER_SIGNALS)
extern siginfo_t pending_handler_buf[];
extern siginfo_t *next_pending_handler;
#define signals_pending() (next_pending_handler != pending_handler_buf)