Repository navigation
HAVE_POLL_FINE is always false when cross-compiling with CMake #14714
Description
Activity
The check for this actually builds and runs code to verify poll() and that cannot be done for cross-compiles. Thus, it guesses.
Maybe this should rather guess on it working, if not using Apple OS.
One option is to hard-wire known results for (cross-)compilation targets (like done for Apple).
One other is to explicitly pass-DHAVE_POLL_FINE=ON/OFFto CMake override the default for specific builds.In ./configure this detection is reserved for cross-builds as well.
Classically, you'd double-check the config.h file after configure has run so that it figured out things correctly. For cross-compiles especially, as it has more limited checks due to not being able to run code for checks.
So cmake/configure needs to use a use a default for such checks. Probably going with the safe one.
Maybe this should rather guess on it working, if not using Apple OS.
That seem a reasonable solution to me. I would say that there are more platforms with a working
poll()than platforms with a broken one, but I think I should not speculate about this.Either way, I think it would be cool to have an entry about this behavior in the Known Bugs section; something like "
poll()cannot be detected properly in some environments" sounds fine.it would be cool to have an entry about this behavior in the Known Bugs section
It's not really a bug, it's a known limitation. And this is not unique for curl, this is how cross-compiling works for just about everyone. There several more checks that cannot be done for cross-builds.
Ideally we should have these documented, but it might be tricky.
Reacted by KartatzWould it help to fall back to a non-runtime detection for cross-builds, like?:
#if <UNIX> && defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L /* has native poll() */ #endif
Yeah, that's probably a decent guess.
- added a commit that references this issue
on Aug 29, 2024 Does #14734 make poll() detected in your cross-build?
Yes, it's correctly detected. Thanks!
Reacted by Viktor Szakats- added a commit that references this issue
on Aug 30, 2024
I did this
I was having a weird issue when using the multi interface where the
curl_multi_poll()call occasionally returnsCURLM_UNRECOVERABLE_POLL.The thing is, this issue was only reproducible in cross-compiled binaries. After a bit of investigation around
Curl_poll(), I found that this is caused by the lack of theHAVE_POLL_FINEdefine in these builds.Looking at CMake/OtherTests.cmake I see that there is indeed a check for
HAVE_POLL_FINEinside aif (NOT CMAKE_CROSSCOMPILING)condition.Removing the
NOT CMAKE_CROSSCOMPILINGcheck and replacingcheck_c_source_runs()withcheck_c_source_compiles()fixes this.I expected the following
Properly detection of
HAVE_POLL_FINE.curl/libcurl version
libcurl/8.10.0-DEV BearSSL nghttp2/1.61.0
operating system
Linux rhel 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux