Hi Eric, For the main executable, it is permitted for Darwin to access _environ directly. For shared libraries, it is not (one is supposed use _NSGetEnviron()).
At present, the more recent darwin ports are "getting away" with the omission because they have a blanket setting of -Wl,-undefined,dynamic_lookup which means that the symbol can be satisfied from the executable at dynamic load time. However, the change is applicable generally (not just to the older ports mentioned in the PR). The attached patch fixes this properly (we can bike-shed over whether __APPLE__ or __MACH__ is a better guard, I don't have an axe to grind particularly). This is one of two remaining bootstrap blockers across the Darwin patch. OK for trunk? Iain gcc/ada: PR ada/64349 * env.c (__gnat_environ): Use the _NSGetEnviron() interface to access the environment for Darwin.
From c336acb970b21589368948bc1bdc502546b568fc Mon Sep 17 00:00:00 2001 From: Iain Sandoe <i...@codesourcery.com> Date: Mon, 22 Dec 2014 10:47:40 +0000 Subject: [PATCH] Arrange for libada to use the approved interface to obtain _environ on Darwin --- gcc/ada/env.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/ada/env.c b/gcc/ada/env.c index 9530813..ff602b2 100644 --- a/gcc/ada/env.c +++ b/gcc/ada/env.c @@ -198,6 +198,11 @@ __gnat_setenv (char *name, char *value) #endif } +#ifdef __APPLE__ +#include <crt_externs.h> +#define environ (*_NSGetEnviron ()) +#endif + char ** __gnat_environ (void) { @@ -209,10 +214,10 @@ __gnat_environ (void) #elif defined (sun) extern char **_environ; return _environ; -#elif ! (defined (__vxworks)) - extern char **environ; +#elif defined (__vxworks) || defined (__APPLE__) return environ; #else + extern char **environ; return environ; #endif } -- 1.8.4.2