[MacPorts] #70267: libgpg-error @1.50 does not build: Undefined symbols: "_environ"

MacPorts noreply at macports.org
Fri Jun 21 06:43:07 UTC 2024


#70267: libgpg-error @1.50 does not build: Undefined symbols: "_environ"
-------------------------+-------------------------------------------------
  Reporter:              |      Owner:  ryandesign
  barracuda156           |
      Type:  defect      |     Status:  accepted
  Priority:  Normal      |  Milestone:
 Component:  ports       |    Version:  2.9.3
Resolution:              |   Keywords:  legacy-os tiger leopard snowleopard
      Port:  libgpg-     |  lion
  error                  |
-------------------------+-------------------------------------------------
Changes (by ryandesign):

 * owner:  Schamschula => ryandesign
 * cc: Schamschula (added)
 * status:  assigned => accepted
 * keywords:   => legacy-os tiger leopard snowleopard lion


Old description:

> The patch used in https://github.com/macports/macports-
> ports/commit/72a1a9efe3711c6dcfeb8bedc96fe837ef0fe7dd fails to work:
>
> {{{
> Undefined symbols:
>   "_environ", referenced from:
>       _environ$non_lazy_ptr in libgpg_error_la-spawn-posix.o
> ld: symbol(s) not found
> }}}
>
> Unfortunately, replacing it with what is usually correct:
>
> {{{
> #ifdef __APPLE__
> # include <crt_externs.h>
> # define environ (*_NSGetEnviron())
> #else
>   extern char **environ;
> #endif
> }}}
>
> does not work here:
>
> {{{
> libtool: compile:  /usr/bin/gcc-4.2 -std=gnu99 -DHAVE_CONFIG_H -I. -I..
> -DLOCALEDIR=\"/opt/local/share/locale\" -I/opt/local/include -pipe -Os
> -arch ppc -Wall -Wpointer-arith -MT libgpg_error_la-version.lo -MD -MP
> -MF .deps/libgpg_error_la-version.Tpo -c version.c  -fno-common -DPIC -o
> .libs/libgpg_error_la-version.o
> spawn-posix.c:72: error: field '_NSGetEnviron' declared as a function
> spawn-posix.c: In function 'my_exec':
> spawn-posix.c:350: error: expected identifier before '(' token
> spawn-posix.c:351: error: expected identifier before '(' token
> spawn-posix.c: In function '_gpgrt_spawn_actions_set_environ':
> spawn-posix.c:456: error: expected identifier before '(' token
> libtool: compile:  /usr/bin/gcc-4.2 -std=gnu99 -DHAVE_CONFIG_H -I. -I..
> -DLOCALEDIR=\"/opt/local/share/locale\" -I/opt/local/include -pipe -Os
> -arch ppc -Wall -Wpointer-arith -MT libgpg_error_la-init.lo -MD -MP -MF
> .deps/libgpg_error_la-init.Tpo -c init.c  -fno-common -DPIC -o .libs
> /libgpg_error_la-init.o
> make[3]: *** [libgpg_error_la-spawn-posix.lo] Error 1
> make[3]: *** Waiting for unfinished jobs....
> }}}

New description:

 The patch used in [72a1a9efe3711c6dcfeb8bedc96fe837ef0fe7dd/macports-
 ports] fails to work:

 {{{
 Undefined symbols:
   "_environ", referenced from:
       _environ$non_lazy_ptr in libgpg_error_la-spawn-posix.o
 ld: symbol(s) not found
 }}}

 Unfortunately, replacing it with what is usually correct:

 {{{
 #ifdef __APPLE__
 # include <crt_externs.h>
 # define environ (*_NSGetEnviron())
 #else
   extern char **environ;
 #endif
 }}}

 does not work here:

 {{{
 libtool: compile:  /usr/bin/gcc-4.2 -std=gnu99 -DHAVE_CONFIG_H -I. -I..
 -DLOCALEDIR=\"/opt/local/share/locale\" -I/opt/local/include -pipe -Os
 -arch ppc -Wall -Wpointer-arith -MT libgpg_error_la-version.lo -MD -MP -MF
 .deps/libgpg_error_la-version.Tpo -c version.c  -fno-common -DPIC -o .libs
 /libgpg_error_la-version.o
 spawn-posix.c:72: error: field '_NSGetEnviron' declared as a function
 spawn-posix.c: In function 'my_exec':
 spawn-posix.c:350: error: expected identifier before '(' token
 spawn-posix.c:351: error: expected identifier before '(' token
 spawn-posix.c: In function '_gpgrt_spawn_actions_set_environ':
 spawn-posix.c:456: error: expected identifier before '(' token
 libtool: compile:  /usr/bin/gcc-4.2 -std=gnu99 -DHAVE_CONFIG_H -I. -I..
 -DLOCALEDIR=\"/opt/local/share/locale\" -I/opt/local/include -pipe -Os
 -arch ppc -Wall -Wpointer-arith -MT libgpg_error_la-init.lo -MD -MP -MF
 .deps/libgpg_error_la-init.Tpo -c init.c  -fno-common -DPIC -o .libs
 /libgpg_error_la-init.o
 make[3]: *** [libgpg_error_la-spawn-posix.lo] Error 1
 make[3]: *** Waiting for unfinished jobs....
 }}}

--

Comment:

 You are building with gcc for ppc so I assume this is on Mac OS X 10.6.
 The patch works fine on OS X 10.8 and later per buildbot results. You
 cannot expect everyone to write code compatible with ancient systems. For
 10.7 and earlier, `_NSGetEnviron()` needs to be called. There are patches
 in the sudo, hugs98, newlisp, and other ports that show how to do this.

-- 
Ticket URL: <https://trac.macports.org/ticket/70267#comment:2>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list