HomePhabricator

[CMAKE] SYS_getrandom is expected to be linux only

Description

[CMAKE] SYS_getrandom is expected to be linux only

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).

Reviewers: #bitcoin_abc, deadalnix, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D4710

Details

Provenance
FabienAuthored on Dec 12 2019, 15:18
FabienPushed on Dec 13 2019, 07:51
Reviewer
Restricted Project
Differential Revision
D4710: [CMAKE] SYS_getrandom is expected to be linux only
Parents
rSTAGING53070e930d56: [CMAKE] Fix FindBerkeleyDB for FreeBSD
Branches
Unknown
Tags
Unknown