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
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;