Opened 3 months ago

Last modified 2 months ago

#72309 assigned defect

oscomore build error: Undefined symbols: "_environ"

Reported by: barracuda156 Owned by: michaelld (Michael Dickens)
Priority: Normal Milestone:
Component: ports Version: 2.10.5
Keywords: Cc:
Port: osmocore

Description

/bin/sh ../libtool  --tag=CC   --mode=link /opt/local/bin/gcc-mp-14 -Wall  -pthread  -pipe -Os -std=gnu11 -I/opt/local/include/LegacySupport -arch ppc -DBUILDING_LIBOSMOCORE -Wall -version-info 15:0:3 -no-undefined -Wl,-headerpad_max_install_names -std=gnu11 -lMacportsLegacySupport -arch ppc -o libosmocore.la -rpath /opt/local/lib context.lo timer.lo timer_gettimeofday.lo timer_clockgettime.lo select.lo signal.lo msgb.lo bits.lo bitvec.lo bitcomp.lo counter.lo fsm.lo write_queue.lo utils.lo socket.lo logging.lo logging_syslog.lo logging_gsmtap.lo rate_ctr.lo gsmtap_util.lo crc16.lo panic.lo backtrace.lo conv.lo application.lo rbtree.lo strrb.lo loggingrb.lo crc8gen.lo crc16gen.lo crc32gen.lo crc64gen.lo macaddr.lo stat_item.lo stats.lo stats_statsd.lo prim.lo conv_acc.lo conv_acc_generic.lo sercomm.lo prbs.lo isdnhdlc.lo tdef.lo sockaddr_str.lo use_count.lo exec.lo   plugin.lo msgfile.lo serial.lo  -L/opt/local/lib -Wl,-rpath,/opt/local/lib -ltalloc     
libtool: link: /opt/local/bin/gcc-mp-14 -dynamiclib  -o .libs/libosmocore.12.dylib  .libs/context.o .libs/timer.o .libs/timer_gettimeofday.o .libs/timer_clockgettime.o .libs/select.o .libs/signal.o .libs/msgb.o .libs/bits.o .libs/bitvec.o .libs/bitcomp.o .libs/counter.o .libs/fsm.o .libs/write_queue.o .libs/utils.o .libs/socket.o .libs/logging.o .libs/logging_syslog.o .libs/logging_gsmtap.o .libs/rate_ctr.o .libs/gsmtap_util.o .libs/crc16.o .libs/panic.o .libs/backtrace.o .libs/conv.o .libs/application.o .libs/rbtree.o .libs/strrb.o .libs/loggingrb.o .libs/crc8gen.o .libs/crc16gen.o .libs/crc32gen.o .libs/crc64gen.o .libs/macaddr.o .libs/stat_item.o .libs/stats.o .libs/stats_statsd.o .libs/prim.o .libs/conv_acc.o .libs/conv_acc_generic.o .libs/sercomm.o .libs/prbs.o .libs/isdnhdlc.o .libs/tdef.o .libs/sockaddr_str.o .libs/use_count.o .libs/exec.o .libs/plugin.o .libs/msgfile.o .libs/serial.o   -lMacportsLegacySupport -L/opt/local/lib -ltalloc  -Os -arch ppc -Wl,-headerpad_max_install_names -arch ppc -Wl,-rpath -Wl,/opt/local/lib   -pthread -install_name  /opt/local/lib/libosmocore.12.dylib -compatibility_version 16 -current_version 16.0 -Wl,-single_module
Undefined symbols:
  "_environ", referenced from:
      _environ$non_lazy_ptr in exec.o
     (maybe you meant: _osmo_environment_append, _environ$non_lazy_ptr , _osmo_environment_filter , _osmo_environment_whitelist )
ld: symbol(s) not found
collect2: error: ld returned 1 exit status
make[3]: *** [libosmocore.la] Error 1

Common bug; the correct code would be:

--- a/src/exec.c	2020-01-03 01:42:30.000000000 +0800
+++ b/src/exec.c	2025-04-08 22:17:16.000000000 +0800
@@ -190,7 +190,12 @@
 }
 
 /* Seems like POSIX has no header file for this, and even glibc + __USE_GNU doesn't help */
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
 extern char **environ;
+#endif
 
 /*! call an external shell command without waiting for it.
  *

Change History (1)

comment:1 Changed 2 months ago by ryandesign (Ryan Carsten Schmidt)

You didn't attach a main.log file or mention your macOS version, architecture, port version, etc.

IIRC, this problem should only affect Mac OS X 10.7.x and earlier.

The patch looks correct. gcc, for example, applied the same patch.

This is an upstream bug. As such, please report it to the project's developers rather than to MacPorts. They will fix it in their code, and once they release a new version, we can update to it and receive the fix. It makes no sense for MacPorts and everybody else who wants to compile this software on old macOS to separately maintain a patch like the one you suggested; the fix belongs in the upstream repository.

Note: See TracTickets for help on using tickets.