As discussed before, shared libraries on Mac OS X can not reference the environ variable directly, where applications can. This is a show stopper on Mac OS X, because of the internals of autoconf and because the environ variable is referenced in gpc's runtime library. To solve this problem, I apply the following patch:
--- gcc/p/rts/rts.c.orig Wed Apr 16 01:58:46 2003 +++ gcc/p/rts/rts.c Fri Jun 6 11:35:50 2003 @@ -195,7 +195,15 @@ extern int errno; #endif
-#if defined (HAVE_ENVIRON) || defined (environ) +/* needed by Mac OS X */ +#if defined (__MACH__) && defined(__APPLE__) +#include <crt_externs.h> +#endif + +/* on Mac OS X the environ variable can not be referenced in shared libraries */ +#if defined (__MACH__) && defined(__APPLE__) +#define environ (*_NSGetEnviron()) +#elif defined (HAVE_ENVIRON) || defined (environ) #if !defined (environ) && !defined (ENVIRON_DECLARED) extern char **environ; #endif
I would be grateful if this patch is merged with gpc's sources.
Regards,
Adriaan van Os
Adriaan van Os wrote:
As discussed before, shared libraries on Mac OS X can not reference the environ variable directly, where applications can. This is a show stopper on Mac OS X, because of the internals of autoconf and because the environ variable is referenced in gpc's runtime library. To solve this problem, I apply the following patch:
--- gcc/p/rts/rts.c.orig Wed Apr 16 01:58:46 2003 +++ gcc/p/rts/rts.c Fri Jun 6 11:35:50 2003 @@ -195,7 +195,15 @@ extern int errno; #endif
-#if defined (HAVE_ENVIRON) || defined (environ) +/* needed by Mac OS X */ +#if defined (__MACH__) && defined(__APPLE__) +#include <crt_externs.h> +#endif
+/* on Mac OS X the environ variable can not be referenced in shared libraries */ +#if defined (__MACH__) && defined(__APPLE__) +#define environ (*_NSGetEnviron()) +#elif defined (HAVE_ENVIRON) || defined (environ) #if !defined (environ) && !defined (ENVIRON_DECLARED) extern char **environ; #endif
I would be grateful if this patch is merged with gpc's sources.
I'd rather not. The idea is to check for features in autoconf, *not* to add system-conditionals.
AFAICS, checking for <crt_externs.h> and _NSGetEnviron() and using them, if present, in favour of environ should work, shouldn't it?
Frank
Frank Heckenbach wrote:
Adriaan van Os wrote:
As discussed before, shared libraries on Mac OS X can not reference the environ variable directly, where applications can. This is a show stopper on Mac OS X, because of the internals of autoconf and because the environ variable is referenced in gpc's runtime library. To solve this problem, I apply the following patch:
--- gcc/p/rts/rts.c.orig Wed Apr 16 01:58:46 2003 +++ gcc/p/rts/rts.c Fri Jun 6 11:35:50 2003 @@ -195,7 +195,15 @@ extern int errno; #endif
-#if defined (HAVE_ENVIRON) || defined (environ) +/* needed by Mac OS X */ +#if defined (__MACH__) && defined(__APPLE__) +#include <crt_externs.h> +#endif
+/* on Mac OS X the environ variable can not be referenced in shared libraries */ +#if defined (__MACH__) && defined(__APPLE__) +#define environ (*_NSGetEnviron()) +#elif defined (HAVE_ENVIRON) || defined (environ) #if !defined (environ) && !defined (ENVIRON_DECLARED) extern char **environ; #endif
I would be grateful if this patch is merged with gpc's sources.
I'd rather not. The idea is to check for features in autoconf, *not* to add system-conditionals.
AFAICS, checking for <crt_externs.h> and _NSGetEnviron() and using them, if present, in favour of environ should work, shouldn't it?
Yes, see e.g. http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02341.html and http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02387.html
Regards,
Adriaan van Os
Adriaan van Os wrote:
AFAICS, checking for <crt_externs.h> and _NSGetEnviron() and using them, if present, in favour of environ should work, shouldn't it?
Yes, see e.g. http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02341.html
Applying.
Frank
Frank Heckenbach wrote:
Adriaan van Os wrote:
AFAICS, checking for <crt_externs.h> and _NSGetEnviron() and using them, if present, in favour of environ should work, shouldn't it?
Yes, see e.g. http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02341.html
Applying.
OK, thanks
Regards,
Adriaan van Os