summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-12-18 19:29:13 -0500
committerBen Gamari <ben@smart-cactus.org>2021-12-20 15:21:48 -0500
commitfc58715f20aef740ccadf473a23ce8f036c8d3b3 (patch)
tree0ab3e6933c195f65a7971638fd09886fa8e76fbd
parent47e8b67e6a4b0800e5869f7d851dddf1ba5d5e9d (diff)
downloadhaskell-fc58715f20aef740ccadf473a23ce8f036c8d3b3.tar.gz
rts: Consolidate RtsSymbols from libc
Previously (9ebda74ec5331911881d734b21fbb31c00a0a22f) `environ` was added to `RtsSymbols` to ensure that environment was correctly propagated when statically linking. However, this introduced #20577 since platforms are inconsistent in whether they provide a prototype for `environ`. I fixed this by providing a prototype but while doing so dropped symbol-table entry, presumably thinking that it was redundant due to the entry in the mingw-specific table. Here I reintroduce the symbol table entry for `environ` and move libc symbols shared by Windows and Linux into a new macro, `RTS_LIBC_SYMBOLS`, avoiding this potential confusion. (cherry picked from commit 7a0dcdceab882782cdbe5ce1f84269bb16909acb)
-rw-r--r--rts/RtsSymbols.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index f037ec52a1..7d42ff09e5 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -33,6 +33,11 @@
#include <elf.h> /* _DYNAMIC */
#endif
+/* We must provide a prototype for environ since depending upon the libc
+ * version it may or may not be provided by unistd.h. See #20577.
+ */
+extern char **environ;
+
/* -----------------------------------------------------------------------------
* Symbols to be inserted into the RTS symbol table.
*/
@@ -59,8 +64,6 @@
SymI_HasProto(signal_handlers) \
SymI_HasProto(stg_sig_install) \
SymI_HasProto(rtsTimerSignal) \
- SymI_HasProto(atexit) \
- SymI_NeedsDataProto(environ) \
SymI_NeedsDataProto(nocldstop)
#endif
@@ -1019,6 +1022,11 @@
#define RTS_LIBGCC_SYMBOLS
#endif
+// Symbols defined by libc
+#define RTS_LIBC_SYMBOLS \
+ SymI_HasProto_redirect(atexit, atexit, STRENGTH_STRONG) /* See Note [Strong symbols] */ \
+ SymI_HasProto(environ)
+
/* entirely bogus claims about types of these symbols */
#define SymI_NeedsProto(vvv) extern void vvv(void);
#define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
@@ -1045,6 +1053,7 @@ RTS_POSIX_ONLY_SYMBOLS
RTS_MINGW_ONLY_SYMBOLS
RTS_DARWIN_ONLY_SYMBOLS
RTS_OPENBSD_ONLY_SYMBOLS
+RTS_LIBC_SYMBOLS
RTS_LIBGCC_SYMBOLS
RTS_LIBFFI_SYMBOLS
#undef SymI_NeedsProto