libwebsockets
libwebsockets copied to clipboard
Build Failure without Server and libuv
Noticed a problem building version 4.3.3 in Yocto (scarthgap branch). When setting PACKAGECONFIG to not include server see the Yocto bitbake file here https://git.openembedded.org/meta-openembedded/tree/meta-oe/recipes-connectivity/libwebsockets/libwebsockets_4.3.3.bb?h=scarthgap (uses -DLWS_WITHOUT_SERVER=ON)
...
| lib/event-libs/libuv/libuv.c: In function 'elops_listen_init_uv':
| libwebsockets/4.3.3/git/include/libwebsockets.h:367:54: error: 'struct lws' has no member named 'listen_list'
| 367 | #define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)))
| | ^~~~~~~~
| libwebsockets/4.3.3/git/lib/event-libs/libuv/libuv.c:701:27: note: in expansion of macro 'lws_container_of'
| 701 | struct lws *wsi = lws_container_of(d, struct lws, listen_list);
The error seems to come from the changes here where a member listen_list that's not compiled when the server feature is disabled is being used in the event library code regardless of the server feature being compiled or not.
https://github.com/warmcat/libwebsockets/commit/6163c967273fad05bf544e455bc185562eb6facc
Tested building on 4.3.3 outside Yocto (Ubuntu 22.04) and the minimal repro build is the following deviation from the standard configuration.
cmake -B build . then used ccmake to set the following options LWS_WITHOUT_SERVER and LWS_WITH_LIBUV and configure.
[ 98%] Linking C shared library libwebsockets.so
[ 98%] Built target websockets_shared
[ 98%] Building C object lib/event-libs/libuv/CMakeFiles/websockets-evlib_uv.dir/libuv.c.o
In file included from /usr/include/x86_64-linux-gnu/sys/param.h:23,
from /usr/include/uv/unix.h:41,
from /usr/include/uv.h:68,
from /home/ubuntu/3rd/libwebsockets/lib/event-libs/libuv/private-lib-event-libs-libuv.h:25,
from /home/ubuntu/3rd/libwebsockets/lib/event-libs/libuv/libuv.c:26:
/home/ubuntu/3rd/libwebsockets/lib/event-libs/libuv/libuv.c: In function ‘elops_listen_init_uv’:
/home/ubuntu/3rd/libwebsockets/include/libwebsockets.h:367:54: error: ‘struct lws’ has no member named ‘listen_list’
367 | #define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M)))
| ^~~~~~~~
/home/ubuntu/3rd/libwebsockets/lib/event-libs/libuv/libuv.c:701:27: note: in expansion of macro ‘lws_container_of’
701 | struct lws *wsi = lws_container_of(d, struct lws, listen_list);
| ^~~~~~~~~~~~~~~~
gmake[2]: *** [lib/event-libs/libuv/CMakeFiles/websockets-evlib_uv.dir/build.make:76: lib/event-libs/libuv/CMakeFiles/websockets-evlib_uv.dir/libuv.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1330: lib/event-libs/libuv/CMakeFiles/websockets-evlib_uv.dir/all] Error 2
gmake: *** [Makefile:166: all] Error 2
It should also be checked that building with other event backends works as well. As disabling server without setting a backend works fine because the poll backend seems to be selected by default when building natively.
It's a bit late, but I pushed a patch fixing this on both main and v4.3-stable