Skip to content

configure: check if "-lrt" is required for using the Dasynq timers - #588

Merged
mobin-2008 merged 2 commits into
davmac314:masterfrom
mobin-2008:configure_librt_check
Oct 14, 2026
Merged

mobin-2008 merged 2 commits into
davmac314:masterfrom
mobin-2008:configure_librt_check

Conversation

@mobin-2008

@mobin-2008 mobin-2008 commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses #551 and also includes a fix for linker flags ordering issue that was found when testing it with Ubuntu 21.04.

Tested on an Ubuntu 21.04 VM with CPPFLAGS="-DDASYNQ_HAVE_EPOLL=0" ./configure (does require linking with librt) and my Artix (does not require linking with librt).

Specify the linker flags at the end of the compiler driver invocation
in try_link_object(), like how Makefiles do.

The ordering of compiler driver flags is important, for example if the
linker is invoked with '--as-needed' flag, it would discard any library
that doesn't satisfiy a non-weak symbol at the time of being loaded and
because 'configure' specified linker flags (and potentially libraries)
before the object, it would make the linker discard the specified
library, leading to false "undefined symbols" when the linker tries to
link the object. See ld(1) for more information.

@davmac314 davmac314 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is pretty good. I do have some minor comments.

Comment thread configure
Comment on lines +260 to +261
t1.add_timer(l1);
l1.run();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness this really should arm the timer also (arm_timer_rel(l1, {1,0}); or similar).

Comment thread configure Outdated
if [ "$AUTO_LDFLAGS_BASE" = true ] && [ "$PLATFORM" = FreeBSD ]; then
check_link_argument LDFLAGS_BASE -lrt
if [ "$AUTO_LDFLAGS_BASE" = true ]; then
info "Checking whether using timers require linking with librt to work..."

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to work" is redundant, and "require" should be "requires".

I actually think:
"Checking whether linking with librt is required"
... would be better. No real need to mention timers here; that's really just an implementation detail, and explicitly mentioning timers sort of implies that maybe it would be possible to build without support for timers.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer "Checking whether linking with librt is required".

Comment thread configure Outdated
Comment on lines +672 to +675
# Account for the CPPFLAGS in this check. Unlike the other checks, this one uses the Dasynq
# library which can be configured with a number of macro definitions. For example, an user
# under Linux may specify "-DDASYNQ_HAVE_EPOLL=0" to disable usage of epoll system calls which
# also makes Dasynq use POSIX timers instead of timerfd, potentially changing the test result.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: good comment in that it is explanatory and useful, but it is quite verbose. You could probably trim this down to the essential details, i.e. Dasynq can be configured by compile-time macros, which can influence the result of this test.

You can leave mostly as-is if you prefer, but in that case it's "a user" not "an user" and "disable usage of the epoll system call" not "disable usage of epoll system calls".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: good comment in that it is explanatory and useful, but it is quite verbose. You could probably trim this down to the essential details, i.e. Dasynq can be configured by compile-time macros, which can influence the result of this test.

This essential part of this is the Account for the CPPFLAGS in this check. Unlike the other checks, this one uses the Dasynq library which can be configured with a number of macro definitions. and the rest is just an example of how this affects this test. I'm going to reorder it a little bit to make the essential part complete without reading the example (i.e. moving potentially changing the test result. to the essential part.)

You can leave mostly as-is if you prefer, but in that case it's "a user" not "an user" and "disable usage of the epoll system call" not "disable usage of epoll system calls".

Fixed.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This essential part of this is the Account for the CPPFLAGS in this check. Unlike the other checks,

The details I pointed out in my comment are what I believe to to be the essential part.

"Account for the CPPFLAGS in this check" is just something that the line below is doing. It should be something more like "CPPFLAGS is included in the following check, because ..." if this is important.

"Unlike the other checks" is just extraneous - you don't need to say it.

@mobin-2008 mobin-2008 Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've trimmed it down a little bit.

@mobin-2008
mobin-2008 force-pushed the configure_librt_check branch from 4a8d76f to 33f13a8 Compare October 13, 2026 19:43
Comment thread configure Outdated
Comment on lines +675 to +676
# a user under Linux may specify "-DDASYNQ_HAVE_EPOLL=0" to disable usage of the epoll system
# calls and make Dasynq use POSIX timers instead of timerfd.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable usage of the epoll system calls

As I said in the previous review, it's "disable usage of the epoll system call". It's an interface, singular - call, not calls.

This would be better, IMO:
"... to disable the epoll backend, which currently also causes Dasynq to use POSIX timers."

But at least fix "calls" to "call" as I already pointed that out, please. The rest looks ok.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I used the string in the Dasynq config.h (If the epoll family of system calls are available:) which says family of and I only saw the the in your requested change.

Anyway, changed to your suggestion.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the string in the Dasynq config.h

You're right actually that it is a set of calls, that slipped my mind. Still, keeping "family of" would have been more clear. (I think what it is now is better though).

Check if using a Dasynq timer in a test program requires linking with
librt, then supply "-lrt" in the LDFLGAS_BASE of the build if it does.

Perviously 'configure' only added the "-lrt" flag for the FreeBSD,
which was known for requiring it.
@mobin-2008
mobin-2008 force-pushed the configure_librt_check branch from 33f13a8 to 8062e5b Compare October 13, 2026 22:31
@mobin-2008
mobin-2008 merged commit f621bad into davmac314:master Oct 14, 2026
7 checks passed
@mobin-2008
mobin-2008 deleted the configure_librt_check branch October 14, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants