From: Iain Sandoe Date: Sat, 21 Nov 2020 09:06:03 +0000 (+0000) Subject: Darwin, libgfortran : Do not use environ directly from the library. X-Git-Tag: releases/gcc-10.3.0~492 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1d7709ec6845c97f667e6cb2d46ff2de8d5a5e0;p=thirdparty%2Fgcc.git 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. (cherry picked from commit a3454130760bf51b76495663c60ac6dffbe3d130) --- diff --git a/libgfortran/intrinsics/execute_command_line.c b/libgfortran/intrinsics/execute_command_line.c index 71d61a766ad4..6d7b8fc658e6 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 +# ifdef __APPLE__ +# include +# define environ (*_NSGetEnviron ()) +# else extern char **environ; +# endif #endif #if defined(HAVE_POSIX_SPAWN) || defined(HAVE_FORK) #include