Darwin, libgfortran : Do not use environ directly from the library.

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.
This commit is contained in:
Iain Sandoe 2020-11-21 09:06:03 +00:00
parent 93f1186f7d
commit a345413076
1 changed files with 5 additions and 0 deletions

View File

@ -34,7 +34,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#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>