Hello, Peyton, Jonathan L, on Mon 04 Apr 2016 22:09:19 +0000, wrote: > Fundamentally, I think _HWLOC_CHECK_DECL()’s macro logic is broken.
It was not, originally :) The problem of AC_CHECK_DECL is that it only checks that a declaration exists (by referencing it as a right-value, not a function). That however doesn't check that we have a proper declaration with full parameters, etc. i.e. something like this: extern int ffsl(); would be counted as proper declaration. The original version of HWLOC_CHECK_DECL (mentioned in the comment) would try to call the function with a lot of parameters, to check whether the compiler detected that it's wrong, so that we catch miscalls at compile-time instead of run-time. This was however changed in 6a9299ce9d1cb1c13b3b346fe6fdfed2df75c672 to add a prototype, and thus detect the conflicting prototypes instead of the miscall. This was done for the case where strict compilation flags are used which would see implicit function declarations as a failure (and thus believe the function is declared). Checking for the conflicting prototypes however failed with clang an icc because they only emit a warning, see commit 447c8b038f57509c822c88cdeacffaeb03042874. In the end these changes completely changed the intent of the macro, and using AC_CHECK_DECL would probably work a lot more. But the intent of the macro still makes sense, and we currently don't implement it any more... The bug here is that that HWLOC_CHECK_DECL assumed that availability of the function was tested before, i.e. > conftest.c(96) : fatal error C1083: Cannot open include file: 'sched.h': No > such file or directory was unexpected. So I'd say to revert to calling the function with a lot of arguments (to get the originally intented detection), but calling AC_CHECK_DECL beforewards to properly check for declaration presence. So we get everything we actually wanted. I'm having a look at the changes for that. samuel