--- packages/base/include/HsBase.h.orig	2006-09-21 00:28:37.000000000 +0200
+++ packages/base/include/HsBase.h	2009-12-13 12:52:32.000000000 +0100
@@ -764,7 +764,13 @@
 
 /* ToDo: write a feature test that doesn't assume 'environ' to
  *    be in scope at link-time. */
-extern char** environ;
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
+ extern char **environ;
+#endif
+
 INLINE char **__hscore_environ() { return environ; }
 
 /* lossless conversions between pointers and integral types */


--- packages/unix/include/HsUnix.h.orig	2006-09-21 04:14:16.000000000 +0545
+++ packages/unix/include/HsUnix.h	2022-08-08 00:34:33.000000000 +0545
@@ -80,7 +80,12 @@
 #include <signal.h>
 #endif
 
-extern char **environ;
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
+ extern char **environ;
+#endif
 
 #ifndef INLINE
 # if defined(__GNUC__)
