Skip to content

Commit 722afb4

Browse files
committed
libstdc++: Do not check getentropy and arc4random for cross builds
The "getentropy" and "arc4random" check may not yield a correct result for the cross compile builds because linking is often not available for them and the C library headers (notoriously, newlib) may still declare these function prototypes even if they are not actually part of the final library -- for this reason, this commit disables the "getentropy" and "arc4random" checks for non-native builds. This effectively prevents the std::random_device from making use of these functions when `--with-newlib` is specified, which is indeed a correct behaviour because the newlib does not provide a default stub for the "getentropy" function (also note that the newlib "arc4random" implementation internally calls the missing "getentropy" function). For other C libraries, the `GLIBCXX_CROSSCONFIG` function may hard-code the availability of these functions by manually defining `HAVE_GETENTROPY` and `HAVE_ARC4RANDOM`, or by calling the `GLIBCXX_CHECK_GETENTROPY` and `GLIBCXX_CHECK_ARC4RANDOM` functions. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 27eef47 commit 722afb4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libstdc++-v3/configure.ac

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ if $GLIBCXX_IS_NATIVE; then
269269
# For /dev/random and /dev/urandom for std::random_device.
270270
GLIBCXX_CHECK_DEV_RANDOM
271271

272+
# Check for other random number APIs
273+
GLIBCXX_CHECK_GETENTROPY
274+
GLIBCXX_CHECK_ARC4RANDOM
275+
272276
# For TLS support.
273277
GCC_CHECK_TLS
274278

@@ -474,10 +478,6 @@ GLIBCXX_CHECK_X86_RDRAND
474478
# Check if assembler supports rdseed opcode.
475479
GLIBCXX_CHECK_X86_RDSEED
476480

477-
# Check for other random number APIs
478-
GLIBCXX_CHECK_GETENTROPY
479-
GLIBCXX_CHECK_ARC4RANDOM
480-
481481
# This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
482482
GLIBCXX_CONFIGURE_TESTSUITE
483483

0 commit comments

Comments
 (0)