Bug 257696 - audio/openal-soft: Fails to link with JACK enabled: ERROR: ld-elf.so.1: /usr/local/lib/libopenal.so.1: Undefined symbol "jack_error_callback"
Summary: audio/openal-soft: Fails to link with JACK enabled: ERROR: ld-elf.so.1: /usr/...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Hans Petter Selasky
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2021-08-09 03:34 UTC by Jack
Modified: 2022-01-19 10:46 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (multimedia)
koobs: merge-quarterly?


Attachments
pkg version -v output (60.73 KB, text/plain)
2021-08-09 05:46 UTC, Jack
no flags Details
compile log with make showconfig (107.64 KB, text/plain)
2021-08-09 05:47 UTC, Jack
no flags Details
Workaround for the missing symbol (596 bytes, patch)
2021-08-09 20:31 UTC, Florian Walpen
no flags Details | Diff
openal-soft-1.21.1_3 build failure with GCC 11, binutils 2.37 @ FreeBSD 12.3-STABLE (254.72 KB, text/plain)
2022-01-15 20:06 UTC, Sean Champ
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack 2021-08-09 03:34:57 UTC
When openal-soft is built with JACK support, the following error appears.

ERROR: ld-elf.so.1: /usr/local/lib/libopenal.so.1: Undefined symbol "jack_error_callback"
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2021-08-09 03:39:04 UTC
(In reply to Jack from comment #0)

Thank you for your report. Could you add some additional detail, including:

- uname -a output
- pkg version -v output
- full build log (compressed if necessary)
- config.log output (in WRKSRC directory, compressed if necessary)
Comment 2 Jack 2021-08-09 05:46:02 UTC
FreeBSD upstairs.jack.com 13.0-STABLE FreeBSD 13.0-STABLE #0 stable/13-n246457-1ea187f8a1bf: Sat Jul 24 00:28:11 PDT 2021     jack@upstairs.jack.com:/usr/obj/usr/src/amd64.amd64/sys/UPSTAIRS  amd64
Comment 3 Jack 2021-08-09 05:46:36 UTC
Created attachment 227032 [details]
pkg version -v output
Comment 4 Jack 2021-08-09 05:47:04 UTC
Created attachment 227033 [details]
compile log with make showconfig
Comment 5 Jack 2021-08-09 05:49:21 UTC
I don't think there is a config.log for cmake?
Comment 6 Florian Walpen 2021-08-09 20:31:06 UTC
Created attachment 227058 [details]
Workaround for the missing symbol

I can confirm this. Had to install games/supertux2 though, none of my existing ports actually use OpenAL, despite dependencies.

The new audio/jack version does not export the jack_error_callback symbol anymore, at least not in the client library (libjack.so). This looks intentional to me, as the symbol is marked optional.

My first workaround (and proof of culprit) is attached here. The nullptr argument makes jack use its default handler, which should be fine. And it gets supertux running.
Comment 7 Florian Walpen 2021-08-09 20:51:03 UTC
The code in question looks like it tries to check for the presence of the jack_error_callback symbol. That hints to weak symbol references, but the included `jack/jack.h` header does not specify jack_error_callback as weak.

There is actually an additional `jack/weakjack.h` header installed which can be used to achieve that. But when I add it here, other symbols (which are present) provoke a SEGFAULT. There may be a problem with linking order, I didn't investigate any further.
Comment 8 Sean Champ 2022-01-15 09:45:43 UTC
I've seen this error also, compiling multimedia/ffmpeg with jack enabled, with clang 13 in FreeBSD 12.3-STABLE. An excerpt of the build log for multimedia/ffmpeg 
~~~~
/usr/local/libexec/ccache/clang -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -Wl,--as-needed -lm -Wl,-rpath,/>
/usr/local/libexec/ccache/clang -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibpostproc -Llibswscale -Llibswresample -Wl,--as-needed -lm -Wl,-rpath,/>
ld: error: /usr/local/lib/libopenal.so: undefined reference to jack_error_callback [--no-allow-shlib-undefined]
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:124: ffplay_g] Error 1
gmake[2]: *** Waiting for unfinished jobs....
ld: error: /usr/local/lib/libopenal.so: undefined reference to jack_error_callback [--no-allow-shlib-undefined]
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:124: ffmpeg_g] Error 1
gmake[2]: Leaving directory '/wrkdirs/usr/ports/multimedia/ffmpeg/work/ffmpeg-4.4.1'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/multimedia/ffmpeg
~~~~

-ljack does show up in the compiler call, so there went my first guess ...

After the tip about possible side effects with weak pointers here, then looking at the work src file for jack
work/jack2-eaedec353489f26617221d66f80fd2503953c663/common/jack/weakmacros.h
~~~~
#ifndef JACK_WEAK_EXPORT
#ifdef __GNUC__
/* JACK_WEAK_EXPORT needs to be a macro which
   expands into a compiler directive. If non-null, the directive
   must tell the compiler to arrange for weak linkage of
   the symbol it used with. For this to work full may
   require linker arguments in the client as well.
*/
#ifdef _WIN32
    /*
        Not working with __declspec(dllexport) so normal linking
        Linking with JackWeakAPI.cpp will be the preferred way.
    */
    #define JACK_WEAK_EXPORT
#else
    #define JACK_WEAK_EXPORT __attribute__((WEAK_ATTRIBUTE))
#endif
~~~~


Maybe JACK_WEAK_EXPORT is not being defined when the build is produced with clang?

As a workaround, I'll try building Jack with GCC, the openal-soft and ffmpeg after. Hopefully it may clear up then
Comment 9 Florian Walpen 2022-01-15 14:22:39 UTC
(In reply to Sean Champ from comment #8)

Hmm, I could never produce the error in a build, with neither audio/openal-soft nor multimedia/ffmpeg. I only get this when running a consumer like supertux2. Do you have any non-default options set apart from Jack and OpenAL?
Comment 10 Sean Champ 2022-01-15 18:25:36 UTC
Rebuilding audio/jack with GCC, then openal-soft and ffmpeg with clang, the build in ffmpeg still fail like so when linking onto openal-soft.  I'll try rebuilding openal-soft with GCC also, then checking the build in ffmpeg

I'm building with clang 13 from the FreeBSD base system in a recent build on the stable/12 branch, i.e 12.3-STABLE under uname. jack is enabled in all three of these ports.
Comment 11 Florian Walpen 2022-01-15 19:05:54 UTC
After some digging, I think this is caused by an inconsistency in the export definitions of the libjack.so library. Jack2 (v1.9.x) seems to only export jack_error_callback in libjackserver.so, but not in libjack.so. All this while the jack.h header promises a non-weak symbol for it.

I'll see if this can be fixed in the jack port, I'm in the midst of updating that anyway - there's a new version 1.9.20 with FreeBSD support upstreamed.
Comment 12 Sean Champ 2022-01-15 19:56:24 UTC
(In reply to Florian Walpen from comment #11)

Great to hear!

fwiw the openal-soft build failed when I tried to compile with gcc11.  An excerpt of the verbose build log under poudriere:
~~~~
[ 13% 15/107] /usr/local/libexec/ccache/g++11 -DRESTRICT=__restrict -I/wrkdirs/usr/ports/audio/openal-soft/work/.build -I/wrkdirs/usr/ports/audio/openal-soft/work/openal-soft-1.21.1/utils -I>
FAILED: CMakeFiles/makemhr.dir/utils/makemhr/loadsofa.cpp.o
/usr/local/libexec/ccache/g++11 -DRESTRICT=__restrict -I/wrkdirs/usr/ports/audio/openal-soft/work/.build -I/wrkdirs/usr/ports/audio/openal-soft/work/openal-soft-1.21.1/utils -I/wrkdirs/usr/p>
../openal-soft-1.21.1/utils/makemhr/loadsofa.cpp: In function 'bool LoadSofaFile(const char*, uint, uint, uint, ChannelModeT, HrirDataT*)':
../openal-soft-1.21.1/utils/makemhr/loadsofa.cpp:554:27: error: 'sleep_for' is not a member of 'std::this_thread'
  554 |         std::this_thread::sleep_for(std::chrono::milliseconds{50});
      |                           ^~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-thread-safety' may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option '-Wno-thread-safety' may have been intended to silence earlier diagnostics
[ 14% 15/107] /usr/local/libexec/ccache/g++11 -DRESTRICT=__restrict -I/wrkdirs/usr/ports/audio/openal-soft/work/.build -I/wrkdirs/usr/ports/audio/openal-soft/work/openal-soft-1.21.1/utils -I>
In file included from ../openal-soft-1.21.1/utils/makemhr/makemhr.cpp:65:
../openal-soft-1.21.1/utils/makemhr/makemhr.h: In function 'int ProcessDefinition(const char*, uint, ChannelModeT, bool, uint, uint, int, int, double, uint, HeadModelT, double, const char*)':
../openal-soft-1.21.1/utils/makemhr/makemhr.h:91:8: warning: inlining failed in call to 'HrirDataT::~HrirDataT() noexcept': call is unlikely and code size would grow [-Winline]
   91 | struct HrirDataT {
      |        ^~~~~~~~~
../openal-soft-1.21.1/utils/makemhr/makemhr.cpp:1485:1: note: called from here
 1485 | }
      | ^
In file included from ../openal-soft-1.21.1/utils/makemhr/makemhr.cpp:65:
../openal-soft-1.21.1/utils/makemhr/makemhr.h:91:8: warning: inlining failed in call to 'HrirDataT::~HrirDataT() noexcept': call is unlikely and code size would grow [-Winline]
   91 | struct HrirDataT {
      |        ^~~~~~~~~
../openal-soft-1.21.1/utils/makemhr/makemhr.cpp:1485:1: note: called from here
 1485 | }
      | ^
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-thread-safety' may have been intended to silence earlier diagnostics
cc1plus: note: unrecognized command-line option '-Wno-thread-safety' may have been intended to silence earlier diagnostics
ninja: build stopped: subcommand failed.
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/audio/openal-soft
*** Error code 1
~~~

fwiw the '-Wno-thread-safety' option was added to CFLAGS under local make.conf

It looks like this is the most recent version of the upstream distfile. Maybe it'll build with any earlier GCC version?

I'll attach my build log for  openal-soft-1.21.1_3 under local configuration. For ports builds, I'm using some custom on-site configuration with files referenced originally from /etc/make.conf together with a local /usr/ports/Makefile.inc for facilitating some parts of the build configuration  - e.g toolchain configuration with conditional selection of clang, gcc, bintuls, and nasm for specific ports, also some local hacks for ccache integration in the build (local wrapper scripts, toolchaini symlinks under BINARY_LINKDIR, etc). Perhaps this may help to explain the verbose output in my build log.

The build log will be trimmed of my local annotations on make.conf, and will not include these additional files. I could clean those up and attach, if it could be of any interest.

The build log is verbose, illustrating a lot of the toolchain configuration at every stage of the build when building under poudriere

For the present thing, I'll try building this with an earlier GCC version, maybe gcc10 will work out?
Comment 13 Sean Champ 2022-01-15 20:06:52 UTC
Created attachment 231028 [details]
openal-soft-1.21.1_3 build failure with GCC 11, binutils 2.37 @ FreeBSD 12.3-STABLE

This is a build log from my local poudriere build for openal-soft-1.21.1_3. For purpose of brefvity, I've trimmed the make.conf content to remove some local annotations. The build log is otherwise quite verbose, in illustrating features of the toolchain configuration.

The build was produced using GCC 11, binutils 2.37, on FreeBSD 12.3-STABLE, full uname:
FreeBSD riparian.cloud.thinkum.space 12.3-STABLE FreeBSD 12.3-STABLE stable/12-n1855-ce99de0241e RIPARIAN  amd64

The build failure shows up at around line nr. 2757 in this build log
Comment 14 Sean Champ 2022-01-15 21:26:20 UTC
re: the build failure with GCC 11, I've tried a GCC 11 build with --enable-libstdcxx-time added to CONFIGURE_ARGS then building openal-soft with that GCC

References:
* What is _GLIBCXX_USE_NANOSLEEP all about? (Stack Overflow)
   https://stackoverflow.com/questions/12523122/what-is-glibcxx-use-nanosleep-all-about
* std::this_thread::sleep_for() and GCC (Stack Overflow)
   https://stackoverflow.com/questions/4438084/stdthis-threadsleep-for-and-gcc

vis a vis, at the second reference:
> error: ‘sleep_for’ is not a member of ‘std::this_thread’
> I looked in header 'thread'.
> sleep_for() is protected with _GLIBCXX_USE_NANOSLEEP

The build still fails under this compiler configuration. The build failure is essentially the same as in that attached build log. Excerpt:

~~~~
[ 13% 15/107] /usr/local/libexec/ccache/g++11 -DRESTRICT=__restrict -I/wrkdirs/usr/ports/audio/openal-soft/work/.build -I/wrkdirs/usr/ports/audio/openal-soft/work/openal-soft-1.21.1/utils -I>
FAILED: CMakeFiles/makemhr.dir/utils/makemhr/loadsofa.cpp.o 
/usr/local/libexec/ccache/g++11 -DRESTRICT=__restrict -I/wrkdirs/usr/ports/audio/openal-soft/work/.build -I/wrkdirs/usr/ports/audio/openal-soft/work/openal-soft-1.21.1/utils -I/wrkdirs/usr/p>
../openal-soft-1.21.1/utils/makemhr/loadsofa.cpp: In function 'bool LoadSofaFile(const char*, uint, uint, uint, ChannelModeT, HrirDataT*)':
../openal-soft-1.21.1/utils/makemhr/loadsofa.cpp:554:27: error: 'sleep_for' is not a member of 'std::this_thread'
  554 |         std::this_thread::sleep_for(std::chrono::milliseconds{50});
      |                           ^~~~~~~~~
~~~~

Though the gcc build has that added configure arg now, and may have some additional features under related defines in the source tree, I'm not entirely sure if the openal-soft build is using GNU libstdc++ in the build

Of course, this is probably unrelated to jackd.
Comment 15 Sean Champ 2022-01-15 21:54:15 UTC
Changing the USES line to the following in audio/openal-soft, the build does not fail with GCC 11 here

USES=           cmake compiler:gcc-c++11-lib tar:bzip2 

Apparently this uses GCC but with libc++ in lieu of GNU libstc++


I'll try building ffmpeg with an openal-soft built under this configuration, jackd enabled all across
Comment 16 Sean Champ 2022-01-15 22:03:25 UTC
erm that was too soon, the build still fails here, back to " undefined reference to `jack_error_callback'". 

This is with the following change in the openal-soft port Makefile

USES=           cmake compiler:gcc-c++11-lib tar:bzip2 

and with GCC11 patched for '--enable-libstdcxx-time'

An excerpt of the build log, without truncation to screen width:
~~~~
[ 95% 103/107] : && /usr/local/libexec/ccache/gcc11 -O2 -pipe -Wno-thread-safety   -fstack-protector -Wl,-rpath=/usr/local/lib/gcc11 -isystem /usr/local/include -fno-strict-aliasing -O2 -pipe
 -Wno-thread-safety   -fstack-protector -Wl,-rpath=/usr/local/lib/gcc11 -isystem /usr/local/include -fno-strict-aliasing -Wl,--as-needed -Wl,--as-needed -L/wrkdirs/usr/ports/audio/openal-soft
/work -fstack-protector -Wl,-rpath=/usr/local/lib/gcc11 -L/usr/local/lib/gcc11 CMakeFiles/openal-info.dir/utils/openal-info.c.o -o openal-info  -Wl,-rpath,/wrkdirs/usr/ports/audio/openal-soft
/work/.build:  -pthread  libopenal.so.1.21.1 && :
FAILED: openal-info 
: && /usr/local/libexec/ccache/gcc11 -O2 -pipe -Wno-thread-safety   -fstack-protector -Wl,-rpath=/usr/local/lib/gcc11 -isystem /usr/local/include -fno-strict-aliasing -O2 -pipe -Wno-thread-sa
fety   -fstack-protector -Wl,-rpath=/usr/local/lib/gcc11 -isystem /usr/local/include -fno-strict-aliasing -Wl,--as-needed -Wl,--as-needed -L/wrkdirs/usr/ports/audio/openal-soft/work -fstack-p
rotector -Wl,-rpath=/usr/local/lib/gcc11 -L/usr/local/lib/gcc11 CMakeFiles/openal-info.dir/utils/openal-info.c.o -o openal-info  -Wl,-rpath,/wrkdirs/usr/ports/audio/openal-soft/work/.build:  
-pthread  libopenal.so.1.21.1 && :
/usr/local/bin/ld: libopenal.so.1.21.1: undefined reference to `jack_error_callback'
collect2: error: ld returned 1 exit status
[ 96% 103/107] /usr/local/libexec/ccache/g++11 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I/wrkdirs/usr/ports/audio/openal-soft/work/.build/utils/alsoft-config -I/wrkdirs/usr/ports/audio/openal-soft/work/.build -isystem /usr/local/include/qt5 -isystem /usr/local/include/qt5/QtWidgets -isystem /usr/local/include/qt5/QtGui -isystem /usr/local/include/qt5/QtCore -isystem /usr/local/lib/qt5/mkspecs/freebsd-clang -O2 -pipe -Wno-thread-safety   -fstack-protector -Wl,-rpath=/usr/local/lib/gcc11   -nostdinc++ -isystem /usr/include/c++/v1 -Wl,-rpath=/usr/local/lib/gcc11 -isystem /usr/local/include -O2 -pipe -Wno-thread-safety   -fstack-protector -Wl,-rpath=/usr/local/lib/gcc11   -nostdinc++ -isystem /usr/include/c++/v1 -Wl,-rpath=/usr/local/lib/gcc11 -isystem /usr/local/include -fPIC -std=gnu++14 -MD -MT utils/alsoft-config/CMakeFiles/alsoft-config.dir/main.cpp.o -MF utils/alsoft-config/CMakeFiles/alsoft-config.dir/main.cpp.o.d -o utils/alsoft-config/CMakeFiles/alsoft-config.dir/main.cpp.o -c /wrkdirs/usr/ports/audio/openal-soft/work/openal-soft-1.21.1/utils/alsoft-config/main.cpp
ninja: build stopped: subcommand failed.
~~~~

With apologies for the circuitous patching and build logs here, in the local build it's back to the original build failure presently

I'll try to keep an eye out  for any updates with jackd in the ports tree. imo the ideal kdenlive build would use jackd, lol, I'm sure there are countless usage cases
Comment 17 Florian Walpen 2022-01-15 22:13:05 UTC
Ok, so exporting the missing jack_error_callback in libjack.so effectively solves this problem. Either that or exporting it as weak symbol, I'll have to discuss that with the Jack maintainers.

For anyone with a pressing need for this option, there's still my workaround patch. But I think I'll have this resolved in the next week or so.

@Sean Champ: I'm not sure what you're trying to achieve there. The compiler is not the problem, the missing symbol is. And consumers of the openal-soft library will not run without it.
Comment 18 Sean Champ 2022-01-16 01:29:29 UTC
(In reply to Florian Walpen from comment #17)

I was mainly trying to get this component to build with jack, not being a lot of familiar with C or C++ albeit.  

In my own limited experience with either programming language, I was simply trying to build this with another compiler. After I tried building it with gcc11 then, I encountered that other error. 

Simply, I was hoping there might be a build configuration that would work around both of these build errors, while keeping jackd in the build config. Towards audio processing with kdenlive or for live audio output, Jamin provides a multi-band equalizer for jack, if jack's available on the host. 

I'm not aware of anything similar to Jamin in free/open source audio applications. For a usage case with kdenlive, maybe there's some kind of an equalizer available with it internally
Comment 19 Florian Walpen 2022-01-16 11:52:55 UTC
(In reply to Sean Champ from comment #18)

For live mastering of audio, Jack and Jamin sounds like the way to go. Do you need OpenAL for that? If not, you could just disable it in ffmpeg.

Otherwise, the only short term solution is my workaround patch attached here. You can just add it to the other patches in audio/openal-soft/files - I think it should still work.
Comment 20 Florian Walpen 2022-01-16 22:41:20 UTC
FYI, bug #261256 contains the update for audio/jack which also fixes this issue for me. Please report back when the update hits the ports tree.
Comment 21 commit-hook freebsd_committer freebsd_triage 2022-01-19 10:45:36 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=93344cda77603560b6ba421778d92be03e70800b

commit 93344cda77603560b6ba421778d92be03e70800b
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-01-19 10:41:40 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-01-19 10:44:09 +0000

    audio/jack: Update to 1.9.20 release.

    The FreeBSD specific changes have been upstreamed, we can fetch the original
    sources again. Development of the client examples and tools has been split
    from the JACK server, move them to the new port jack-example-tools.

    This also includes a fix for missing library symbols, see bug #257696.

    Take maintainership of audio/jack and audio/jack-example-tools .

    PR: 257696
    PR: 261256

    Submitted by:   Florian Walpen <dev@submerge.ch>
    Approved by:    pi (implicit)

 audio/Makefile                                    |  1 +
 audio/jack-example-tools/Makefile (new)           | 49 +++++++++++++++++
 audio/jack-example-tools/distinfo (new)           |  3 ++
 audio/jack-example-tools/pkg-descr (new)          |  8 +++
 audio/jack-example-tools/pkg-plist (new)          | 65 +++++++++++++++++++++++
 audio/jack/Makefile                               | 34 ++++--------
 audio/jack/distinfo                               |  6 +--
 audio/jack/files/patch-common_JackError.cpp (new) | 10 ++++
 audio/jack/files/patch-common_JackError.h (new)   | 13 +++++
 audio/jack/pkg-descr                              | 13 ++---
 audio/jack/pkg-message                            | 49 ++++++-----------
 audio/jack/pkg-plist                              | 60 +--------------------
 12 files changed, 184 insertions(+), 127 deletions(-)