Bug #3251
closed[1.4.76] buildroot compile error with bootlin-sparc{64-g,-uc}libc
Description
Hi,
I noticed a compile error on the Sparc platform while bumping lighttpd in Buildroot.
bootlin-sparc-uclibc:¶
FAILED: src/lighttpd.p/fdevent_impl.c.o /home/thomas/br-test-pkg/bootlin-sparc-uclibc/host/bin/sparc-linux-gcc -Isrc/lighttpd.p -Isrc -I../src -I/home/thomas/br-test-pkg/bootlin-sparc-uclibc/host/sparc-buildroot-linux-uclibc/sysroot/usr/local/include -fdiagnostics-color=always -Wall -Winvalid-pch -std=c11 -O3 -D_LARGEFILE64_SOURCE -O2 -g0 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D_DEFAULT_SOURCE -D_GNU_SOURCE -DHAVE_CONFIG_H -pipe -Wall -g -Wshadow -W -pedantic -MD -MQ src/lighttpd.p/fdevent_impl.c.o -MF src/lighttpd.p/fdevent_impl.c.o.d -o src/lighttpd.p/fdevent_impl.c.o -c ../src/fdevent_impl.c In file included from ../src/ck.h:121, from ../src/buffer.h:407, from ../src/fdevent_impl.c:5: ../src/fdevent_impl.c: In function ‘fdevent_linux_sysepoll_init’: ../src/ck.h:125:29: error: static assertion failed: "EPOLLRDHUP == FDEVENT_RDHUP" 125 | #define ck_static_assert(x) static_assert((x),#x) | ^~~~~~~~~~~~~ ../src/fdevent_impl.c:379:5: note: in expansion of macro ‘ck_static_assert’ 379 | ck_static_assert(EPOLLRDHUP == FDEVENT_RDHUP); | ^~~~~~~~~~~~~~~~
bootlin-sparc64-glibc:¶
FAILED: src/lighttpd.p/fdevent_impl.c.o /home/thomas/br-test-pkg/bootlin-sparc64-glibc/host/bin/sparc64-linux-gcc -Isrc/lighttpd.p -Isrc -I../src -I/home/thomas/br-test-pkg/bootlin-sparc64-glibc/host/sparc64-buildroot-linux-gnu/sysroot/usr/local/include -fdiagnostics-color=always -Wall -Winvalid-pch -std=c11 -O3 -D_LARGEFILE64_SOURCE -O2 -g0 -D_FORTIFY_SOURCE=1 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -D_DEFAULT_SOURCE -D_GNU_SOURCE -DHAVE_CONFIG_H -pipe -Wall -g -Wshadow -W -pedantic -MD -MQ src/lighttpd.p/fdevent_impl.c.o -MF src/lighttpd.p/fdevent_impl.c.o.d -o src/lighttpd.p/fdevent_impl.c.o -c ../src/fdevent_impl.c In file included from ../src/ck.h:121, from ../src/buffer.h:407, from ../src/fdevent_impl.c:5: ../src/fdevent_impl.c: In function ‘fdevent_linux_sysepoll_init’: ../src/ck.h:125:29: error: static assertion failed: "EPOLLRDHUP == FDEVENT_RDHUP" 125 | #define ck_static_assert(x) static_assert((x),#x) | ^~~~~~~~~~~~~ ../src/fdevent_impl.c:379:5: note: in expansion of macro ‘ck_static_assert’ 379 | ck_static_assert(EPOLLRDHUP == FDEVENT_RDHUP); | ^~~~~~~~~~~~~~~~
Reproduction:¶
$ git clone https://gitlab.com/buildroot.org/buildroot.git $ cd buildroot/ $ curl https://patchwork.ozlabs.org/series/403994/mbox/ | git am $ ./utils/test-pkg -p lighttpd -a $ cat ~/br-test-pkg/bootlin-sparc-uclibc/logfile $ cat ~/br-test-pkg/bootlin-sparc64-glibc/logfile
Files
Updated by gstrauss 8 months ago
- Category set to core
- Target version changed from 1.4.xx to 1.4.77
What is the value of EPOLLRDHUP
on that system? I had added logic in lighttpd 1.4.76 (commit f14f9142) in an attempt to fix the build issue on Debian sparc64
https://buildd.debian.org/status/fetch.php?pkg=lighttpd&arch=sparc64&ver=1.4.74-2&stamp=1709590155&raw=0
If the value with uclibc on Linux on sparc64 is 0x2000, as is on most Linux, and not 0x0800 as is on glibc on sparc64, then I'll adjust the special-case to check for __GLIBC__
, too.
Ultimately, the workaround for you is to adjust the value of FDEVENT_RDHUP
in fdevent.h.
The value is hard-coded to encapsulate the system-specific values rather than expose extra system headers, but lighttpd has a static_assert() to ensure that the values match in fdevent_impl.c
Updated by gstrauss 8 months ago
- Status changed from Patch Pending to Fixed
Applied in changeset 88ff3763dae65371eab9f8a22ac1c95c96fe4490.
Updated by ThomasDevoogdt 8 months ago
Hi,
Sorry for the late answer.
I checked the patch, but I think you were a little bit too fast.
There is apparently POLLRDHUP and EPOLLRDHUP, for which there are two static asserts with FDEVENT_RDHUP.
But since the two are not the same, there will always be one of the two that fails.
../src/fdevent_impl.c:379:5: note: in expansion of macro ‘ck_static_assert’ 379 | ck_static_assert(EPOLLRDHUP == FDEVENT_RDHUP); | ^~~~~~~~~~~~~~~~ ../src/fdevent_impl.c:857:5: note: in expansion of macro ‘ck_static_assert’ 857 | ck_static_assert(POLLRDHUP == FDEVENT_RDHUP); | ^~~~~~~~~~~~~~~~
bootlin-sparc-uclibc:¶
~/br-test-pkg/bootlin-sparc-uclibc$ grep -r "POLLRDHUP" host/sparc-buildroot-linux-uclibc/sysroot/usr/include host/sparc-buildroot-linux-uclibc/sysroot/usr/include/linux/eventpoll.h:#define EPOLLRDHUP 0x00002000 host/sparc-buildroot-linux-uclibc/sysroot/usr/include/bits/poll.h:# define POLLRDHUP 0x800 host/sparc-buildroot-linux-uclibc/sysroot/usr/include/sys/epoll.h: EPOLLRDHUP = 0x2000, host/sparc-buildroot-linux-uclibc/sysroot/usr/include/sys/epoll.h:#define EPOLLRDHUP EPOLLRDHUP host/sparc-buildroot-linux-uclibc/sysroot/usr/include/asm-generic/poll.h:#ifndef POLLRDHUP host/sparc-buildroot-linux-uclibc/sysroot/usr/include/asm-generic/poll.h:#define POLLRDHUP 0x2000 host/sparc-buildroot-linux-uclibc/sysroot/usr/include/asm/poll.h:#define POLLRDHUP 2048
bootlin-sparc64-glibc:¶
~/br-test-pkg/bootlin-sparc64-glibc$ grep -r "POLLRDHUP" host/sparc64-buildroot-linux-gnu/sysroot/usr/include host/sparc64-buildroot-linux-gnu/sysroot/usr/include/linux/eventpoll.h:#define EPOLLRDHUP (__poll_t)0x00002000 host/sparc64-buildroot-linux-gnu/sysroot/usr/include/bits/poll.h:# define POLLRDHUP 0x800 host/sparc64-buildroot-linux-gnu/sysroot/usr/include/sys/epoll.h: EPOLLRDHUP = 0x2000, host/sparc64-buildroot-linux-gnu/sysroot/usr/include/sys/epoll.h:#define EPOLLRDHUP EPOLLRDHUP host/sparc64-buildroot-linux-gnu/sysroot/usr/include/asm-generic/poll.h:#ifndef POLLRDHUP host/sparc64-buildroot-linux-gnu/sysroot/usr/include/asm-generic/poll.h:#define POLLRDHUP 0x2000 host/sparc64-buildroot-linux-gnu/sysroot/usr/include/asm/poll.h:#define POLLRDHUP 2048
So in short:
#define EPOLLRDHUP 0x2000 #define POLLRDHUP 0x0800
Note that 2048 = 0x0800.
Kr,
Thomas Devoogdt
Updated by gstrauss 8 months ago · Edited
This might work since lighttpd use of lighttpd FDEVENT_RDHUP
checks for flags existing, not exact match.
--- a/src/fdevent.h +++ b/src/fdevent.h @@ -40,6 +40,8 @@ struct fdnode_st { #if (defined(__sun) && defined(__SVR4)) /* Solaris */ \ || defined(__FreeBSD__) #define FDEVENT_RDHUP 0x4000 +#elif (defined(__linux__) && (defined(__sparc__) || defined(__sparc))) +#define FDEVENT_RDHUP 0x2800 /*(0x2000 EPOLLRDHUP | 0x0800 POLLRDHUP)*/ #else #define FDEVENT_RDHUP 0x2000 #endif --- a/src/fdevent_impl.c +++ b/src/fdevent_impl.c @@ -338,6 +338,11 @@ fdevent_linux_sysepoll_event_set (fdevents *ev, fdnode *fdn, int events) struct epoll_event ep; #ifndef EPOLLRDHUP events &= ~FDEVENT_RDHUP; + #elif (defined(__linux__) && (defined(__sparc__) || defined(__sparc))) + if (events & FDEVENT_RDHUP) { + events &= ~FDEVENT_RDHUP; + events |= EPOLLRDHUP; + } #endif ep.events = events | EPOLLERR | EPOLLHUP; ep.data.ptr = fdn; @@ -376,7 +381,11 @@ fdevent_linux_sysepoll_init (fdevents *ev) ck_static_assert(EPOLLERR == FDEVENT_ERR); ck_static_assert(EPOLLHUP == FDEVENT_HUP); #ifdef EPOLLRDHUP + #if (defined(__linux__) && (defined(__sparc__) || defined(__sparc))) + ck_static_assert(EPOLLRDHUP & FDEVENT_RDHUP); + #else ck_static_assert(EPOLLRDHUP == FDEVENT_RDHUP); + #endif #endif ev->type = FDEVENT_HANDLER_LINUX_SYSEPOLL; @@ -770,6 +779,11 @@ fdevent_poll_event_set (fdevents *ev, fdnode *fdn, int events) #ifndef POLLRDHUP events &= ~FDEVENT_RDHUP; + #elif (defined(__linux__) && (defined(__sparc__) || defined(__sparc))) + if (events & FDEVENT_RDHUP) { + events &= ~FDEVENT_RDHUP; + events |= POLLRDHUP; + } #endif if (k >= 0) { @@ -854,7 +868,11 @@ fdevent_poll_init (fdevents *ev) ck_static_assert(POLLHUP == FDEVENT_HUP); ck_static_assert(POLLNVAL == FDEVENT_NVAL); #ifdef POLLRDHUP + #if (defined(__linux__) && (defined(__sparc__) || defined(__sparc))) + ck_static_assert(POLLRDHUP & FDEVENT_RDHUP); + #else ck_static_assert(POLLRDHUP == FDEVENT_RDHUP); + #endif #endif ev->type = FDEVENT_HANDLER_POLL;
Updated by ThomasDevoogdt 8 months ago
- File 0002-core-fix-POLLRDHUP-on-SPARC-fixes-3251.patch 0002-core-fix-POLLRDHUP-on-SPARC-fixes-3251.patch added
Hi,
I can confirm that the build is fixed with this. But I didn't run any real-life tests since I don't have the hardware. For that, we will have to wait until Buildroot folks pick this up for their projects.
Kr,
Thomas
Updated by gstrauss 8 months ago
@ThomasDevoogdt Thank you for testing the build and packaging the patch.
It is likely that only lighttpd epoll (the default lighttpd event handler on Linux) worked in buildroot on Linux on SPARC up until lighttpd 1.4.74 when I changed some runtime asserts to C11 static_assert()
, resulting in the assertion failures you reported above.
Also available in: Atom