Skip to content

Conversation

fanquake
Copy link
Member

@fanquake fanquake commented Oct 20, 2020

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):

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:

configure:18704: checking for mutexes
configure: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
conftest.c:46:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main() {
^
conftest.c:51:2: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
        exit (
        ^
conftest.c:51:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
1 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.

@awesome-doge
Copy link

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

checking for getopt optreset variable... yes
checking for mutexes... UNIX/fcntl
configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
configure: error: Unable to find a mutex implementation

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK 0729d1a, the diff is a correct resolution of the bug introduced by Apple Clang update. Though not able to test on macOS Big Sur.

@willcl-ark
Copy link
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?

@awesome-doge
Copy link

awesome-doge commented Oct 20, 2020

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

@Sjors
Copy link
Member

Sjors commented Oct 20, 2020

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.

@awesome-doge
Copy link

awesome-doge commented Oct 20, 2020

ACK Adding export CFLAGS="-Wno-error=implicit-function-declaration is an effective solution.

@DrahtBot
Copy link
Contributor

Guix builds

File commit f5bd46a
(master)
commit 8a637ab
(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...

@Sjors
Copy link
Member

Sjors commented Oct 21, 2020

tACK 0729d1a on Big Sur beta 10 (20A5395g) with Xcode 12.1

@dongcarl
Copy link
Contributor

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?

@willcl-ark
Copy link
Member

I was playing with a commit for the contrib script which adds to CFLAGS as I thought this approach was cleaner too: willcl-ark@266b574

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 0729d1a, tested on macOS Big Sur 11.0 Beta (20A5395g), Xcode 12.1 (12A7403).

@DrahtBot
Copy link
Contributor

Gitian builds

File commit f5bd46a
(master)
commit 8a637ab
(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...

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

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 bitcoin#19411.
@fanquake fanquake force-pushed the bdb_xcode12_implicit_function_decleration branch from 0729d1a to d0a829e Compare October 27, 2020 13:31
@fanquake
Copy link
Member Author

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.

@laanwj
Copy link
Member

laanwj commented Oct 29, 2020

Code review ACK d0a829e

@laanwj laanwj merged commit 5b82f25 into bitcoin:master Oct 29, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 29, 2020
…macOS

d0a829e build: fix mutex detection when building bdb on macOS (fanquake)

Pull request description:

  Starting with the Apple Clang shipped with Xcode 12, [Apple has enabled -Werror=implicit-function-declaration by default](https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes):
  > 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):
  ```bash
  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:
  ```bash
  configure:18704: checking for mutexes
  configure: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
  conftest.c:46:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  main() {
  ^
  conftest.c:51:2: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
          exit (
          ^
  conftest.c:51:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
  1 warning and 1 error generated.
  ```

  Append `-Wno-error=implicit-function-declaration` to `cflags` so that `-Wimplicit-function-declaration` [returns to being a warning](https://clang.llvm.org/docs/UsersManual.html#cmdoption-wno-error), and the configure checks succeed.

  Fixes bitcoin#19411.

ACKs for top commit:
  laanwj:
    Code review ACK d0a829e

Tree-SHA512: 7813005b1fc0b370f843b6c0672acab32c999416e92c3f02b75d866e9c7aa41fe5822704fc74de6b65f0d7d94f2cdd05cc7c3ee83295ff1ecbc71d8492b9a2bf
fanquake added a commit to fanquake/bitcoin that referenced this pull request Oct 30, 2020
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 bitcoin#19411.

Github-Pull: bitcoin#20195
Rebased-From: d0a829e
@fanquake
Copy link
Member Author

Added to #20166 for backporting.

maflcko pushed a commit that referenced this pull request Nov 18, 2020
7566af4 doc: Update data directory path comments (Hennadii Stepanov)
09261de util: Add StripRedundantLastElementsOfPath function (Hennadii Stepanov)
8ef0dac macOS deploy: use the new plistlib API (Jonas Schnelli)
314e795 build: fix mutex detection when building bdb on macOS (fanquake)
1f67a30 random: fixes read buffer resizing in RandAddSeedPerfmon (Ethan Heilman)
6113b54 net: Send post-verack handshake messages at most once (MarcoFalke)
bdf15d0 rpc: Adjust witness-tx deserialize error message (MarcoFalke)
731502a rpc: Properly deserialize txs with witness before signing (MarcoFalke)
ee0082b Avoid the use of abs64 in timedata (Pieter Wuille)
05bd0c2 docs: Correct description for getblockstats's txs field (Nadav Ivgi)

Pull request description:

  Backports the following PRs to the 0.20 branch:
  * #19777 - docs: Correct description for getblockstats's txs field
  * #19836 - rpc: Properly deserialize txs with witness before signing
  * #20080 - Strip any trailing `/` in -datadir and -blocksdir paths
  * #20082 - [bugfix] random: fixes read buffer to use min rather than max
  * #20141 - Avoid the use of abs64 in timedata
  * #20146 - net: Send post-verack handshake messages at most once
  * #20195 - build: fix mutex detection when building bdb on macOS
  * #20298 - macOS deploy: use the new plistlib API

  Will add additional commits as they become available.

ACKs for top commit:
  MarcoFalke:
    review ACK 7566af4 🗡

Tree-SHA512: add6bb978313c12c3e07bc232636ae9d1ab0edd0b816705c5c70eeb1cc04097165fd5e29d60c706886943ceb1f749a422020766b4aa2d23be51e9f839157a4bb
xdustinface pushed a commit to xdustinface/dash that referenced this pull request Feb 17, 2021
…macOS

d0a829e build: fix mutex detection when building bdb on macOS (fanquake)

Pull request description:

  Starting with the Apple Clang shipped with Xcode 12, [Apple has enabled -Werror=implicit-function-declaration by default](https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes):
  > 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):
  ```bash
  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:
  ```bash
  configure:18704: checking for mutexes
  configure: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
  conftest.c:46:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  main() {
  ^
  conftest.c:51:2: error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
          exit (
          ^
  conftest.c:51:2: note: include the header <stdlib.h> or explicitly provide a declaration for 'exit'
  1 warning and 1 error generated.
  ```

  Append `-Wno-error=implicit-function-declaration` to `cflags` so that `-Wimplicit-function-declaration` [returns to being a warning](https://clang.llvm.org/docs/UsersManual.html#cmdoption-wno-error), and the configure checks succeed.

  Fixes bitcoin#19411.

ACKs for top commit:
  laanwj:
    Code review ACK d0a829e

Tree-SHA512: 7813005b1fc0b370f843b6c0672acab32c999416e92c3f02b75d866e9c7aa41fe5822704fc74de6b65f0d7d94f2cdd05cc7c3ee83295ff1ecbc71d8492b9a2bf
@fanquake fanquake deleted the bdb_xcode12_implicit_function_decleration branch June 9, 2021 01:15
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request Jul 2, 2021
07f08d4 build: fix mutex detection when building bdb on macOS (fanquake)
07185c3 build: use -isysroot over --sysroot on macOS (fanquake)
424ea09 depends: Add --sysroot option to mac os native compile flags (Russell Yanofsky)

Pull request description:

  Fixing macOS depends builds, solving #2456 issue.
  Back porting:
  * bitcoin#18743.
  * bitcoin#20195.
  * bitcoin#21793.

ACKs for top commit:
  Fuzzbawls:
    ACK 07f08d4
  random-zebra:
    utACK 07f08d4 and merging...

Tree-SHA512: 2de72a30e8bdfad582b303993eff8384e74d3699992695d6d7a6ec14f0e40898e7e1d70fc6e6a74318eaf21d5e312c346748a4a5986f1f29aa149150e30bdb3f
michelvankessel added a commit to michelvankessel/navcoin-core that referenced this pull request Aug 25, 2021
See bitcoin/bitcoin@d0a829e from bitcoin/bitcoin#20195

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
mxaddict pushed a commit to navcoin/navcoin-core that referenced this pull request Oct 11, 2021
See bitcoin/bitcoin@d0a829e from bitcoin/bitcoin#20195

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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to build BDB 4.8 on macOS Big Sur beta or Xcode 12.0
10 participants