build: improve gexauxval() detection, remove getauxval() weak linking #23082

pull fanquake wants to merge 2 commits into bitcoin:master from fanquake:remove_weak_auxval changing 3 files +3 −20
  1. fanquake commented at 7:42 AM on September 24, 2021: member

    It was pointed out in [#23030](/bitcoin-bitcoin/23030/) that we might be able to get rid of our weak linking of getauxval() (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, and getauxval has been available in the since API version 18, 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, 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.

  2. build: remove arm includes from getauxval() check
    Then the check will work on platforms other than ARM.
    e56100c5b4
  3. build: remove support for weak linking getauxval()
    It was [pointed out in #23030](https://github.com/bitcoin/bitcoin/pull/23030#issuecomment-922893367) 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.
    4446ef0a54
  4. fanquake added the label Build system on Sep 24, 2021
  5. fanquake added the label DrahtBot Guix build requested on Sep 24, 2021
  6. fanquake requested review from laanwj on Sep 24, 2021
  7. laanwj commented at 10:20 AM on September 24, 2021: member

    Going to test on some architectures—

    checking for strong getauxval support in the system headers

    • :heavy_check_mark: Ubuntu 20.04 x86_64-linux-gnu yes
    • :heavy_check_mark: Debian Sid riscv64-linux-gnu yes
    • :heavy_check_mark: FreeBSD x86_64 no (freebsd doesn't have this mechanism)
    • :heavy_check_mark: Fedora Rawhide riscv64-linux-gnu yes

    Output from GUIX log:

    checking host system type... x86_64-pc-linux-gnu
    checking for strong getauxval support in the system headers... yes
    checking host system type... arm-unknown-linux-gnueabihf
    checking for strong getauxval support in the system headers... yes
    checking host system type... aarch64-unknown-linux-gnu
    checking for strong getauxval support in the system headers... yes
    checking host system type... riscv64-unknown-linux-gnu
    checking for strong getauxval support in the system headers... yes
    checking host system type... powerpc64-unknown-linux-gnu
    checking for strong getauxval support in the system headers... yes
    checking host system type... powerpc64le-unknown-linux-gnu
    checking for strong getauxval support in the system headers... yes
    checking host system type... x86_64-w64-mingw32
    checking for strong getauxval support in the system headers... no
    checking host system type... x86_64-apple-darwin19
    checking for strong getauxval support in the system headers... no
    

    All as expected.

  8. in configure.ac:1211 in 4446ef0a54
    1209 | @@ -1210,8 +1210,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xmmintrin.h>]], [[
    1210 |  
    1211 |  AC_MSG_CHECKING(for strong getauxval support in the system headers)
    


    laanwj commented at 10:21 AM on September 24, 2021:

    just remove 'strong' here imo, there's no 'weak' to contrast it against anymore


    laanwj commented at 11:07 AM on September 27, 2021:

    Although we can't rename the define - it's used by the crc32c library after all. Maybe better to leave it as is I dunno,


    fanquake commented at 6:55 AM on September 28, 2021:

    Although we can't rename the define - it's used by the crc32c library after all.

    Yes if that wasn't the case we could rename the define, and probably simplify the configure check further.

    Maybe better to leave it as is I dunno,

    I think leaving strong in here is ok for now.

  9. DrahtBot commented at 9:15 PM on September 25, 2021: member

    <!--9cd9c72976c961c55c7acef8f6ba82cd-->

    Guix builds

    File commit b7e360081506cc646dd86f131df2d01f3c544f0e<br>(master) commit a1534156669baa3019e317b34e7b95d74398759c<br>(master and this pull)
    SHA256SUMS.part e8e21d4714b5937d... 985785b3a3b47a08...
    *-aarch64-linux-gnu-debug.tar.gz dc15eb87d19022e2... 4e8933a2a7558062...
    *-aarch64-linux-gnu.tar.gz c35d34b053ac26e6... 07efb1b601d7ecfa...
    *-arm-linux-gnueabihf-debug.tar.gz 7b8f6da267804224... 6e95dc5c133ed138...
    *-arm-linux-gnueabihf.tar.gz 6012495e46b289b1... 749600e17aa9a165...
    *-osx-unsigned.dmg 8bd9d2b1f8d85ddc... 6db18c6d42d103f7...
    *-osx-unsigned.tar.gz 6a2d324448968cf7... 1e73ccf0e7a446cc...
    *-osx64.tar.gz 06faab7fb7b16fbb... 46f690f6c9d9b549...
    *-powerpc64-linux-gnu-debug.tar.gz 154c89eadaf74bd7... f43e6bfb1bc95441...
    *-powerpc64-linux-gnu.tar.gz 048dc46a2b3c4742... d94e8bd4cee8c25d...
    *-powerpc64le-linux-gnu-debug.tar.gz bae828208f6a832f... 5d900748c13a32e4...
    *-powerpc64le-linux-gnu.tar.gz dad3b82fc9c49086... e058ae72e450580f...
    *-riscv64-linux-gnu-debug.tar.gz af8bbe8970c58472... 068e1d39d6402d4b...
    *-riscv64-linux-gnu.tar.gz 1db7459bb2072cfa... a7d75ba273ac9d48...
    *-win-unsigned.tar.gz fa8ef2c4cf56a54e... 738272c07c4471a8...
    *-win64-debug.zip 24b53d6155e96ff0... 2135ab880921ed7d...
    *-win64-setup-unsigned.exe aa5e3f1417d53f0a... fe233ca7eb6ae159...
    *-win64.zip 7f12c17085c53faa... 6b2882124cf7055a...
    *-x86_64-linux-gnu-debug.tar.gz 10b87fc0ad7c94ff... dfef07142037edb0...
    *-x86_64-linux-gnu.tar.gz 98a91a293dfed5fc... 4621d05a1be2b9df...
    *.tar.gz e669e19314fe333c... 5fb54436718f51d6...
    guix_build.log 62883e024c5de51b... cc2b5dd09eae0686...
    guix_build.log.diff 2e625d55d4d8f924...
  10. DrahtBot removed the label DrahtBot Guix build requested on Sep 25, 2021
  11. fanquake commented at 11:47 AM on September 28, 2021: member

    Guix builds:

    bash-5.1# find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
    807377d2513c6370b0b6e57c08a41597eddc98cb2bab452387702286ef755b79  guix-build-4446ef0a549d/output/aarch64-linux-gnu/SHA256SUMS.part
    de797a3823e33aaf594706ec28eb625500899ee20aa415544d6a894f8d84c224  guix-build-4446ef0a549d/output/aarch64-linux-gnu/bitcoin-4446ef0a549d-aarch64-linux-gnu-debug.tar.gz
    9c14b5a685d59d94a4956222d7f405eac98faa5556778131117f247e12686dde  guix-build-4446ef0a549d/output/aarch64-linux-gnu/bitcoin-4446ef0a549d-aarch64-linux-gnu.tar.gz
    fb02d579ea2c6fbb10361748d65d11b747a320da1e33085a130f817f6c174eff  guix-build-4446ef0a549d/output/arm-linux-gnueabihf/SHA256SUMS.part
    11c896c5bc4dfec88412d889ef6e735d07fd425b317426921509fea51eb7bcf7  guix-build-4446ef0a549d/output/arm-linux-gnueabihf/bitcoin-4446ef0a549d-arm-linux-gnueabihf-debug.tar.gz
    c8b70b49707b37a7cb35217b599cd6a41e06aa19231df65c3a9f1d2fb2e68cb1  guix-build-4446ef0a549d/output/arm-linux-gnueabihf/bitcoin-4446ef0a549d-arm-linux-gnueabihf.tar.gz
    da17132928423728409230890ce8031b9cb1349d82f594bceca7e677d9969eef  guix-build-4446ef0a549d/output/dist-archive/bitcoin-4446ef0a549d.tar.gz
    03bd0789703bf5b2928c6608d75801af5c7a152af7c4ffc942437a39f8eadc9a  guix-build-4446ef0a549d/output/powerpc64-linux-gnu/SHA256SUMS.part
    93a51043aa84b7d29c5652f53d2193139cf9838e9ff6832fe9af8ac71a3ee520  guix-build-4446ef0a549d/output/powerpc64-linux-gnu/bitcoin-4446ef0a549d-powerpc64-linux-gnu-debug.tar.gz
    313db9e9e835bfd40c54e96fafa0a3b4e9abbbc9f745c4740ac23bcbd9d4e1c0  guix-build-4446ef0a549d/output/powerpc64-linux-gnu/bitcoin-4446ef0a549d-powerpc64-linux-gnu.tar.gz
    fe46d33b8f8d5b81b121d65283ca67109baa5a29b31a989734da725022d79e54  guix-build-4446ef0a549d/output/powerpc64le-linux-gnu/SHA256SUMS.part
    905dd93c3baf22d513ed5baae7eaf39f70dc8a3e52dc0a44392a3587cecc725a  guix-build-4446ef0a549d/output/powerpc64le-linux-gnu/bitcoin-4446ef0a549d-powerpc64le-linux-gnu-debug.tar.gz
    794ea6c5bb9aec1dac0c1f50edf0c1b8fa41f7640fb498d7c34e6d19eeaeaebf  guix-build-4446ef0a549d/output/powerpc64le-linux-gnu/bitcoin-4446ef0a549d-powerpc64le-linux-gnu.tar.gz
    abce72a0657161c0dbcf08913ccc8c554b16dc01881a3302af5901bc3e4c9c54  guix-build-4446ef0a549d/output/riscv64-linux-gnu/SHA256SUMS.part
    785117a347aa1bad35ae488990edcb0ebfd39758b85b392cc52febbfc24d8edc  guix-build-4446ef0a549d/output/riscv64-linux-gnu/bitcoin-4446ef0a549d-riscv64-linux-gnu-debug.tar.gz
    da449cced8e169d6326c76c3eb647977e9ab102a25efed1c6766a0220940f102  guix-build-4446ef0a549d/output/riscv64-linux-gnu/bitcoin-4446ef0a549d-riscv64-linux-gnu.tar.gz
    05d0019214fe026bea0374f4bb473200408185c34f520e8782a28b035774ff5b  guix-build-4446ef0a549d/output/x86_64-apple-darwin19/SHA256SUMS.part
    a19b8b6d4045035908cb2cb820b13db72b46f5f376eefd6067917e96d0d37968  guix-build-4446ef0a549d/output/x86_64-apple-darwin19/bitcoin-4446ef0a549d-osx-unsigned.dmg
    6bc81fa428753f78cc15fbf26fa8bba92ca78e576c57a7021198e9e67ee79b78  guix-build-4446ef0a549d/output/x86_64-apple-darwin19/bitcoin-4446ef0a549d-osx-unsigned.tar.gz
    71eef344b03778e141cbf86f471431bb7132622ff11176d218a01c6857e38a28  guix-build-4446ef0a549d/output/x86_64-apple-darwin19/bitcoin-4446ef0a549d-osx64.tar.gz
    e886878ddb281b184df3c9b41ec276bac43a23995890091252c2a58b4393b9a7  guix-build-4446ef0a549d/output/x86_64-linux-gnu/SHA256SUMS.part
    c248a23752dcef2d1413ec5ef13f63a6ce09a483482de9cc6e9f0bdbe372f575  guix-build-4446ef0a549d/output/x86_64-linux-gnu/bitcoin-4446ef0a549d-x86_64-linux-gnu-debug.tar.gz
    7ac5dd415a094469da60d2a694a4bad98d4f2fef056e090027bbd56ebd39454b  guix-build-4446ef0a549d/output/x86_64-linux-gnu/bitcoin-4446ef0a549d-x86_64-linux-gnu.tar.gz
    1510b87819334ace4dc104bac6953e77963d12ce47589aee954934db9a3a8c34  guix-build-4446ef0a549d/output/x86_64-w64-mingw32/SHA256SUMS.part
    25be8963960b9dd0eaf9bff1d956492a189f2aaa2a86d3c65326e046b40401c9  guix-build-4446ef0a549d/output/x86_64-w64-mingw32/bitcoin-4446ef0a549d-win-unsigned.tar.gz
    312e5b5f0de501d00e76ec6d3bed7a2854f84f86292bcd899255ec0192e2850f  guix-build-4446ef0a549d/output/x86_64-w64-mingw32/bitcoin-4446ef0a549d-win64-debug.zip
    030ec3f37b6d5c1ecfc166013379578684582a5e3e806a9a0a0c5274ef94b102  guix-build-4446ef0a549d/output/x86_64-w64-mingw32/bitcoin-4446ef0a549d-win64-setup-unsigned.exe
    cca299a44fbea988487dbedc43b1008a0c6f47a6c44377b0a12a97c7f4e0a04e  guix-build-4446ef0a549d/output/x86_64-w64-mingw32/bitcoin-4446ef0a549d-win64.zip
    
  12. laanwj commented at 10:54 AM on September 30, 2021: member

    Code review and tested ACK 4446ef0a549d567a88d82b606aa8c47f115673f9

  13. laanwj merged this on Sep 30, 2021
  14. laanwj closed this on Sep 30, 2021

  15. fanquake deleted the branch on Sep 30, 2021
  16. sidhujag referenced this in commit 068ba9dc4e on Sep 30, 2021
  17. DrahtBot locked this on Oct 30, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me