roc-streaming / roc-pulse

Roc Toolkit modules for PulseAudio.
https://roc-streaming.org
GNU Lesser General Public License v2.1
8 stars 2 forks source link

undefined symbol: pthread_atfork #27

Closed Ramblurr closed 1 year ago

Ramblurr commented 1 year ago

Hi there! I'm trying to get roc running on a raspberry pi (with 64bit arm).

I've used the rocstreaming/toolchain-aarch64-linux-gnu container image to cross-compile

Inside the toolchain container, I used the cmake command cmake .. -DHOST=aarch64-linux-gnu -DPULSEAUDIO_VERSION=14.2

Then I copied the built module-roc-sink.so and module-roc-sink-input.so to /usr/lib/pulse-14.2/modules/ on my raspberry pi.

Then I configured default.pa with : load-module module-roc-sink remote_ip=<some ip>, and performed a pulse audio restart.

This resulted in:

Dec 26 08:56:53 dev1 pulseaudio[2070]: E: [pulseaudio] ltdl-bind-now.c: Failed to open module /usr/lib/pulse-14.2/modules/module-roc-sink.so: /usr/lib/pulse-14.2/modules/module-roc-sink.so: undefined symbol: pthread_atfork
Dec 26 08:56:53 dev1 pulseaudio[2070]: /usr/bin/pulseaudio: symbol lookup error: /usr/lib/pulse-14.2/modules/module-roc-sink.so: undefined symbol: pthread_atfork

I've looked through CMakelists.txt, but don't see anything related to pthreads. Any tips would be much appreciated.

Target system info:

Debian bullseye 11 (Raspian) Linux dev1 5.15.76-v8+ #1597 SMP PREEMPT Fri Nov 4 12:16:41 GMT 2022 aarch64 GNU/Linux Raspberry PI Zero W 2

Compilation system: Fedora 37 Linux toolbox 6.0.11-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Dec 2 20:47:45 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

compile_commands.json:

[
{
  "directory": "/var/home/ramblurr/src/mycroft/roc-pulse/build",
  "command": "/opt/toolchain/bin/aarch64-linux-gnu-gcc -DROC_PULSEAUDIO_VERSION=14.2 -Dmodule_roc_sink_input_EXPORTS -I/var/home/ramblurr/src/mycroft/roc-pulse/src -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/pulseaudio-src/src -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/libtool-src/libltdl -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/roc-prefix/include  -fPIC -Wall -Wextra -Wno-unused-variable -O3 -DNDEBUG -fPIC -o CMakeFiles/module-roc-sink-input.dir/src/module-roc-sink-input.c.o -c /var/home/ramblurr/src/mycroft/roc-pulse/src/module-roc-sink-input.c",
  "file": "/var/home/ramblurr/src/mycroft/roc-pulse/src/module-roc-sink-input.c"
},
{
  "directory": "/var/home/ramblurr/src/mycroft/roc-pulse/build",
  "command": "/opt/toolchain/bin/aarch64-linux-gnu-gcc -DROC_PULSEAUDIO_VERSION=14.2 -Dmodule_roc_sink_EXPORTS -I/var/home/ramblurr/src/mycroft/roc-pulse/src -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/pulseaudio-src/src -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/libtool-src/libltdl -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/roc-prefix/include  -fPIC -Wall -Wextra -Wno-unused-variable -O3 -DNDEBUG -fPIC -o CMakeFiles/module-roc-sink.dir/src/module-roc-sink.c.o -c /var/home/ramblurr/src/mycroft/roc-pulse/src/module-roc-sink.c",
  "file": "/var/home/ramblurr/src/mycroft/roc-pulse/src/module-roc-sink.c"
},
{
  "directory": "/var/home/ramblurr/src/mycroft/roc-pulse/build",
  "command": "/opt/toolchain/bin/aarch64-linux-gnu-gcc -DROC_PULSEAUDIO_VERSION=14.2 -I/var/home/ramblurr/src/mycroft/roc-pulse/src -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/pulseaudio-src/src -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/libtool-src/libltdl -isystem /var/home/ramblurr/src/mycroft/roc-pulse/build/roc-prefix/include  -fPIC -Wall -Wextra -Wno-unused-variable -O3 -DNDEBUG -o CMakeFiles/rocpulse_helpers.dir/src/rocpulse_helpers.c.o -c /var/home/ramblurr/src/mycroft/roc-pulse/src/rocpulse_helpers.c",
  "file": "/var/home/ramblurr/src/mycroft/roc-pulse/src/rocpulse_helpers.c"
}
]
Ramblurr commented 1 year ago

Hmm ok, this patch fixed it!

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d768d4..874cef7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -145,6 +145,10 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
     "${CMAKE_C_FLAGS} -Weverything -Wno-unused-variable")
 endif()

+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+link_libraries(Threads::Threads)
+
 add_definitions(
   -DROC_PULSEAUDIO_VERSION=${PULSEAUDIO_VERSION}
   )
gavv commented 1 year ago

Thanks for report and patch! I've pushed it to main: cf0410cc6090ba599823a10e91861520f5e4172a

I also changed cross-compile options a bit:

gavv commented 1 year ago

Example:

docker run -t --rm -u "${UID}" -v "${PWD}:${PWD}" -w "${PWD}" \
  rocstreaming/toolchain-aarch64-linux-gnu \
    env TOOLCHAIN_PREFIX=aarch64-linux-gnu PULSEAUDIO_VERSION=14.2 make
gavv commented 1 year ago

Tagged v0.0.2 with these fixes.

gavv commented 1 year ago

Closing, feel free to reopen if needed.