hoehermann / purple-signald

Pidgin libpurple bridge to signald.
GNU General Public License v3.0
153 stars 19 forks source link

pthread build error on OpenSuse. #81

Closed Zombie-Ryushu closed 1 year ago

Zombie-Ryushu commented 1 year ago
[   60s] cd /home/abuild/rpmbuild/BUILD/purple-signald-1678641082.7f1d736/build/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/signald.dir/link.txt --verbose=1
[   60s] /usr/bin/cc -fPIC -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -DNDEBUG -O2 -g -DNDEBUG  -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,libsignald.so -o libsignald.so CMakeFiles/signald.dir/attachments.c.o CMakeFiles/signald.dir/comms.c.o CMakeFiles/signald.dir/contacts.c.o CMakeFiles/signald.dir/groups.c.o CMakeFiles/signald.dir/libsignald.c.o CMakeFiles/signald.dir/link.c.o CMakeFiles/signald.dir/login.c.o CMakeFiles/signald.dir/message.c.o CMakeFiles/signald.dir/signald_procmgmt.c.o CMakeFiles/signald.dir/input.c.o CMakeFiles/signald.dir/options.c.o CMakeFiles/signald.dir/receipt.c.o CMakeFiles/signald.dir/admin.c.o CMakeFiles/signald.dir/status.c.o CMakeFiles/signald.dir/interface.c.o CMakeFiles/signald.dir/reply.c.o CMakeFiles/signald.dir/__/submodules/MegaMimes/src/MegaMimes.c.o CMakeFiles/signald.dir/__/submodules/QR-Code-generator/c/qrcodegen.c.o  -lpurple -lglib-2.0 -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 
[   60s] /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/signald.dir/login.c.o: in function `try_connect':
[   60s] /home/abuild/rpmbuild/BUILD/purple-signald-1678641082.7f1d736/src/login.c:133: undefined reference to `pthread_create'
[   60s] /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/purple-signald-1678641082.7f1d736/src/login.c:136: undefined reference to `pthread_detach'
[   60s] collect2: error: ld returned 1 exit status
[   60s] make[2]: *** [src/CMakeFiles/signald.dir/build.make:372: src/libsignald.so] Error 1
[   60s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/purple-signald-1678641082.7f1d736/build'
[   60s] make[1]: *** [CMakeFiles/Makefile2:101: src/CMakeFiles/signald.dir/all] Error 2
[   60s] make: *** [Makefile:139: all] Error 2
[   60s] error: Bad exit status from /var/tmp/rpm-tmp.fBTG09 (%build)
hoehermann commented 1 year ago

It looks like you are using GCC 7. That major release is over six years old. My build environment typically uses more up-to date versions. I am currently using GCC 11. It seems to link against libpthread automatically. For building with older versions, you may try to adjust src/CMakeLists.txt as described here: https://stackoverflow.com/questions/1620918/cmake-and-libpthread

Zombie-Ryushu commented 1 year ago

I believe the OpenSuse Build cluster has parameters for building with gcc-10, let me try that.

Zombie-Ryushu commented 1 year ago
[   52s] /usr/bin/gcc-10 -fPIC -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -DNDEBUG -O2 -g -DNDEBUG  -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -shared -Wl,-soname,libsignald.so -o libsignald.so CMakeFiles/signald.dir/attachments.c.o CMakeFiles/signald.dir/comms.c.o CMakeFiles/signald.dir/contacts.c.o CMakeFiles/signald.dir/groups.c.o CMakeFiles/signald.dir/libsignald.c.o CMakeFiles/signald.dir/link.c.o CMakeFiles/signald.dir/login.c.o CMakeFiles/signald.dir/message.c.o CMakeFiles/signald.dir/signald_procmgmt.c.o CMakeFiles/signald.dir/input.c.o CMakeFiles/signald.dir/options.c.o CMakeFiles/signald.dir/receipt.c.o CMakeFiles/signald.dir/admin.c.o CMakeFiles/signald.dir/status.c.o CMakeFiles/signald.dir/interface.c.o CMakeFiles/signald.dir/reply.c.o CMakeFiles/signald.dir/__/submodules/MegaMimes/src/MegaMimes.c.o CMakeFiles/signald.dir/__/submodules/QR-Code-generator/c/qrcodegen.c.o  -lpurple -lglib-2.0 -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 
[   52s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: CMakeFiles/signald.dir/login.c.o: in function `try_connect':
[   52s] /home/abuild/rpmbuild/BUILD/purple-signald-1678641082.7f1d736/src/login.c:133: undefined reference to `pthread_create'
[   52s] /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/bin/ld: /home/abuild/rpmbuild/BUILD/purple-signald-1678641082.7f1d736/src/login.c:136: undefined reference to `pthread_detach'
[   52s] collect2: error: ld returned 1 exit status
[   52s] make[2]: *** [src/CMakeFiles/signald.dir/build.make:372: src/libsignald.so] Error 1
[   52s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/purple-signald-1678641082.7f1d736/build'
[   52s] make[1]: *** [CMakeFiles/Makefile2:101: src/CMakeFiles/signald.dir/all] Error 2
[   52s] make: *** [Makefile:139: all] Error 2
[   52s] error: Bad exit status from /var/tmp/rpm-tmp.scaG1Q (%build)

Same error with gcc-10.

Zombie-Ryushu commented 1 year ago

it's suffering from obvious underlinking. Add a -lpthread where necessary or patch src/CMakeLists.txt

hoehermann commented 1 year ago

It is far from obvious to me. Adding libpthread is my recommendation in my first answer. I am hesitant to change the src/CMakeLists.txt without investigating. Before I understand why it is working now, I might break things for other people.

Update: Maybe it is due to this change in glibc. There is some discussion about it. I will now add the Threads dependency explicitly. Does it work for you?