Merge #20594: Fix getauxval calls in randomenv.cpp

836a3dc02c72f917db5be386b9b4787a59d48610 Avoid weak-linked getauxval support on non-linux platforms (like macOS) (Jonas Schnelli)
41a413b31746cc749f3c64ed8070cea9cc6cfdbe Define correct symbols for getauxval (Jonas Schnelli)

Pull request description:

  PR #20358 made use of the two preprocessor symbols `HAVE_STRONG_GETAUXVAL` as well as `HAVE_WEAK_GETAUXVAL`.

  These symbols have not been defined in configure.ac. They where only passed selective as CRC32 CPPFLAGS in https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.crc32c.include#L16.

  PR #20358 would have broken the macOS build since `getauxval` is not supported on macOS (but weak-linking does pass).

  This PR defines the two symbols correctly and reduces calls to `getauxval` to linux.

ACKs for top commit:
  laanwj:
    Code review ACK 836a3dc02c72f917db5be386b9b4787a59d48610
  jonatack:
    utACK 836a3dc02c72f917db5be386b9b4787a59d48610

Tree-SHA512: 6527f4a617b937f4c368a3cb1c162f1ac38a6f5e6341295554961eaf322906e9b27398a6f7b00819854ceebb5c828d3e6ce0a779edd769adc4053ce8beda3739
This commit is contained in:
Wladimir J. van der Laan 2020-12-14 21:00:49 +01:00 committed by pasta
parent 0cb3dd5b87
commit 81f6dd86b7

View File

@ -1050,18 +1050,20 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
]], [[ ]], [[
getauxval(AT_HWCAP); getauxval(AT_HWCAP);
]])], ]])],
[ AC_MSG_RESULT(yes); HAVE_STRONG_GETAUXVAL=1 ], [ AC_MSG_RESULT(yes); HAVE_STRONG_GETAUXVAL=1; AC_DEFINE(HAVE_STRONG_GETAUXVAL, 1, [Define this symbol to build code that uses getauxval)]) ],
[ AC_MSG_RESULT(no); HAVE_STRONG_GETAUXVAL=0 ] [ AC_MSG_RESULT(no); HAVE_STRONG_GETAUXVAL=0 ]
) )
AC_MSG_CHECKING(for weak getauxval support in the compiler) AC_MSG_CHECKING(for weak getauxval support in the compiler)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef __linux__
unsigned long getauxval(unsigned long type) __attribute__((weak)); unsigned long getauxval(unsigned long type) __attribute__((weak));
#define AT_HWCAP 16 #define AT_HWCAP 16
#endif
]], [[ ]], [[
getauxval(AT_HWCAP); getauxval(AT_HWCAP);
]])], ]])],
[ AC_MSG_RESULT(yes); HAVE_WEAK_GETAUXVAL=1 ], [ AC_MSG_RESULT(yes); HAVE_WEAK_GETAUXVAL=1; AC_DEFINE(HAVE_WEAK_GETAUXVAL, 1, [Define this symbol to build code that uses getauxval (weak linking)]) ],
[ AC_MSG_RESULT(no); HAVE_WEAK_GETAUXVAL=0 ] [ AC_MSG_RESULT(no); HAVE_WEAK_GETAUXVAL=0 ]
) )