libressl/portable

cmake: prefer check_symbol_exists() over check_function_exists()

Closed this issue · 0 comments

The Android CI started failing because check_function_exists() detected that pipe2 was available, but then it errored out because unistd.h doesn't contain a prototype:

/home/runner/work/portable/portable/tests/tlstest.c:244:6: error: call to undeclared function 'pipe2'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  244 |         if (pipe2(cfds, O_NONBLOCK) == -1)
      |             ^

The check_function_exists() documentation calls out this trap.

Note

Prefer using CheckSymbolExists instead of this module, for the following reasons:

check_function_exists() can't detect functions that are inlined in headers or specified as a macro.

check_function_exists() can't detect anything in the 32-bit versions of the Win32 API, because of a mismatch in calling conventions.

check_function_exists() only verifies linking, it does not verify that the function is declared in system headers.

I pushed a fix for the specific issue with pipe2(), but I suspect that we should change all function detections to check_symbol_exists().