depends: fix compiling bdb with clang-16 on aarch64 #27462

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:fix_bdb_clang_16 changing 1 files +1 −1
  1. fanquake commented at 10:04 am on April 14, 2023: member

    Compiling bdb with clang-16 on aarch64 (hardware) currently fails:

    0make -C depends/ bdb CC=clang CXX=clang++
    1...
    2checking for mutexes... UNIX/fcntl
    3configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
    4configure: error: Unable to find a mutex implementation
    

    Looking at config.log we’ve got:

     0configure:18704: checking for mutexes
     1configure:18815: clang -o conftest -pipe -std=c11 -O2 -Wno-error=implicit-function-declaration -Wno-error=format-security    -I/bitcoin/depends/aarch64-unknown-linux-gnu/include -D_GNU_SOURCE -D_REENTRANT   -L/bitcoin/depends/aarch64-unknown-linux-gnu/lib conftest.c  -lpthread >&5
     2conftest.c:45:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
     3main() {
     4^
     5int
     6conftest.c:50:2: warning: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     7        exit (
     8        ^
     9conftest.c:50:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
    101 warning and 1 error generated.
    

    Clang-16 changed -Wimplicit-function-declaration and -Wimplicit-int warnings into errors, see: https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#potentially-breaking-changes.

    The -Wimplicit-function-declaration and -Wimplicit-int warnings now default to an error in C99, C11, and C17. As of C2x, support for implicit function declarations and implicit int has been removed, and the warning options will have no effect. Specifying -Wimplicit-int in C89 mode will now issue warnings instead of being a noop.

  2. DrahtBot commented at 10:04 am on April 14, 2023: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hebasto
    Concept ACK theuni

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Build system on Apr 14, 2023
  4. maflcko added the label DrahtBot Guix build requested on Apr 14, 2023
  5. maflcko commented at 11:29 am on April 14, 2023: member
    Unrelated: Interesting, that probably also means we can’t switch to C++20 with depends, as long as bdb is around, assuming that depends is compiled with the same flags as Bitcoin Core?
  6. maflcko commented at 3:11 pm on April 14, 2023: member
    This is only broken on aarch64, right?
  7. fanquake commented at 3:13 pm on April 14, 2023: member

    This is only broken on aarch64, right?

    Yea. Otherwise the CI should be failing. I haven’t looked into the x86_64 vs aarch64 code in bdb. (updated title)

  8. fanquake renamed this:
    depends: fix compiling bdb with clang-16
    depends: fix compiling bdb with clang-16 on aarch64
    on Apr 14, 2023
  9. theuni commented at 3:22 pm on April 14, 2023: member
    Concept ACK. To @MarcoFalke’s point, how nasty would a patch be to actually fix the casts?
  10. fanquake commented at 3:25 pm on April 14, 2023: member

    how nasty would a patch be to actually fix the casts?

    The first failures occur in configure, so probably nasty.

  11. fanquake commented at 3:40 pm on April 14, 2023: member

    Guix Build:

     0ed1f83a77d00:/bitcoin# find guix-build-$(git rev-parse --short=12 HEAD)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
     105fb39e87c26ce80c12c9a1e054eb5b558a454120c19cc555d7ab1d6508c0749  guix-build-0cc90822d502/output/aarch64-linux-gnu/SHA256SUMS.part
     2c488ff0d8eb0e1ec605f5ca6836b3dba4ab468f2f51ad2356ec9a632f6aee4c5  guix-build-0cc90822d502/output/aarch64-linux-gnu/bitcoin-0cc90822d502-aarch64-linux-gnu-debug.tar.gz
     332c33bdb964d7eb3fe16f30f00b5eb3582e65e1c53d93be62ffe2e159ed2e5ba  guix-build-0cc90822d502/output/aarch64-linux-gnu/bitcoin-0cc90822d502-aarch64-linux-gnu.tar.gz
     493e6cb10b0acb01daa904b5a2a810eef4a0e6cb644c7bcab522bf3f368faa7ad  guix-build-0cc90822d502/output/arm-linux-gnueabihf/SHA256SUMS.part
     5a266006b08ec1f1c9590721d0e6fc616281f8d96ba692d65302081d1c29cb19e  guix-build-0cc90822d502/output/arm-linux-gnueabihf/bitcoin-0cc90822d502-arm-linux-gnueabihf-debug.tar.gz
     6c50055c3a2fe9a804a184d0eecfd334b57666774b529d049529f0c7d4dcd1956  guix-build-0cc90822d502/output/arm-linux-gnueabihf/bitcoin-0cc90822d502-arm-linux-gnueabihf.tar.gz
     7289ed95547b61597b60d1d3d0d11f1000725dbe882e856ef257418ea3a0223eb  guix-build-0cc90822d502/output/arm64-apple-darwin/SHA256SUMS.part
     82a031cd937cc370409996570a413d2ccf5541aee6881a1598dd0680fe006f5bd  guix-build-0cc90822d502/output/arm64-apple-darwin/bitcoin-0cc90822d502-arm64-apple-darwin-unsigned.dmg
     970d645f92719f79a3bbb1ac0cf1cf871609163c7a00ddaa1f80a0ced7534aa90  guix-build-0cc90822d502/output/arm64-apple-darwin/bitcoin-0cc90822d502-arm64-apple-darwin-unsigned.tar.gz
    10f02cc0c4f55d08aae79acc45d9de470b8c910dcebdacebb38480692c34ed9223  guix-build-0cc90822d502/output/arm64-apple-darwin/bitcoin-0cc90822d502-arm64-apple-darwin.tar.gz
    11614940475d1219cbab5a1c01e7be6cf1b40675b571bae344b32bc2fee76cd5fd  guix-build-0cc90822d502/output/dist-archive/bitcoin-0cc90822d502.tar.gz
    12d9a0a0de3db69c9bc561e4014bde35820cc778cb97fc6140f761631d8c62f90a  guix-build-0cc90822d502/output/powerpc64-linux-gnu/SHA256SUMS.part
    132f34368e54dbab5dd1d9734ad818030ab432b99e7b3e54469400736534720478  guix-build-0cc90822d502/output/powerpc64-linux-gnu/bitcoin-0cc90822d502-powerpc64-linux-gnu-debug.tar.gz
    14b8f9e26637e27453713547b2d0eeb8f06bff24368a28e24aaabaf5c268fe18c3  guix-build-0cc90822d502/output/powerpc64-linux-gnu/bitcoin-0cc90822d502-powerpc64-linux-gnu.tar.gz
    15a024401d89295a9875cdaa4aff6c36272d29527d33078b9dd184525f812e630e  guix-build-0cc90822d502/output/powerpc64le-linux-gnu/SHA256SUMS.part
    1619e3dbe1b853fe47f55bee2bc5fa17766dae9376d3efce0a37320940c8cbe09f  guix-build-0cc90822d502/output/powerpc64le-linux-gnu/bitcoin-0cc90822d502-powerpc64le-linux-gnu-debug.tar.gz
    1758ed0e123da877934552ded68a142f881c7e11290f24047fe95ffc2d8c095543  guix-build-0cc90822d502/output/powerpc64le-linux-gnu/bitcoin-0cc90822d502-powerpc64le-linux-gnu.tar.gz
    18ea90971b0a4029c27ad8dab096dacee452ba0120921026d0f0b81c18ce389d3a  guix-build-0cc90822d502/output/riscv64-linux-gnu/SHA256SUMS.part
    1939823ee979381fac92a4b3e745092771e7010a98d5dde532b4f7d7d54eccc6c8  guix-build-0cc90822d502/output/riscv64-linux-gnu/bitcoin-0cc90822d502-riscv64-linux-gnu-debug.tar.gz
    20fb7b0f3d6bac3ba8eade24e4a0ad9656a4fe627f41cb1c12ecc456e61561419d  guix-build-0cc90822d502/output/riscv64-linux-gnu/bitcoin-0cc90822d502-riscv64-linux-gnu.tar.gz
    21e78399eeb59aec9c8fb24da3f9f237c8e2b26bf04a1b6e6e230a488aaec8fa86  guix-build-0cc90822d502/output/x86_64-apple-darwin/SHA256SUMS.part
    225a82eb03bcf33b6ca40458ac4bf37058e97b71ce957246f7b2149430d5f554fa  guix-build-0cc90822d502/output/x86_64-apple-darwin/bitcoin-0cc90822d502-x86_64-apple-darwin-unsigned.dmg
    233b26f4786a5a69fe5440cbd4583f30deb99b3047f6a36f58f331185de72a3e13  guix-build-0cc90822d502/output/x86_64-apple-darwin/bitcoin-0cc90822d502-x86_64-apple-darwin-unsigned.tar.gz
    24271387a4882d34d7a7effe8678d0989af78ce6e46cba2bf2d9f2b2ce1ee0aff9  guix-build-0cc90822d502/output/x86_64-apple-darwin/bitcoin-0cc90822d502-x86_64-apple-darwin.tar.gz
    25d1b0dc135cd51e7bd0fe8f2a997c19d724e4b8302d7e29d6c310670e81154c43  guix-build-0cc90822d502/output/x86_64-linux-gnu/SHA256SUMS.part
    2654b0dd7d8f5ee51f9f99313ddc2439892e3c41046349e67e206dd40979c447e2  guix-build-0cc90822d502/output/x86_64-linux-gnu/bitcoin-0cc90822d502-x86_64-linux-gnu-debug.tar.gz
    27a280f0f5f002e52df4c7f1fcbdee619ba40e401047eb0c046ce78411d3dd836b  guix-build-0cc90822d502/output/x86_64-linux-gnu/bitcoin-0cc90822d502-x86_64-linux-gnu.tar.gz
    28f18582890648c119ed7069d30a5c6eb2e56f9ca8ea26c7f5caf65f2e1b6f7404  guix-build-0cc90822d502/output/x86_64-w64-mingw32/SHA256SUMS.part
    29ccef6cdc725b5a047699b486a72f792a2eef396b7f7e1163c989c4297d3f31c9  guix-build-0cc90822d502/output/x86_64-w64-mingw32/bitcoin-0cc90822d502-win64-debug.zip
    304b54d569784032fe8e9626dc284f20077ab834953e666d2eaa1cf6143ffaacae  guix-build-0cc90822d502/output/x86_64-w64-mingw32/bitcoin-0cc90822d502-win64-setup-unsigned.exe
    3142d938b7a34fefc0c08e086216919e155d35a84eaa29f44a788a0f028c87332b  guix-build-0cc90822d502/output/x86_64-w64-mingw32/bitcoin-0cc90822d502-win64-unsigned.tar.gz
    32c571f23f07690fb0c3846055d70d48650e4a2ecdc7838b92cf5a5f1d85223715  guix-build-0cc90822d502/output/x86_64-w64-mingw32/bitcoin-0cc90822d502-win64.zip
    
  12. theuni commented at 4:23 pm on April 14, 2023: member

    May be interesting: I don’t hit any issues when cross building for aarch64-linux-gnu from x86_64:

    0make NO_QT=1 HOST=aarch64-linux-gnu CC="clang --target=aarch64-linux-gnu" CXX='clang++ --target=aarch64-linux-gnu'
    

    ^^ (Where clang/clang++ are clang16 via PATH) builds fine.

  13. DrahtBot commented at 4:48 pm on April 14, 2023: contributor

    Guix builds

    File commit 2bfe43db164de7382d01c06dbdebf250d35f9f2f(master) commit 7fa8427c6a25e81c6201d2880da9b97bcafd72d3(master and this pull)
    SHA256SUMS.part 7da8690e1c5e210d... f8c00099ac9eb06b...
    *-aarch64-linux-gnu-debug.tar.gz c8d4d9b53c23c5db... 0bd4196faf61d328...
    *-aarch64-linux-gnu.tar.gz 3f86ff36fd15f413... f53a9449ec996c80...
    *-arm-linux-gnueabihf-debug.tar.gz 10b7ff22afa2c4eb... 0c92745ff0a0eb9a...
    *-arm-linux-gnueabihf.tar.gz 984e49e376395f02... 465f8fdcce92f64c...
    *-powerpc64-linux-gnu-debug.tar.gz a6bd281841309804... a56e1b3e1371d439...
    *-powerpc64-linux-gnu.tar.gz 7e8347a7b3152a65... 0dcf280632024784...
    *-powerpc64le-linux-gnu-debug.tar.gz bc00bb58c7c0218f... 71894635542094f0...
    *-powerpc64le-linux-gnu.tar.gz 9526268d9e505563... 30f3d58b737675c3...
    *-riscv64-linux-gnu-debug.tar.gz 5e5a788ef154284d... 0f2230d58d893bd8...
    *-riscv64-linux-gnu.tar.gz 33a73f6de604d4ca... e0c3ad1bc122cf72...
    *-x86_64-linux-gnu-debug.tar.gz 6c3ab47eef00be9a... a19ea7c6c1ef98e6...
    *-x86_64-linux-gnu.tar.gz 20ab928d5d1fc93d... fb04e308aef92daa...
    *.tar.gz 795f841accfffd75... 90e403bba4698ccd...
    guix_build.log b6b809522e74bb89... 62e524c37566938d...
    guix_build.log.diff 8c5cea1f257d080e...
  14. DrahtBot removed the label DrahtBot Guix build requested on Apr 14, 2023
  15. depends: fix compiling bdb with clang-16 on aarch64
    Compiling bdb with clang-16 on aarch64 (hardware) currently fails:
    ```bash
    make -C depends/ bdb CC=clang CXX=clang++
    ...
    checking for mutexes... UNIX/fcntl
    configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
    configure: error: Unable to find a mutex implementation
    ```
    
    Looking at config.log we've got:
    ```bash
    configure:18704: checking for mutexes
    configure:18815: clang -o conftest -pipe -std=c11 -O2 -Wno-error=implicit-function-declaration -Wno-error=format-security    -I/bitcoin/depends/aarch64-unknown-linux-gnu/include -D_GNU_SOURCE -D_REENTRANT   -L/bitcoin/depends/aarch64-unknown-linux-gnu/lib conftest.c  -lpthread >&5
    conftest.c:45:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    main() {
    ^
    int
    conftest.c:50:2: warning: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            exit (
            ^
    conftest.c:50:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
    1 warning and 1 error generated.
    ```
    
    Clang-16 changed `-Wimplicit-function-declaration` and `-Wimplicit-int`
    warnings into errors, see:
    https://releases.llvm.org/16.0.0/tools/clang/docs/ReleaseNotes.html#potentially-breaking-changes.
    
    > The -Wimplicit-function-declaration and -Wimplicit-int warnings now
    > default to an error in C99, C11, and C17. As of C2x, support for implicit
    > function declarations and implicit int has been removed, and the
    > warning options will have no effect. Specifying -Wimplicit-int in
    > C89 mode will now issue warnings instead of being a noop.
    f8b8458276
  16. fanquake force-pushed on Apr 17, 2023
  17. fanquake commented at 9:16 am on April 17, 2023: member
    I’ve updated the commit message and PR description with more information.
  18. hebasto approved
  19. hebasto commented at 9:25 am on April 17, 2023: member

    ACK f8b8458276983f8fc1e2a47c4d00c1e30633067d, tested on Ubuntu Lunar (aarch64) with:

    0make -C depends bdb CC=clang-16 CXX=clang++-16
    

    and

    0make -C depends bdb CC=clang-16 CXX="clang++-16 -stdlib=libc++"
    
  20. fanquake merged this on Apr 17, 2023
  21. fanquake closed this on Apr 17, 2023

  22. fanquake deleted the branch on Apr 17, 2023
  23. theuni commented at 3:36 pm on April 17, 2023: member
    Wait, did we ever figure out why this only happens when not cross-compiling? That’s fishy to me.
  24. sidhujag referenced this in commit d140634801 on Apr 17, 2023
  25. fanquake commented at 4:18 pm on April 17, 2023: member

    This does happen when cross-compiling with Clang-16, i.e clang-16 test.c --target=aarch64-linux-gnu (on x86_64), where test.c contains the equivalent of the warning-causing code being dumped into conftest.c. However depends isn’t really usable to easily do cross-compilation with Clang, except for where we’ve got it setup for macOS.

    The fact that this doesn’t fail in the same way, when using a different cross-compiler (GCC), cross-compiling on x86_64, seems like a potentially related, but separate issue?

  26. theuni commented at 7:47 pm on April 17, 2023: member
    Ok, yeah, I guess my question was: why isn’t this slipping into a “CC=clang” build. But point taken that’s not really a supported combo.
  27. fanquake referenced this in commit f0919339bf on Apr 18, 2023
  28. fanquake referenced this in commit c40b1da2fd on Apr 18, 2023
  29. fanquake referenced this in commit 15a24781d0 on Apr 18, 2023
  30. theuni commented at 6:54 pm on April 18, 2023: member

    Just in case it’s ever helpful (or as @MarcoFalke said, in case we need this for c++20), here’s a set of depends patches for bdb that should fix the existing configure checks: https://github.com/theuni/bitcoin/commits/bdb-configure-int-checks

    The code itself still isn’t patched for the missing prototypes, but if the time comes and we need to do that, it should be simple enough.

  31. fanquake commented at 10:41 am on April 19, 2023: member
    @theuni Thanks for following up. Hopefully we’ll be able to avoid the route of having to do even more invasive patching.
  32. fanquake referenced this in commit 7b7636ead1 on May 1, 2023
  33. bitcoin locked this on Apr 18, 2024

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: 2024-12-27 09:12 UTC

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