public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Marcel Vollweiler <marcel@codesourcery.com>,
	 Jakub Jelinek <jakub@redhat.com>,
	Iain Sandoe <iain@sandoe.co.uk>
Subject: Re: [PATCH] OpenMP, libgomp: Environment variable syntax extension.
Date: Fri, 09 Sep 2022 22:50:19 +0200	[thread overview]
Message-ID: <yddleqsuvas.fsf@CeBiTec.Uni-Bielefeld.DE> (raw)
In-Reply-To: <Yxc0VBitp4C06F5F@tucnak> (Jakub Jelinek via Gcc-patches's message of "Tue, 6 Sep 2022 13:51:48 +0200")

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

Hi Jakub,

> On Wed, Aug 31, 2022 at 12:56:25PM +0200, Marcel Vollweiler wrote:
>> libgomp/ChangeLog:
[...]
>> 	(initialize_env): Extended to parse the new syntax of environment
>> 	variables.

this patch broke Darwin bootstrap:

Undefined symbols for architecture x86_64:
  "_environ", referenced from:
      _initialize_env in env.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[5]: *** [libgomp.la] Error 1

This is documented in environ(7):

     Shared libraries and bundles don't have direct access to environ, which
     is only available to the loader ld(1) when a complete program is being
     linked.  The environment routines can still be used, but if direct access
     to environ is needed, the _NSGetEnviron() routine, defined in
     <crt_externs.h>, can be used to retrieve the address of environ at run-
     time.

The following patch/hack, taken from
libgfortran/intrinsics/execute_command_line.c, allows the link to
succeed.  Bootstrap still running...

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ae.patch --]
[-- Type: text/x-patch, Size: 617 bytes --]

diff --git a/libgomp/env.c b/libgomp/env.c
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -54,6 +54,13 @@
 #include <errno.h>
 #include "thread-stacksize.h"
 
+#ifdef __APPLE__
+# include <crt_externs.h>
+# define environ (*_NSGetEnviron ())
+#else
+extern char **environ;
+#endif
+
 #ifndef HAVE_STRTOULL
 # define strtoull(ptr, eptr, base) strtoul (ptr, eptr, base)
 #endif
@@ -2033,7 +2040,6 @@ startswith (const char *str, const char 
 static void __attribute__((constructor))
 initialize_env (void)
 {
-  extern char **environ;
   char **env;
   int omp_var, dev_num = 0, dev_num_len = 0, i;
   bool ignore = false;

  reply	other threads:[~2022-09-09 20:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 15:22 Marcel Vollweiler
2022-01-18 16:10 ` [PATCH] " Marcel Vollweiler
2022-05-04 15:12   ` Jakub Jelinek
2022-05-04 15:52     ` Tobias Burnus
2022-06-10 13:59     ` Marcel Vollweiler
2022-06-30 11:40       ` Jakub Jelinek
2022-06-30 13:21         ` Jakub Jelinek
2022-06-30 17:13           ` Jakub Jelinek
2022-07-04 15:14         ` Jakub Jelinek
2022-07-25 13:38         ` Marcel Vollweiler
2022-08-02  7:52           ` Marcel Vollweiler
2022-08-22 15:35             ` Jakub Jelinek
2022-08-31 10:56               ` Marcel Vollweiler
2022-09-06 11:51                 ` Jakub Jelinek
2022-09-09 20:50                   ` Rainer Orth [this message]
2022-09-09 22:08                     ` Jakub Jelinek
2022-09-09 22:13                       ` Iain Sandoe
2022-09-09 22:17                         ` Jakub Jelinek
2022-09-10 13:17                           ` Iain Sandoe
2022-09-09 11:50                 ` [committed] libgomp: Fix up OMP_PROC_BIND handling [PR106894] Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yddleqsuvas.fsf@CeBiTec.Uni-Bielefeld.DE \
    --to=ro@cebitec.uni-bielefeld.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iain@sandoe.co.uk \
    --cc=jakub@redhat.com \
    --cc=marcel@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).