public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ.
@ 2014-12-22 12:02 Iain Sandoe
  2014-12-22 13:55 ` Arnaud Charlet
  2014-12-22 14:02 ` Eric Botcazou
  0 siblings, 2 replies; 5+ messages in thread
From: Iain Sandoe @ 2014-12-22 12:02 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches Patches

[-- Attachment #1: Type: text/plain, Size: 896 bytes --]

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.


[-- Attachment #2: pr64349-libada-environ.txt --]
[-- Type: text/plain, Size: 1000 bytes --]

From c336acb970b21589368948bc1bdc502546b568fc Mon Sep 17 00:00:00 2001
From: Iain Sandoe <iain@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


[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ.
  2014-12-22 12:02 [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ Iain Sandoe
@ 2014-12-22 13:55 ` Arnaud Charlet
  2014-12-22 14:14   ` Iain Sandoe
  2014-12-22 14:02 ` Eric Botcazou
  1 sibling, 1 reply; 5+ messages in thread
From: Arnaud Charlet @ 2014-12-22 13:55 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: Eric Botcazou, gcc-patches Patches, Tristan Gingold

Iain,

The change isn't quite right for iOS (aka arm-darwin), but the general idea
is the right one.

Tristan (cc:ed) has prepared a patch for this issue which works on both
MAC OS and darwin), which I'll merge soon. This will address this PR.

Arno

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ.
  2014-12-22 12:02 [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ Iain Sandoe
  2014-12-22 13:55 ` Arnaud Charlet
@ 2014-12-22 14:02 ` Eric Botcazou
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Botcazou @ 2014-12-22 14:02 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: gcc-patches, Tristan Gingold

> 	PR ada/64349
> 	* env.c (__gnat_environ): Use the _NSGetEnviron() interface to access
> 	the environment for Darwin.

OK if Tristan has no objections to the patch:
  https://gcc.gnu.org/ml/gcc-patches/2014-12/msg01753.html

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ.
  2014-12-22 13:55 ` Arnaud Charlet
@ 2014-12-22 14:14   ` Iain Sandoe
  2014-12-22 14:39     ` Arnaud Charlet
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2014-12-22 14:14 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: Eric Botcazou, gcc-patches Patches, Tristan Gingold

hi Arnaud,

On 22 Dec 2014, at 13:53, Arnaud Charlet wrote:

> The change isn't quite right for iOS (aka arm-darwin), but the general idea
> is the right one.

hmm.. I wasn't aware of a [> 4.2.1] arm-mach-o backend .. if that's a general issue, then I'll consider it for future patches.

> Tristan (cc:ed) has prepared a patch for this issue which works on both
> MAC OS and darwin), which I'll merge soon. This will address this PR.

Thanks, that's fine .. always better to be general.
Iain

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ.
  2014-12-22 14:14   ` Iain Sandoe
@ 2014-12-22 14:39     ` Arnaud Charlet
  0 siblings, 0 replies; 5+ messages in thread
From: Arnaud Charlet @ 2014-12-22 14:39 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: Eric Botcazou, gcc-patches Patches, Tristan Gingold

> hmm.. I wasn't aware of a [> 4.2.1] arm-mach-o backend .. if that's a general
> issue, then I'll consider it for future patches.

Yes please.

> > Tristan (cc:ed) has prepared a patch for this issue which works on both
> > MAC OS and darwin), which I'll merge soon. This will address this PR.
> 
> Thanks, that's fine .. always better to be general.

Great.

Arno

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-22 14:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-22 12:02 [Patch, libada] Fix PR64349 - make darwin use the correct interface to access _environ Iain Sandoe
2014-12-22 13:55 ` Arnaud Charlet
2014-12-22 14:14   ` Iain Sandoe
2014-12-22 14:39     ` Arnaud Charlet
2014-12-22 14:02 ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).