diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2020-11-21 09:06:03 +0000 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2020-11-21 09:06:49 +0000 |
commit | a3454130760bf51b76495663c60ac6dffbe3d130 (patch) | |
tree | 6f06e18749d5fbc839dce36eed3983286fec18a1 /libgfortran | |
parent | 93f1186f7d3419c7af692295bd509d7bfaf170a1 (diff) |
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.
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/intrinsics/execute_command_line.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c index 71d61a766ad..6d7b8fc658e 100644 --- a/libgfortran/intrinsics/execute_command_line.c +++ b/libgfortran/intrinsics/execute_command_line.c @@ -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> |