On macOS / Darwin, the environ variable can be used directly in the
code of an executable, but cannot be used in the code of a shared
library (i.e. libgfortran.dylib), in this case.
In such cases, the function _NSGetEnviron should be called to get
the address of 'environ'.
libgfortran/ChangeLog:
* intrinsics/execute_command_line.c (environ): Use
_NSGetEnviron to get the environment pointer on Darwin.
#endif
#ifdef HAVE_POSIX_SPAWN
#include <spawn.h>
+# ifdef __APPLE__
+# include <crt_externs.h>
+# define environ (*_NSGetEnviron ())
+# else
extern char **environ;
+# endif
#endif
#if defined(HAVE_POSIX_SPAWN) || defined(HAVE_FORK)
#include <signal.h>