jiixyj / epoll-shim

small epoll implementation using kqueue; includes all features needed for libinput/libevdev
MIT License
91 stars 24 forks source link

FreeBSD build - linker error #25

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi! I'm not sure that this is the right place to ask for help, so please let me know if I need to ask somewhere else. I'm using Poudriere to build my ports automatically. I'm using the latest head of 12.01 port tree. The devel/libepoll-shim port build fails with linker error.

First these 2 warnings:

[12/44] /usr/local/libexec/ccache/cc -Depoll_shim_EXPORTS -Isrc -I/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/include -I/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/include/eventfd -I/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/external/queue-macros/include -I/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/external/tree-macros/include -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -fPIC -fvisibility=hidden -pthread -std=gnu11 -MD -MT src/CMakeFiles/epoll-shim.dir/signalfd_ctx.c.o -MF src/CMakeFiles/epoll-shim.dir/signalfd_ctx.c.o.d -o src/CMakeFiles/epoll-shim.dir/signalfd_ctx.c.o -c /wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/src/signalfd_ctx.c
/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/src/signalfd_ctx.c:60:6: warning: implicit declaration of function 'sigandset' is invalid in C99 [-Wimplicit-function-declaration]
            sigandset(&pending_sigs, &pending_sigs, &signalfd->sigs) < 0) {
            ^
/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/src/signalfd_ctx.c:64:18: warning: implicit declaration of function 'sigisemptyset' is invalid in C99 [-Wimplicit-function-declaration]
        *has_pending = !sigisemptyset(&pending_sigs);
                        ^
2 warnings generated.

then:

[21/44] : && /usr/local/libexec/ccache/cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -fstack-protector-strong test/CMakeFiles/tst-timerfd.dir/tst-timerfd.c.o -o test/tst-timerfd  -Wl,-rpath,/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/src:/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/external/microatf/src  src/libepoll-shim.so.0  external/microatf/src/libmicroatf-c.so  -pthread && cd /wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test && /usr/local/bin/cmake -D TEST_TARGET=tst-timerfd -D TEST_EXECUTABLE=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test/tst-timerfd -D TEST_EXECUTOR= -D TEST_PROPERTIES= -D TEST_CONFIG_VARIABLES= -D TRANSLATE_SIGNAL=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/external/microatf/src/microatf-translate-signal -D CTEST_FILE=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test/tst-timerfd_tests.cmake -D BINARY_DIR=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test -D TEST_RUN_SCRIPT=/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/external/microatf/cmake/ATFRunTest.cmake -P /wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/external/microatf/cmake/ATFTestAddTests.cmake
FAILED: test/tst-timerfd test/tst-timerfd_tests.cmake 
: && /usr/local/libexec/ccache/cc -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -fstack-protector-strong test/CMakeFiles/tst-timerfd.dir/tst-timerfd.c.o -o test/tst-timerfd  -Wl,-rpath,/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/src:/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/external/microatf/src  src/libepoll-shim.so.0  external/microatf/src/libmicroatf-c.so  -pthread && cd /wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test && /usr/local/bin/cmake -D TEST_TARGET=tst-timerfd -D TEST_EXECUTABLE=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test/tst-timerfd -D TEST_EXECUTOR= -D TEST_PROPERTIES= -D TEST_CONFIG_VARIABLES= -D TRANSLATE_SIGNAL=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/external/microatf/src/microatf-translate-signal -D CTEST_FILE=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test/tst-timerfd_tests.cmake -D BINARY_DIR=/wrkdirs/usr/ports/devel/libepoll-shim/work/.build/test -D TEST_RUN_SCRIPT=/wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/external/microatf/cmake/ATFRunTest.cmake -P /wrkdirs/usr/ports/devel/libepoll-shim/work/epoll-shim-c8491d3/external/microatf/cmake/ATFTestAddTests.cmake
ld: error: src/libepoll-shim.so.0: undefined reference to sigandset
ld: error: src/libepoll-shim.so.0: undefined reference to sigisemptyset
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
*** Error code 1

Environment details:

=>> Building devel/libepoll-shim
build started at Tue Mar  9 22:32:03 CET 2021
port directory: /usr/ports/devel/libepoll-shim
package name: libepoll-shim-0.0.20210213
building for: FreeBSD 1201amd64-head-job-01 12.1-RELEASE-p10 FreeBSD 12.1-RELEASE-p10 amd64
maintained by: x11@FreeBSD.org
Makefile ident:      $FreeBSD: head/devel/libepoll-shim/Makefile 566000 2021-02-18 22:06:57Z jbeich $
Poudriere version: 3.3.6
Host OSVERSION: 1202000
Jail OSVERSION: 1201000
Job Id: 01

---Begin Environment---
SHELL=/bin/csh
OSVERSION=1201000
UNAME_v=FreeBSD 12.1-RELEASE-p10
UNAME_r=12.1-RELEASE-p10
BLOCKSIZE=K
MAIL=/var/mail/root
STATUS=1
HOME=/root
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
LOCALBASE=/usr/local
USER=root
LIBEXECPREFIX=/usr/local/libexec/poudriere
POUDRIERE_VERSION=3.3.6
MASTERMNT=/usr/local/poudriere/data/.m/1201amd64-head/ref
POUDRIERE_BUILD_TYPE=bulk
PACKAGE_BUILDING=yes
SAVED_TERM=unknown
PWD=/usr/local/poudriere/data/.m/1201amd64-head/ref/.p/pool
P_PORTS_FEATURES=FLAVORS SELECTED_OPTIONS
MASTERNAME=1201amd64-head
SCRIPTPREFIX=/usr/local/share/poudriere
OLDPWD=/usr/local/poudriere/data/.m/1201amd64-head/ref/.p
SCRIPTPATH=/usr/local/share/poudriere/bulk.sh
POUDRIEREPATH=/usr/local/bin/poudriere
---End Environment---

Any advise what can be wrong? Thanks.

jiixyj commented 3 years ago

Hi! This is absolutely the right place to ask :)

It looks like those sigops functions appeared in FreeBSD 12.2 and are not available in 12.1.

Can you check if the following (completely untested) patch works?

diff --git a/src/signalfd_ctx.c b/src/signalfd_ctx.c
index 73a3443..507be48 100644
--- a/src/signalfd_ctx.c
+++ b/src/signalfd_ctx.c
@@ -29,7 +29,9 @@
        __sigandset((sr), (sd));                                      \
        0;                                                            \
    })
-#elif defined(__DragonFly__)
+#elif defined(__DragonFly__) ||                                               \
+    (defined(__FreeBSD__) && __FreeBSD__ == 12 &&                             \
+   __FreeBSD_version < 1201505)
 static inline int
 sigandset(sigset_t *dest, sigset_t const *left, sigset_t const *right)
 {
jiixyj commented 3 years ago

I could verify a version of the above patch on a 12.1 machine and applied it on master. All tests ran successfully on 12.1.

Thanks again for the report!

ghost commented 3 years ago

Thank you. It works for me too now.