Skip to content
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

build(macos/other): librt is not needed #24

Open
wants to merge 1 commit into
base: mariadb-4.x
Choose a base branch
from

Conversation

sitano
Copy link

@sitano sitano commented Aug 25, 2024

Follow up to #20

Since glibc >= 2.17 (2012-12-25), librt is a stub-only library. (https://abi-laboratory.pro/?view=changelog&l=glibc&v=2.17)

  • The clock_* suite of functions (declared in <time.h>) is now available directly in the main C library. Previously it was necessary to link with -lrt to use these functions. This change has the effect that a single-threaded program that uses a function such as clock_gettime (and is not linked with -lrt) will no longer implicitly load the pthreads library at runtime and so will not suffer the overheads associated with multi-thread support in other code such as the C++ runtime library.

Current version on Arch Linux is 2.40.

Build results: https://buildbot.mariadb.org/#/grid?branch=refs%2Fpull%2F24%2Fmerge

@sitano
Copy link
Author

sitano commented Aug 25, 2024

As it can be seen at least Debian 10, 11, and Ubuntu 20.04 still provide some functions in librt such as timer_create() that is used from check_get_clockid() at libcheck_pic.a(check.o).

@sitano sitano marked this pull request as draft August 25, 2024 19:34
@sitano
Copy link
Author

sitano commented Aug 25, 2024

The solution could be to include rt lib if timer_create is not found in libc for example, or just exclude it for DARWIN builds.

@sitano
Copy link
Author

sitano commented Aug 25, 2024

@grooverdan wdyt?

@sitano sitano marked this pull request as ready for review August 27, 2024 08:22
@sitano
Copy link
Author

sitano commented Aug 27, 2024

I think the patch is relatively good. I hope CI builders do build tests :D.
The solution is - lazy link rt lib if it is present in the system for tests that use libcheck.
Can you guys pls restart 2 failed builders due to git tls hs

[gal-s390x-ubuntu-2204](https://buildbot.mariadb.org/#/builders/366)	[failed update (failure)](https://buildbot.mariadb.org/#/builders/366/builds/506)
[gal-s390x-ubuntu-2404](https://buildbot.mariadb.org/#/builders/669)	[failed update (failure)](https://buildbot.mariadb.org/#/builders/669/builds/23)

or maybe give me a permission to press button Rebuild for failed workers? (@grooverdan)

@grooverdan
Copy link
Member

Sorry for delay. CMake can do checks. What do you think of this:

CHECK_LIBRARY_EXISTS(rt timer_create "" HAVE_TIMER_CREATE)
IF (HAVE_TIMER_CREATE)
  LIST(APPEND GALERA_UNIT_TEST_LIBS rt)
ENDIF(HAVE_TIMER_CREATE)

@sitano
Copy link
Author

sitano commented Aug 27, 2024

@grooverdan I am up for it. What if there will be another function besides timer_create that will be needed from librt and we miss it? If you think it is relatively safe I can replace it easily with your version. What would you say?

@grooverdan
Copy link
Member

timer_delete was the only other symbol missing in the link. I assume both where moved at the same time and are now gone. Single symbol test is fine.

I can't easily grant rebuild access so I triggered those.

Since glibc >=2.17 (2012-12-25), librt is a stub-only library.
(https://abi-laboratory.pro/?view=changelog&l=glibc&v=2.17)

* The `clock_*' suite of functions (declared in <time.h>) is now available
  directly in the main C library.  Previously it was necessary to link with
  -lrt to use these functions.  This change has the effect that a
  single-threaded program that uses a function such as `clock_gettime' (and
  is not linked with -lrt) will no longer implicitly load the pthreads
  library at runtime and so will not suffer the overheads associated with
  multi-thread support in other code such as the C++ runtime library.

Current version on Arch Linux is 2.40.

It is however is required for Debian 10, 11 and Ubuntu 20.04.

Signed-off-by: Ivan Prisyazhnyy <[email protected]>
@sitano
Copy link
Author

sitano commented Aug 28, 2024

Ok, changed to CHECK_LIBRARY_EXISTS(rt timer_create "" HAVE_TIMER_CREATE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants