-
Notifications
You must be signed in to change notification settings - Fork 34
build: link libfastjson against libm for modf() #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
glibc-2.42 changed modf causing IFUNC modf() resolution to fail at runtime in rsyslog due to missing direct link against libm. Adding -lm to Libs ensures the shared library has a DT_NEEDED entry for libm.
|
See also: https://bugs.gentoo.org/961289 Thanks for the patch! |
|
Thanks! |
|
@Whissi : adding It makes sure software linking against libfastjson and using pkg-config will get a |
|
On systems with We observed exactly this behavior with Is there agreement on this point? This PR ensures that any build system using Now, reading your message, I wonder whether the “proper” fix might actually be to have instead of current output Is that what you meant? |
Your commit message says: What you repeated above is basically what I said, which is my point. The commit message is incorrect/misleading and I wanted to clear up the confusion. Also, rsyslog already has a NEEDED entry on libm: This comes in via https://github.com/rsyslog/rsyslog/blob/main/runtime/Makefile.am#L123 afaics (-lm was added 4 years ago). And yes, I think the PR should be changed as follows:
|
Unless statically linking is not something that libfastjson wants to support. |
And a new upstream release with these changes would make sense. |
Pull Request rsyslog#167 modified libfastjson.pc to add an explicit dependency on -lm through pkg-config. While this worked around missing modf() resolution under glibc ≥ 2.42, it pushed the responsibility onto applications. The correct solution is for libfastjson itself to link against libm so that dependent applications do not need to adjust their linker flags. This commit removes the pkg-config modifications introduced by commit 919f7d2.
glibc ≥ 2.42 no longer provides modf() through implicit linkage, so any library using modf() must explicitly link libm. The previous approach conditionally added -lm only if isnan() failed to link, which is no longer sufficient and did not guarantee that libfastjson itself linked against libm. Replace the isnan-based conditional check with an explicit AC_CHECK_LIB([m], [modf]) so that -lm is always added when required. This ensures libfastjson links directly against libm, allowing dependent applications to link only against libfastjson without needing to add -lm themselves. Fixes: rsyslog#167
|
Many thanks for your feedback! I created #171 to correct the fix. I would appreciate your review on this. |
After upgrading to glibc-2.42, I noticed a runtime error in rsyslogd:
This is due to changed modf implementation in glibc-2.42 causing IFUNC modf() resolution to fail at runtime in rsyslog due to missing direct link against libm.
Adding
-lmto Libs ensures the shared library has a DT_NEEDED entry for libm.