roehling / postsrsd

Postfix Sender Rewriting Scheme daemon
319 stars 38 forks source link

`make -j` fails with `undefined reference to symbol '__pthread_unregister_cancel@@GLIBC_2.3.3'` #130

Closed christoph-kluge closed 1 year ago

christoph-kluge commented 1 year ago

Any idea what might be missing?

While searching for answers I've found similar error-messages where people solved it by adding -pthread to the LDFLAGS

# uname -a
Linux [obfuscated-hostname] 4.14.301-224.520.amzn2.x86_64 #1 SMP Fri Dec 9 09:57:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# ldd --version
ldd (GNU libc) 2.26

This is a subsequent make -j run which reduces the output to the failing left-overs.

# make -j
[  4%] Built target sqlite3
[ 22%] Built target ExtConfuse
[ 46%] Built target check
[ 48%] Building C object CMakeFiles/postsrsd.dir/src/config.c.o
[ 51%] Building C object CMakeFiles/postsrsd.dir/src/database.c.o
[ 53%] Building C object CMakeFiles/postsrsd.dir/src/main.c.o
[ 55%] Building C object CMakeFiles/postsrsd.dir/src/endpoint.c.o
[ 57%] Building C object CMakeFiles/postsrsd.dir/src/milter.c.o
[ 60%] Building C object CMakeFiles/postsrsd.dir/src/netstring.c.o
[ 62%] Building C object CMakeFiles/postsrsd.dir/src/sha1.c.o
[ 64%] Linking C executable test_sha1_executable
[ 66%] Linking C executable test_netstring_executable
[ 68%] Linking C executable test_util_executable
[ 71%] Building C object CMakeFiles/postsrsd.dir/src/srs.c.o
[ 73%] Building C object CMakeFiles/postsrsd.dir/src/srs2.c.o
[ 75%] Building C object tests/unit/CMakeFiles/test_database_executable.dir/test_database.c.o
[ 80%] Building C object tests/unit/CMakeFiles/test_database_executable.dir/__/__/src/database.c.o
[ 80%] Building C object CMakeFiles/postsrsd.dir/src/util.c.o
[ 82%] Building C object tests/unit/CMakeFiles/test_database_executable.dir/__/__/src/util.c.o
/usr/bin/ld: ../../_deps/check-build/src/libcheck.a(check_pack.c.o): undefined reference to symbol '__pthread_unregister_cancel@@GLIBC_2.3.3'
//usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [tests/unit/test_netstring_executable] Error 1
make[1]: *** [tests/unit/CMakeFiles/test_netstring_executable.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: ../../_deps/check-build/src/libcheck.a(check_pack.c.o): undefined reference to symbol '__pthread_unregister_cancel@@GLIBC_2.3.3'
//usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [tests/unit/test_sha1_executable] Error 1
/usr/bin/ld: ../../_deps/check-build/src/libcheck.a(check_pack.c.o): undefined reference to symbol '__pthread_unregister_cancel@@GLIBC_2.3.3'
make[1]: *** [tests/unit/CMakeFiles/test_sha1_executable.dir/all] Error 2
//usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [tests/unit/test_util_executable] Error 1
make[1]: *** [tests/unit/CMakeFiles/test_util_executable.dir/all] Error 2
[ 84%] Linking C executable postsrsd
[ 84%] Built target postsrsd
[ 86%] Linking C executable test_database_executable
/usr/bin/ld: ../../_deps/check-build/src/libcheck.a(check_pack.c.o): undefined reference to symbol '__pthread_unregister_cancel@@GLIBC_2.3.3'
//usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [tests/unit/test_database_executable] Error 1
make[1]: *** [tests/unit/CMakeFiles/test_database_executable.dir/all] Error 2
make: *** [all] Error 2
roehling commented 1 year ago

From what I can tell, libcheck tries to add the -pthread flag here, but this is not very portable. I will add explicit linkage against the pthread library and you can check if that works for you.

roehling commented 1 year ago

I had to fix a few more link errors, but the latest HEAD should be working now. I'm developing on Debian unstable with glibc 2.36, which has a merged pthread, so those errors never came up on my machine. Thank you very much for the bug report!

christoph-kluge commented 1 year ago

@roehling thank you for this quick solution. 2.0.1 worked like a charm :)