configure: also check for clockgettime()#9
Conversation
|
I just forgot a little nit in the previous iteration, so I just repushed a fixed patch. |
|
Hi @yann-morin-1998, thank you very much for your PR! I'll leave some review comments inline. Best regards, |
| [needs_rt="yes"], | ||
| AC_MSG_ERROR(cannot find nanosleep))) | ||
| AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes") | ||
| AC_CHECK_FUNCS(clock_gettime, [], |
There was a problem hiding this comment.
Can you do the same once more for nanosleep()? I have the feeling that clock_gettime() might need librt more often than nanosleep(), leading to compilation errors on systems where only nanosleep() needs the lib.
There was a problem hiding this comment.
Can you change this to AC_CHECK_FUNC() (no trailing 'S') please? IIrc the generated shell code for checking multiple functions is quite substantial.
There was a problem hiding this comment.
Hello, thanks for the feedback! :-)
So far, I just duplicated the nanosleep() case to test for clock_gettime().
However, now that I re-read the autoconf manual, here's what I see:
If the functions might be in libraries other than the default C
library, first call AC_CHECK_LIB for those libraries.
So, to me, we are doing it backwards. We should probably just use
AC_SEARCH_LIBS() and leave it to autoconf to properly add -lrt to
LIBS if needed. Something like:
AC_SEARCH_LIBS([nanosleep],[rt],,[AC_MSG_ERROR([cannot find nanosleep])])
AC_SEARCH_LIBS([clock_gettime],[rt],,[AC_MSG_ERROR([cannot find nanosleep])])
And then get rid of the AM_CONDITIONAL() stuff, since LIBS will
contain -lrt if needed by either.
Thoughts?
clock_gettime() is also in -lrt so we also need to check for it. Use AC_SEARCH_LIBS() instead of our canned combo of AC_CHECK_FUNC() + AC_CHECK_LIB(). AC_SEARCH_LIBS() will automatically add the necessary -l flags to the LIBS variable, so we don't need out AM_CONDITIONAL() construct either, now. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
|
I've re-pushed the commit using In my test-case (fixing http://autobuild.buildroot.org/results/6a9/6a9b4d7b1b3cd72e32579fbaf5a69dbde0fea8e4/), it works as Regards, |
|
Thanks Yann! Let's see if this is doing the right thing – it might be that this will now also link liboping with librt (in addition to the oping and noping binaries). I'll worry about that when someone complaints though ;) Best regards, |
clock_gettime() is also in -lrt so we also need to check for it.
Signed-off-by: "Yann E. MORIN" yann.morin.1998@free.fr