Page MenuHomePhabricator

[CMAKE] SYS_getrandom is expected to be linux only
ClosedPublic

Authored by Fabien on Dec 12 2019, 15:40.

Details

Summary

Building with cmake will check that the syscall exist, but the
implementation using it in random.cpp actually rely for it being Linux
only. Tht would cause build failure on non-Linux system that support the
call. Note that autotools is not affected.

A better solution would be to make it non Linux specific, but that will
require to make sure that the behavior is consistent between various OSs
or to handle the differences in random.cpp.

I choose the conservative approach here as it will not prevent from
improving the things later. Some interesting read regarding
getrandom(): https://lwn.net/Articles/800509/

Test Plan

On a recent enough Linux and FreeBSD >= 12.0:

cmake -GNinja -DBUILD_BITCOIN_QT=OFF ..

Check that HAVE_SYS_GETRANDOM is enabled on Linux and not on FreeBSD.

ninja

Check that the build succeeds (requires D4709 for FreeBSD).

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable