build: fix mutex detection when building bdb on macOS #20195

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:bdb_xcode12_implicit_function_decleration changing 1 files +1 −0
  1. fanquake commented at 9:46 am on October 20, 2020: member

    Starting with the Apple Clang shipped with Xcode 12, Apple has enabled -Werror=implicit-function-declaration by default:

    Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on). This additional error detection unifies Clang’s behavior for iOS/tvOS and macOS 64-bit targets for this diagnostic. (49917738)

    This causes bdbs mutex detection to fail when building on macOS (not cross-compiling):

    0checking for mutexes... UNIX/fcntl
    1configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
    2configure: error: Unable to find a mutex implementation
    

    as previously emitted warnings are being turned into errors. i.e:

    0configure:18704: checking for mutexes
    1configure:18815: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -mmacosx-version-min=10.12 --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o conftest -pipe -O2  -I/Users/michael/github/fanquake-bitcoin/depends/x86_64-apple-darwin19.6.0/include -L/Users/michael/github/fanquake-bitcoin/depends/x86_64-apple-darwin19.6.0/lib conftest.c  -lpthread >&5
    2conftest.c:46:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
    3main() {
    4^
    5conftest.c:51:2: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
    6        exit (
    7        ^
    8conftest.c:51:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
    91 warning and 1 error generated.
    

    Append -Wno-error=implicit-function-declaration to cflags so that -Wimplicit-function-declaration returns to being a warning, and the configure checks succeed.

    Fixes #19411.

  2. fanquake added the label macOS on Oct 20, 2020
  3. fanquake added the label Build system on Oct 20, 2020
  4. fanquake added this to the milestone 0.21.0 on Oct 20, 2020
  5. MarcoFalke added the label Needs gitian build on Oct 20, 2020
  6. MarcoFalke added the label Needs Guix build on Oct 20, 2020
  7. awesome-doge commented at 9:55 am on October 20, 2020: none

    environment:“macos big sur beta 11.0” & “Command_Line_Tools_for_Xcode_12.2_beta_3” Even if I added the “$(package)_cc+=-Wno-error=implicit-function-declaration” code I still get the error

    0checking for getopt optreset variable... yes
    1checking for mutexes... UNIX/fcntl
    2configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
    3configure: error: Unable to find a mutex implementation
    
  8. hebasto approved
  9. hebasto commented at 11:01 am on October 20, 2020: member
    Concept ACK 0729d1a0255eaec2ac3dba1b31a7d5cde7824e5a, the diff is a correct resolution of the bug introduced by Apple Clang update. Though not able to test on macOS Big Sur.
  10. willcl-ark commented at 11:28 am on October 20, 2020: member

    tACK.

    Tested depends build on: System Version: macOS 11.0 (20A5384c) Kernel Version: Darwin 20.1.0 @awesome-doge you are running the contrib script, which has not been fixed (rather than building depends, which this fix addresses). @fanquake do we want to add an export CFLAGS="-Wno-error=implicit-function-declaration" to the contrib script if MacOS>11.0 so that the bdb contrib script works for users?

  11. awesome-doge commented at 11:32 am on October 20, 2020: none
    environment:“macos big sur beta 11.0” & “Command_Line_Tools_for_Xcode_12.2_beta_3” @willcl-ark Thanks, “export CFLAGS="-Wno-error=implicit-function-declaration” passed
  12. Sjors commented at 11:34 am on October 20, 2020: member

    Note that this only fixes the depends build, not contrib/install_db4.sh (CFLAGS="-Wno-error=implicit-function-declaration" indeed does the trick for that).

    Tested 0729d1a on macOS Catalina 10.15.7 with Xcode 12.0.1, but I haven’t tested on Big Sur. It builds, functional wallet tests and feature_backwards_compatibility.py still pass.

    I might try upgrading a machine to Big Sur beta later today.

  13. awesome-doge commented at 11:42 am on October 20, 2020: none
    ACK Adding export CFLAGS="-Wno-error=implicit-function-declaration is an effective solution.
  14. DrahtBot commented at 10:51 am on October 21, 2020: member

    Guix builds

    File commit f5bd46a4cc6d395ce71ecb99852c1774235a249c(master) commit 8a637abb7d6dfc080003d313a50b9ccd56a0a45a(master and this pull)
    *-aarch64-linux-gnu-debug.tar.gz e4dbadb995209f40... eb2ab668fbcd60f2...
    *-aarch64-linux-gnu.tar.gz 980a6feaa9a16c71... e9dbf10857401d4e...
    *-arm-linux-gnueabihf-debug.tar.gz 58da7da8638bf537... 69b665ae6e4070da...
    *-arm-linux-gnueabihf.tar.gz 6f09a594f508217c... 3d95c96cbcbdcfd6...
    *-riscv64-linux-gnu-debug.tar.gz 0abce2fd67df3816... 5b7ec4f82b3b0797...
    *-riscv64-linux-gnu.tar.gz 29cafaa3332c1eb5... 24bac64038156add...
    *-win-unsigned.tar.gz 4d960a0b2fd22290... 6e5decf6f655ecdd...
    *-win64-debug.zip d01960490127df59... f069932d1a208e8e...
    *-win64-setup-unsigned.exe 303b35c46a0fcec0... 1ec68b0f87905d59...
    *-win64.zip d6dea3909a4109f4... 0da5bdbbe79ed3e6...
    *-x86_64-linux-gnu-debug.tar.gz 8dcf17991e819cf5... 41087300d7f18b21...
    *-x86_64-linux-gnu.tar.gz b9a256af0e7ef5c2... bbc7d41aa962f65d...
    *.tar.gz 8bce7f0b98fd7610... 2337098e34f477dc...
    guix_build.log 3faa9c24a3faf7e8... 1ba32fff3a5b1726...
    guix_build.log.diff f01adee889bbe77d...
  15. DrahtBot removed the label Needs Guix build on Oct 21, 2020
  16. Sjors commented at 11:13 am on October 21, 2020: member
    tACK 0729d1a on Big Sur beta 10 (20A5395g) with Xcode 12.1
  17. dongcarl commented at 6:49 pm on October 21, 2020: member

    Is the mutex check the only thing in bdb that needs -Wno-error=implicit-function-declaration?

    Also, perhaps we should put this in cflags and/or cxxflags instead of appending to cc itself?

  18. willcl-ark commented at 7:09 pm on October 21, 2020: member
    I was playing with a commit for the contrib script which adds to CFLAGS as I thought this approach was cleaner too: https://github.com/willcl-ark/bitcoin/commit/266b5741586f4d2db9b78151942c440b2fcffc66
  19. hebasto approved
  20. hebasto commented at 9:35 pm on October 21, 2020: member
    ACK 0729d1a0255eaec2ac3dba1b31a7d5cde7824e5a, tested on macOS Big Sur 11.0 Beta (20A5395g), Xcode 12.1 (12A7403).
  21. willcl-ark approved
  22. DrahtBot commented at 8:53 pm on October 22, 2020: member

    Gitian builds

    File commit f5bd46a4cc6d395ce71ecb99852c1774235a249c(master) commit 8a637abb7d6dfc080003d313a50b9ccd56a0a45a(master and this pull)
    bitcoin-core-linux-0.21-res.yml d1971dabc444008d... d7c18efcee57bb0e...
    bitcoin-core-osx-0.21-res.yml de235a951f7a465e... b65c22dbd477b498...
    bitcoin-core-win-0.21-res.yml f75ce7b9355d334c... 5a5626895e4c0dad...
    *-aarch64-linux-gnu-debug.tar.gz 6ed9c70434fc7fc2... b23e562a903d67e3...
    *-aarch64-linux-gnu.tar.gz 3af5f18ffa364c24... 8de803a78b61e668...
    *-arm-linux-gnueabihf-debug.tar.gz 098fc410215e7c42... 927541e286fd8afd...
    *-arm-linux-gnueabihf.tar.gz 3f2c975b713698b2... e570ed025be9beec...
    *-osx-unsigned.dmg 012c0dc0e1b3f2ec... 948eedc8d14f09af...
    *-osx64.tar.gz 6409b02ac19538f2... 4f67974f9f30ada4...
    *-riscv64-linux-gnu-debug.tar.gz 6da1f76714b4dbfe... 25e4afda219071cf...
    *-riscv64-linux-gnu.tar.gz a90367c39515c3b4... d60072692330e0aa...
    *-win64-debug.zip 453e395581992f20... 30fd8b9ee459db64...
    *-win64-setup-unsigned.exe 8b50662e73d518ea... beaccfe115d80411...
    *-win64.zip aa74cb3b0978fb5a... f795d48a1b3028a5...
    *-x86_64-linux-gnu-debug.tar.gz 7e318d3ab76e48eb... e5f43789f00fd3a1...
    *-x86_64-linux-gnu.tar.gz 6447ef245d9ee8f6... da0a4dd8594f84e1...
    *.tar.gz 8bce7f0b98fd7610... 2337098e34f477dc...
    linux-build.log 3c348dc643432917... dc05373804b6e715...
    osx-build.log 083ca63c793f3b21... 4568be3a1a2700d4...
    win-build.log 72ceb0afecdf12df... 267cdbb803abb1b0...
    bitcoin-core-linux-0.21-res.yml.diff d72ce3e7dbed9984...
    bitcoin-core-osx-0.21-res.yml.diff 63581c498584ca08...
    bitcoin-core-win-0.21-res.yml.diff b4471f3ae189bcfe...
    linux-build.log.diff cf6ff2f2f1a49138...
    osx-build.log.diff 51d9692a4257421b...
    win-build.log.diff 5890fb21346ca07a...
  23. DrahtBot removed the label Needs gitian build on Oct 22, 2020
  24. luke-jr approved
  25. luke-jr commented at 7:24 pm on October 24, 2020: member
    utACK
  26. build: fix mutex detection when building bdb on macOS
    Starting with the Clang shipped with Xcode 12, Apple has enabled
    -Werror=implicit-function-declaration by default. This causes bdbs mutex
    detection to fail when building on macOS (not cross-compiling):
    
    checking for mutexes... UNIX/fcntl
    configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
    configure: error: Unable to find a mutex implementation
    
    as previously emitted warnings are being turned into errors. i.e:
    
    error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
    
    Append -Wno-error=implicit-function-declaration to cflags so that
    -Wimplicit-function-declaration returns to being a warning, and the
    configure checks will succeed.
    
    Fixes #19411.
    d0a829e963
  27. fanquake force-pushed on Oct 27, 2020
  28. fanquake commented at 1:31 pm on October 27, 2020: member

    Is the mutex check the only thing in bdb that needs -Wno-error=implicit-function-declaration?

    Yes as far as I’ve seen.

    Also, perhaps we should put this in cflags and/or cxxflags instead of appending to cc itself?

    The first time I tested this, I’m sure that putting this in cflags wasn’t working.. I’ve retested that now, and agree that is the more appropriate place. Have pushed a change.

  29. fanquake added the label Needs backport (0.20) on Oct 28, 2020
  30. laanwj commented at 11:31 am on October 29, 2020: member
    Code review ACK d0a829e9632379e42f0be5c554e3b692f0d14a95
  31. laanwj merged this on Oct 29, 2020
  32. laanwj closed this on Oct 29, 2020

  33. sidhujag referenced this in commit faf425a4f6 on Oct 29, 2020
  34. fanquake referenced this in commit 314e79581f on Oct 30, 2020
  35. fanquake removed the label Needs backport (0.20) on Oct 30, 2020
  36. fanquake commented at 0:09 am on October 30, 2020: member
    Added to #20166 for backporting.
  37. MarcoFalke referenced this in commit a2fa11f9de on Nov 18, 2020
  38. MarkLTZ referenced this in commit 11254d49e6 on Nov 21, 2020
  39. MarkLTZ referenced this in commit c61e643b75 on Nov 21, 2020
  40. xdustinface referenced this in commit 53ad08710c on Feb 17, 2021
  41. fanquake deleted the branch on Jun 9, 2021
  42. random-zebra referenced this in commit 64da8d9167 on Jul 2, 2021
  43. michelvankessel referenced this in commit cc0364ca33 on Aug 25, 2021
  44. mxaddict referenced this in commit 332989185e on Oct 11, 2021
  45. DrahtBot locked this on Aug 18, 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: 2024-11-17 06:12 UTC

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