Skip to content

Commit 7f81f54

Browse files
committed
Merge bitcoin/bitcoin#23082: build: improve gexauxval() detection, remove getauxval() weak linking
4446ef0 build: remove support for weak linking getauxval() (fanquake) e56100c build: remove arm includes from getauxval() check (fanquake) Pull request description: It was [pointed out in #23030](bitcoin/bitcoin#23030 (comment)) that we might be able to get rid of our weak linking of [`getauxval()`](https://man7.org/linux/man-pages/man3/getauxval.3.html) (`HAVE_WEAK_GETAUXVAL`) entirely, with only Android being a potential holdout: > I wonder if it's time to get rid of HAVE_WEAK_GETAUXVAL. I think it's confusing. Either we build against a C library that has this functionality, or not. We don't do this weak linking thing for any other symbols and recently got rid of the other glibc backwards compatibility stuff. > Unless there is still a current platform that really needs it (Android?), I'd prefer to remove it from the build system, it has caused enough issues. After looking at Android further, it would seem that given we are moving to using `std::filesystem`, which [requires NDK version 22 and later](https://github.com/android/ndk/wiki/Changelog-r22), and `getauxval` has been available in the since [API version 18](https://developer.android.com/ndk/guides/cpu-features#features_using_libcs_getauxval3), that shouldn't really be an issue. Support for API levels < 19 will be dropped with the NDK 24 release, and according to [one website](https://apilevels.com/), supporting API level 18+ will cover ~99% of devices. Note that in the CI we currently build with NDK version 22 and API level 28. The other change in this PR is removing the include of headers for ARM intrinsics, from the check for strong `getauxval()` support in configure, as they shouldn't be needed. Including these headers also meant that the check would basically only succeed when building for ARM. This would be an issue if we remove weak linking, as we wouldn't detect `getauxval()` as supported on other platforms. Note that we also use `getauxval()` in our RNG when it's available. I've checked that with these changes we detect support for strong `getauxval()` on Alpine (muslibc). On Linux, previously we'd be detecting support for weak getauxval(), now we detect strong support. Note that we already require glibc 2.17, and `getauxval()` was introduced in `2.16`. This is an alternative / supersedes #23030. ACKs for top commit: laanwj: Code review and tested ACK 4446ef0 Tree-SHA512: 5f2a9e9cc2d63bddab73f0dcb169d4d6beda74622af82bc0439722f1189f81d052e2fc1eaf27056a7a606320d5ddc4c11075f0d051dd93d77c5e1c15337f354a
2 parents bd40cd8 + 4446ef0 commit 7f81f54

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

configure.ac

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xmmintrin.h>]], [[
12101210

12111211
AC_MSG_CHECKING(for strong getauxval support in the system headers)
12121212
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1213-
#include <arm_acle.h>
1214-
#include <arm_neon.h>
12151213
#include <sys/auxv.h>
12161214
]], [[
12171215
getauxval(AT_HWCAP);
@@ -1220,19 +1218,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
12201218
[ AC_MSG_RESULT(no); HAVE_STRONG_GETAUXVAL=0 ]
12211219
)
12221220

1223-
AC_MSG_CHECKING(for weak getauxval support in the compiler)
1224-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1225-
#ifdef __linux__
1226-
unsigned long getauxval(unsigned long type) __attribute__((weak));
1227-
#define AT_HWCAP 16
1228-
#endif
1229-
]], [[
1230-
getauxval(AT_HWCAP);
1231-
]])],
1232-
[ 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)]) ],
1233-
[ AC_MSG_RESULT(no); HAVE_WEAK_GETAUXVAL=0 ]
1234-
)
1235-
12361221
have_any_system=no
12371222
AC_MSG_CHECKING([for std::system])
12381223
AC_LINK_IFELSE(
@@ -1878,7 +1863,6 @@ AC_SUBST(HAVE_O_CLOEXEC)
18781863
AC_SUBST(HAVE_BUILTIN_PREFETCH)
18791864
AC_SUBST(HAVE_MM_PREFETCH)
18801865
AC_SUBST(HAVE_STRONG_GETAUXVAL)
1881-
AC_SUBST(HAVE_WEAK_GETAUXVAL)
18821866
AC_SUBST(ANDROID_ARCH)
18831867
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
18841868
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])

src/Makefile.crc32c.include

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CRC32C_CPPFLAGS_INT += -I$(srcdir)/crc32c/include
1414
CRC32C_CPPFLAGS_INT += -DHAVE_BUILTIN_PREFETCH=@HAVE_BUILTIN_PREFETCH@
1515
CRC32C_CPPFLAGS_INT += -DHAVE_MM_PREFETCH=@HAVE_MM_PREFETCH@
1616
CRC32C_CPPFLAGS_INT += -DHAVE_STRONG_GETAUXVAL=@HAVE_STRONG_GETAUXVAL@
17-
CRC32C_CPPFLAGS_INT += -DHAVE_WEAK_GETAUXVAL=@HAVE_WEAK_GETAUXVAL@
1817
CRC32C_CPPFLAGS_INT += -DCRC32C_TESTS_BUILT_WITH_GLOG=0
1918

2019
if ENABLE_SSE42

src/randomenv.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#include <sys/vmmeter.h>
5454
#endif
5555
#endif
56-
#if defined(HAVE_STRONG_GETAUXVAL) || defined(HAVE_WEAK_GETAUXVAL)
56+
#if defined(HAVE_STRONG_GETAUXVAL)
5757
#include <sys/auxv.h>
5858
#endif
5959

@@ -326,7 +326,7 @@ void RandAddStaticEnv(CSHA512& hasher)
326326
// Bitcoin client version
327327
hasher << CLIENT_VERSION;
328328

329-
#if defined(HAVE_STRONG_GETAUXVAL) || defined(HAVE_WEAK_GETAUXVAL)
329+
#if defined(HAVE_STRONG_GETAUXVAL)
330330
// Information available through getauxval()
331331
# ifdef AT_HWCAP
332332
hasher << getauxval(AT_HWCAP);
@@ -346,7 +346,7 @@ void RandAddStaticEnv(CSHA512& hasher)
346346
const char* exec_str = (const char*)getauxval(AT_EXECFN);
347347
if (exec_str) hasher.Write((const unsigned char*)exec_str, strlen(exec_str) + 1);
348348
# endif
349-
#endif // HAVE_STRONG_GETAUXVAL || HAVE_WEAK_GETAUXVAL
349+
#endif // HAVE_STRONG_GETAUXVAL
350350

351351
#ifdef HAVE_GETCPUID
352352
AddAllCPUID(hasher);

0 commit comments

Comments
 (0)