From 247cd336af9b9367697e0b5a7a82c5227f986a97 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 23 Dec 2021 11:53:25 -0500 Subject: rts: Only declare environ when necessary Previously we would unconditionally provide a declaration for `environ`, even if `` already provided one. This would result in `-Werror` builds failing on some platforms. Also `#include ` to ensure that the declaration is visible. Fixes #20861. --- rts/RtsSymbols.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'rts/RtsSymbols.c') diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c index 7d7b8422c2..f76573e3ae 100644 --- a/rts/RtsSymbols.c +++ b/rts/RtsSymbols.c @@ -34,10 +34,17 @@ #include /* _DYNAMIC */ #endif +#if defined(HAVE_UNISTD_H) +#include /* environ */ +#endif + +#if !HAVE_DECL_ENVIRON /* 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. + * version it may or may not be provided by unistd.h. See #20577 and #20861. */ extern char **environ; +#endif + /* ----------------------------------------------------------------------------- * Symbols to be inserted into the RTS symbol table. -- cgit v1.2.1