Fix getauxval calls in randomenv.cpp #20594

pull jonasschnelli wants to merge 2 commits into bitcoin:master from jonasschnelli:2020/12/getauxval changing 1 files +4 −2
  1. jonasschnelli commented at 8:44 PM on December 7, 2020: contributor

    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.

  2. Define correct symbols for getauxval 41a413b317
  3. Avoid weak-linked getauxval support on non-linux platforms (like macOS) 836a3dc02c
  4. jonasschnelli force-pushed on Dec 7, 2020
  5. laanwj commented at 9:25 PM on December 7, 2020: member

    Code review ACK 836a3dc02c72f917db5be386b9b4787a59d48610 Agree with making the weak link check Linux specific. It will pretty much pass on every platform with weak linking otherwise, redundantly.

  6. DrahtBot added the label Build system on Dec 7, 2020
  7. jonatack commented at 9:31 PM on December 7, 2020: member

    utACK 836a3dc02c72f917db5be386b9b4787a59d48610

  8. MarcoFalke commented at 3:21 PM on December 8, 2020: member

    #20358 is marked for backport, so should this be marked as well or neither?

  9. jonasschnelli commented at 3:31 PM on December 8, 2020: contributor

    I don't think this qualifies a backport.

  10. MarcoFalke added the label Needs gitian build on Dec 10, 2020
  11. MarcoFalke added the label Needs Guix build on Dec 10, 2020
  12. laanwj commented at 10:40 AM on December 10, 2020: member

    I don't think we're going to backport #20594, so this one shouldn't be needed to be backported either.

  13. DrahtBot commented at 4:33 AM on December 11, 2020: member

    <!--9cd9c72976c961c55c7acef8f6ba82cd-->

    Guix builds

    File commit c8fdbb46bd921575be84cf87e2966a455c3f5274<br>(master) commit b7b41d9d616d4f1e2d5c22d197e922dacc5457fc<br>(master and this pull)
    *-aarch64-linux-gnu-debug.tar.gz 3deed2da45b62eec... f8b7be38ce2bd0fe...
    *-aarch64-linux-gnu.tar.gz 40167786770050a7... 1c480ba919ed20b9...
    *-arm-linux-gnueabihf-debug.tar.gz 2bab3e6fb6bc6c5e... 00a0e88eb84de3e6...
    *-arm-linux-gnueabihf.tar.gz 348f41fdf8bb3296... a73847976a2eaf74...
    *-riscv64-linux-gnu-debug.tar.gz bcdd2745fa674043... 30d02b411ddb05a1...
    *-riscv64-linux-gnu.tar.gz c51f7b7430d46c11... 675851eb1d2a5e85...
    *-win-unsigned.tar.gz b217da27a48616f0... 6f6a7f8f518f1dc6...
    *-win64-debug.zip 738531e96954514f... 93f8f92fc8f5d8b7...
    *-win64-setup-unsigned.exe d002790eae6ad9cf... e3fba8230cb3dca6...
    *-win64.zip 88b762cf6d5e790b... cddd04ca26f97c64...
    *-x86_64-linux-gnu-debug.tar.gz a7ae27f4a44a4417... 4dc76fd7958c1b00...
    *-x86_64-linux-gnu.tar.gz 9d215d854f7c0486... 92ca9f0b6bdc3220...
    *.tar.gz 77f0547c1d498b1d... 1924def56271327d...
    guix_build.log 20eaab73a8ea65e0... 8e895c0575b3ac98...
    guix_build.log.diff e20b3ec664bfc7ff...
  14. DrahtBot removed the label Needs Guix build on Dec 11, 2020
  15. DrahtBot commented at 3:07 AM on December 12, 2020: member

    <!--a722867cd34abeea1fadc8d60700f111-->

    Gitian builds

    File commit 736eb4d8083862a6c3dd79e65afca6217cf7939d<br>(master) commit 1dca7741d66d8e342154698ad3baa3cd89852e23<br>(master and this pull)
    *-aarch64-linux-gnu-debug.tar.gz 2be2a11a222f573c... 0caa707037884abe...
    *-aarch64-linux-gnu.tar.gz aa6be788b43c77ab... 30bccc2fc34223d3...
    *-arm-linux-gnueabihf-debug.tar.gz bc084de532268d02... 9d9024b854110579...
    *-arm-linux-gnueabihf.tar.gz 8bf8847238bbb772... 21bd213dfcf405a6...
    *-osx-unsigned.dmg 0e0b5353ad614bc4... 66fce95a8f9629bf...
    *-osx64.tar.gz 138e5e00bfec397f... deccb18151ae7afd...
    *-riscv64-linux-gnu-debug.tar.gz f77b9fc97e1691c7... 83890c884c7a9a06...
    *-riscv64-linux-gnu.tar.gz 45248a9a8de4982e... 115770bb6696689e...
    *-win64-debug.zip 09d982b554816f6b... e60536ae9a0db672...
    *-win64-setup-unsigned.exe 3c905f96f0f756e0... a7ce72522d6b2737...
    *-win64.zip 8c7fc6e3a8ea93fe... 1695e977e953c730...
    *-x86_64-linux-gnu-debug.tar.gz e47b5bfa0a774d6b... 7534216299cd8565...
    *-x86_64-linux-gnu.tar.gz fe3f8b7e4e601768... aa9278300d67768e...
    *.tar.gz 12158696afd16c3a... e7916754ec0700b3...
    bitcoin-core-linux-22-res.yml 70d8be4a51bc67f7... 3c3ff0a3ba6d40eb...
    bitcoin-core-osx-22-res.yml 97d889ba103beac9... 3381e980d259abc4...
    bitcoin-core-win-22-res.yml 169a1d1fafcb841e... b7c8bd94cdbbd7f7...
    linux-build.log 46b0db1f12f1fed8... 4e0c9a0d1bde535c...
    osx-build.log 42dd0c03e04b575f... 8a34df29be5e5926...
    win-build.log 9a4cfdc2af2389a0... 9eb1ff5f519b0932...
    bitcoin-core-linux-22-res.yml.diff 3be13530bb24beac...
    bitcoin-core-osx-22-res.yml.diff ab4154baf5c66882...
    bitcoin-core-win-22-res.yml.diff 94c7a5ecc8329205...
    linux-build.log.diff f09b079e31e940b2...
    osx-build.log.diff 06af4a15f2a13bf7...
    win-build.log.diff 0b8a4f2d28c8dab6...
  16. DrahtBot removed the label Needs gitian build on Dec 12, 2020
  17. in configure.ac:1113 in 836a3dc02c
    1109 | @@ -1110,18 +1110,20 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    1110 |    ]], [[
    1111 |      getauxval(AT_HWCAP);
    1112 |    ]])],
    1113 | - [ AC_MSG_RESULT(yes); HAVE_STRONG_GETAUXVAL=1 ],
    1114 | + [ AC_MSG_RESULT(yes); HAVE_STRONG_GETAUXVAL=1; AC_DEFINE(HAVE_STRONG_GETAUXVAL, 1, [Define this symbol to build code that uses getauxval)]) ],
    


    luke-jr commented at 4:12 AM on December 14, 2020:
     [
         AC_MSG_RESULT(yes)
         HAVE_STRONG_GETAUXVAL=1
         AC_DEFINE(HAVE_STRONG_GETAUXVAL, 1, [Define this symbol to build code that uses getauxval)])
       ],
    
  18. in configure.ac:1126 in 836a3dc02c
    1123 | +    #endif
    1124 |    ]], [[
    1125 |      getauxval(AT_HWCAP);
    1126 |    ]])],
    1127 | - [ AC_MSG_RESULT(yes); HAVE_WEAK_GETAUXVAL=1 ],
    1128 | + [ 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)]) ],
    


    luke-jr commented at 4:12 AM on December 14, 2020:
     [
       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)])
     ],
    
  19. in configure.ac:1121 in 836a3dc02c
    1117 |  
    1118 |  AC_MSG_CHECKING(for weak getauxval support in the compiler)
    1119 |  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    1120 | +    #ifdef __linux__
    1121 |      unsigned long getauxval(unsigned long type) __attribute__((weak));
    1122 |      #define AT_HWCAP 16
    


    luke-jr commented at 4:14 AM on December 14, 2020:

    This seems very fragile. On what target is getauxval only weak?


    jonasschnelli commented at 7:33 AM on December 14, 2020:

    Why would it be (more) fragile? Weak linking is already pretty fragile AFAIK. IMO this weak linking passes always. See masters Win64 build as an example.

    AFAIK this check is part of googles crc32c suite. Limiting it to linux makes absolute sense to me since getauxval (it doesn't exists on Mac/win).


    luke-jr commented at 3:33 PM on December 14, 2020:

    Sorry, I do mean the weak linking entirely. What do we lose, if we only check for strong linking?


    jonasschnelli commented at 5:14 PM on December 14, 2020:

    That's a valid question. AFAIK the google crc32c getauxval weak linking check is for android (< API level 20). Crc32c is an upstream upstream subtree. I guess if we don't want to check for the weak linking, we might want to PR that there.


    luke-jr commented at 5:44 PM on December 14, 2020:

    I assume if we just don't define it, that code block simply won't be used?


    laanwj commented at 7:55 PM on December 14, 2020:

    This seems very fragile. On what target is getauxval only weak?

    a) getauxval only exists on Linux (OSes with the Linux kernel, I mean) b) by nature of weak linking, it could weakly link on every platform, this makes no sense though

  20. laanwj commented at 7:58 PM on December 14, 2020: member

    I think this fix is fine. Removing the weak check completely is something that could be considered, but might interfere with Android. It doesn't need to be decided in this PR.

  21. laanwj merged this on Dec 14, 2020
  22. laanwj closed this on Dec 14, 2020

  23. sidhujag referenced this in commit 64c284dd69 on Dec 15, 2020
  24. PastaPastaPasta referenced this in commit 81f6dd86b7 on Sep 17, 2021
  25. thelazier referenced this in commit 5af09a3267 on Sep 25, 2021
  26. DrahtBot locked this on Feb 15, 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-13 18:14 UTC

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