Summary: | <sys/timerfd.h> fails to build in POSIX mode due to namespace pollution | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Jan Beich <jbeich> | ||||||
Component: | kern | Assignee: | Warner Losh <imp> | ||||||
Status: | Closed FIXED | ||||||||
Severity: | Affects Only Me | CC: | dan.kotowski, emaste, jake, jfree, junchoon | ||||||
Priority: | --- | Flags: | jbeich:
mfc-stable14+
|
||||||
Version: | CURRENT | ||||||||
Hardware: | Any | ||||||||
OS: | Any | ||||||||
Attachments: |
|
Description
Jan Beich
![]() ![]() Created attachment 244372 [details]
Drop <sys/proc.h> via forward declaration
Tested by:
$ echo 'int main() {}' | cc -xc - -o/dev/null -include sys/sys/timerfd.h
$ echo 'int main() {}' | cc -xc - -o/dev/null -D_KERNEL -include sys/sys/timerfd.h
Created attachment 244373 [details]
Drop <sys/proc.h> via forward declaration
This is addressed in https://reviews.freebsd.org/D41600 Both attachment 244373 [details] and review D41600?id=126574 are not self-sufficient: $ cat a.c #include <sys/timerfd.h> int main() { timerfd_create(CLOCK_MONOTONIC, 0); return 0; } $ cc a.c a.c:2:29: error: use of undeclared identifier 'CLOCK_MONOTONIC' int main() { timerfd_create(CLOCK_MONOTONIC, 0); return 0; } ^ 1 error generated. as found via www/chromium ../../third_party/wayland/src/src/event-loop.c:318:28: error: use of undeclared identifier 'CLOCK_MONOTONIC' timer_fd = timerfd_create(CLOCK_MONOTONIC, ^ ../../third_party/wayland/src/src/event-loop.c:495:2: warning: call to undeclared function 'clock_gettime'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] clock_gettime(CLOCK_MONOTONIC, &now); ^ ../../third_party/wayland/src/src/event-loop.c:495:16: error: use of undeclared identifier 'CLOCK_MONOTONIC' clock_gettime(CLOCK_MONOTONIC, &now); ^ ../../third_party/wayland/src/src/event-loop.c:620:3: warning: call to undeclared function 'clock_gettime'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] clock_gettime(CLOCK_MONOTONIC, &deadline); ^ ../../third_party/wayland/src/src/event-loop.c:620:17: error: use of undeclared identifier 'CLOCK_MONOTONIC' clock_gettime(CLOCK_MONOTONIC, &deadline); ^ Note, clock_gettime() is also affected due to namespace pollution in glibc/musl where <sys/timerfd.h> includes <time.h>. On FreeBSD clock_gettime() was provided via <sys/proc.h> -> <sys/time.h>. (In reply to Jan Beich from comment #4) Based on some simple testing, it looks like we can just follow glib/musl's lead and include sys/time.h? (In reply to Jake Freeland from comment #5) Oops, I misread your comment. glib/musl includes time.h, not sys/time.h, in timerfd.h. I am getting successful compilation when including sys/time.h in timerfd.h. (In reply to Jake Freeland from comment #6) > I am getting successful compilation when including sys/time.h in timerfd.h. Maybe also drop <sys/timespec.h> as it's already included by <sys/time.h>. (In reply to Jan Beich from comment #7) Of course:) Does chromium successfully compile with this change? I just tested using this example: #include <sys/timerfd.h> int main() { timerfd_create(CLOCK_MONOTONIC, 0); return 0; } I'm setting up a chromium compile now, but if you can do verify easier, I will stop it. (In reply to Jake Freeland from comment #8) Chromium successfully compiled with this change. I'll update review D41600 to include sys/time.h in timerfd.h. Thanks for reporting this, Jan. *** Bug 273500 has been marked as a duplicate of this bug. *** Landed in base fb5daae920ba but no MFC yet to stable/14 and releng/14.0. (In reply to Jan Beich from comment #11) Monday. There are several changes and I want to make sure I get them all. Thanks for heads up. Now in stable/14 per base 8bcf9a87c79d but not yet in releng/14.0 (unlike other timerfd fixes). The latter is important for downstream CI e.g., https://github.com/emersion/mako/blob/master/.builds/freebsd.yml https://github.com/emersion/xdg-desktop-portal-wlr/blob/master/.builds/freebsd.yml Doh. I thought I got them all. Will triple check today. I've been fuzzy all week with an illness... I thought I'd returned to clear thinking yesterday... I'll try again today. I thought the delay was just because waiting for re@'s approval. Confirmed everything MFC'ed to stable/14 are now MFS'ed to releng/14, just before BRANCH is bumpet to BETA4. Thanks! If I'm not missing anything (looking for open PR and differential revision containing "timerfd"), these were all that pending in base side. (In reply to Tomoaki AOKI from comment #15) See comment 3. D41600 was later split into series (Stack in Phabricator): D41600 + D41640 + D41641. Of those D41600 and D41640 are now on releng/14.0 but D41641 is still missing. $ git log origin/releng/14.0 sys/sys/timerfd.h or $ git log -E --grep=D41641\|fb5daae920ba\|8bcf9a87c79d origin/releng/14.0 Yea. My method to pick all the hunks of timerfd fixes missed one. I've been sick, and was also rushing a little to get things in before the BETA4 deadline. This will be in rc1 or beta5, whatever the next one is called. Ah, sorry. I've overlooked 1 of 6 MFCs. base 8bcf9a87c79d on stable/14 is missing on releng/14.0 (Not MFS'ed). Maybe this is essential for ports maintainers. Everything I've picked up before appears (including quotes) on freebsd-stable ML [1]. As this post was before some of differential revisions landed into main, some appears as D* numbers. [1] https://lists.freebsd.org/archives/freebsd-stable/2023-September/001461.html I've landed the last one in releng/14.0 with 7454117918cd9f7900d92513a7a4e3ed361987bc If someone can confirm this fixes the issue, I'll close the bug I confirm, created 14.0 poudriere jail and tested x11/mako build without the workaround. |