Compiling on FreeBSD 15.0: '_IO_stdin_used' symbol not defined

Hello,

I really want to compile Asterisk on my FreeBSD 15 router, and make outputs that the ‘_IO_stdin_used’ symbol is not defined.
I don’t understand what the _IO_stdin_used symbol is, nor what a symbol is.

make” & “make NOISY_BUILD=yes” output:

# make
gmake
gmake[1]: Entering directory '/root/asterisk/asterisk-21.2.0'
CC="cc" CXX="c++" LD="" AR="" RANLIB="" CFLAGS="" LDFLAGS="" gmake -C menuselect CONFIGURE_SILENT="--silent" makeopts
gmake[2]: Entering directory '/root/asterisk/asterisk-21.2.0/menuselect'
gmake[2]: 'makeopts' is up to date.
gmake[2]: Leaving directory '/root/asterisk/asterisk-21.2.0/menuselect'
sed: 1: "s/#define\s+AST_BUILDOP ...": RE error: trailing backslash (\)
sed: 1: "s/#define\s+AST_BUILDOP ...": RE error: trailing backslash (\)
   [LD] chan_audiosocket.o -> chan_audiosocket.so
ld: error: version script assignment of 'global' to symbol '_IO_stdin_used' failed: symbol not defined
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [/root/asterisk/asterisk-21.2.0/Makefile.rules:193: chan_audiosocket.so] Error 1
gmake[1]: *** [Makefile:396: channels] Error 2
gmake[1]: Leaving directory '/root/asterisk/asterisk-21.2.0'
*** Error code 2

# make NOISY_BUILD=yes
gmake
gmake[1]: Entering directory '/root/asterisk/asterisk-21.2.0'
CC="cc" CXX="c++" LD="" AR="" RANLIB="" CFLAGS="" LDFLAGS="" gmake -C menuselect CONFIGURE_SILENT="--silent" makeopts
gmake[2]: Entering directory '/root/asterisk/asterisk-21.2.0/menuselect'
gmake[2]: 'makeopts' is up to date.
gmake[2]: Leaving directory '/root/asterisk/asterisk-21.2.0/menuselect'
sed: 1: "s/^\s+//g;s/\s+/ /g;s/\ ...": RE error: trailing backslash (\)
sed: 1: "s/^\s+//g;s/\s+/ /g;s/\ ...": RE error: trailing backslash (\)
sed: 1: "s/#define\s+AST_BUILDOP ...": RE error: trailing backslash (\)
sed: 1: "s/#define\s+AST_BUILDOP ...": RE error: trailing backslash (\)
gmake[2]: Entering directory '/root/asterisk/asterisk-21.2.0/utils'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/root/asterisk/asterisk-21.2.0/utils'
gmake[2]: Entering directory '/root/asterisk/asterisk-21.2.0/agi'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/root/asterisk/asterisk-21.2.0/agi'
gmake[2]: Entering directory '/root/asterisk/asterisk-21.2.0/contrib'
gmake[2]: Nothing to be done for 'all'.
gmake[2]: Leaving directory '/root/asterisk/asterisk-21.2.0/contrib'
gmake[2]: Entering directory '/root/asterisk/asterisk-21.2.0/third-party'
gmake -C pjproject all
gmake[3]: Entering directory '/root/asterisk/asterisk-21.2.0/third-party/pjproject'
gmake[3]: Nothing to be done for 'all'.
gmake[3]: Leaving directory '/root/asterisk/asterisk-21.2.0/third-party/pjproject'
gmake[2]: Leaving directory '/root/asterisk/asterisk-21.2.0/third-party'
gmake[2]: Entering directory '/root/asterisk/asterisk-21.2.0/channels'
/root/asterisk/asterisk-21.2.0/build_tools/make_linker_version_script chan_audiosocket "" "/root/asterisk/asterisk-21.2.0"
cc -o chan_audiosocket.so -pthread -L/usr/local/lib  -shared -Wl,--version-script,chan_audiosocket.exports,--warn-common  chan_audiosocket.o -lpthread
ld: error: version script assignment of 'global' to symbol '_IO_stdin_used' failed: symbol not defined
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [/root/asterisk/asterisk-21.2.0/Makefile.rules:193: chan_audiosocket.so] Error 1
gmake[2]: Leaving directory '/root/asterisk/asterisk-21.2.0/channels'
gmake[1]: *** [Makefile:396: channels] Error 2
gmake[1]: Leaving directory '/root/asterisk/asterisk-21.2.0'
*** Error code 2

Stop.
make: stopped in /root/asterisk/asterisk-21.2.0

The result of searching “_IO_stdin_used” references in the source directory:

# grep -rn '_IO_stdin_used'
./channels/chan_audiosocket.exports:5:          _IO_stdin_used;
./default.exports:5:            _IO_stdin_used;
./main/asterisk.exports.in:51:          If _IO_stdin_used is not exported, stdout/stderr may not get
./main/asterisk.exports.in:62:          > A build process that mangles the export of _IO_stdin_used is
./main/asterisk.exports.in:67:          LINKER_SYMBOL_PREFIX_IO_stdin_used;

The general steps I followed:

download & extract asterisk source

  • pkg install wget
  • mkdir /root/asterisk
  • cd /root/asterisk
  • wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-21.2.0.tar.gz
  • tar -xzvf asterisk-21.2.0.tar.gz

configure and dependencies

  • pkg install gmake e2fsprogs-libuuid jansson libxml2 lua54-lsqlite3
  • ./configure --with-pjproject-bundled

install git & download the freebsd ports required to make menuselect

  • pkg install git
  • git clone https://git.FreeBSD.org/ports.git /usr/ports
  • make menuselect

make asterisk

  • make

This seems to be a glibc-related thing. There’s a note about it in main/asterisk.exports.in, and one of the references is to this posting.

Thanks I didn’t bother to read the links in the note so I’m investigating it now.

I think I’ll have to compile glibc/libc with the enable-oldest-abi flag, or modify the part he mentioned in libio.h then compile it. :crossed_fingers:

I don’t understand anything about the bug though.

Also it seems to historically work when exporting _IO_stdin_used at first:

If _IO_stdin_used is not exported, stdout/stderr may not get properly aligned. That causes breakage on some architectures.

We export the symbol to get proper behaviour. Now printf doesn't SIGBUS anymore on the SPARC.

And further in time not anymore:

A build process that mangles the export of `_IO_stdin_used` is (as defined by the libc ABI, even if not explicitly written down) broken. [...]

Edit: Not solved, giving up:

I tried to compile libc from the FreeBSD source with and without the enable-oldest-abi flag, and it throws errors.
With the flag it says it’s an invalid flag (even when tweaking its syntax and versions) and then it continues compiling until it throws an error because of a missing file. Compiling without the flag throws the same missing file error.
I may have to compile the whole FreeBSD world for libc to compile correctly but it will be too long on this machine. And the flag doesn’t work anyway so there’s no point.

I will probably emulate Asterisk in a Debian appjail.

Thanks again and kind of you for the response @Ido