Skip to content

Commit

Permalink
Add -isysroot to macOS native compile flags (#1203)
Browse files Browse the repository at this point in the history
* depends: Add --sysroot option to mac os native compile flags

Catalina SDK clang stopped automatically searching the SDK include paths when
invoked without --sysroot:

bitcoin/bitcoin#16367 (comment)
Homebrew/homebrew-core#45061

This hasn't been a problem for current native depends packages because are
passing their own --sysroot values, and hasn't been a problem for current host
packages because they use `darwin_` commands instead of `build_darwin_`
commands.  But the current `build_darwin_CC` and `build_darwin_CXX` commands
are still unnecessarily fragile, and incompatible with new native depends
packages added in bitcoin/bitcoin#18677.

Cory Fields <[email protected]> suggested in
bitcoin/bitcoin#16367 (comment) switching
compiler from SDK clang to native clang (from $PATH) to avoid this problem.
This is easy and makes a certain amount of sense for building native packages,
as opposed to host packages. But fanquake <[email protected]> pointed out in
bitcoin/bitcoin#18677 (comment) that it
would be inconsistent use switch to non-SDK compilers while still using other
SDK tools like ranlib and install_name_tool. So simplest, minimal fix seems to
be just adding the missing --sysroot option.

* build: use -isysroot over --sysroot on macOS

Co-authored-by: Russell Yanofsky <[email protected]>
Co-authored-by: fanquake <[email protected]>
Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
4 people authored Apr 28, 2022
1 parent 43158cd commit e92bcf9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions depends/builders/darwin.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build_darwin_CC:=$(shell xcrun -f clang)
build_darwin_CXX:=$(shell xcrun -f clang++)
build_darwin_CC:=$(shell xcrun -f clang) -isysroot$(shell xcrun --show-sdk-path)
build_darwin_CXX:=$(shell xcrun -f clang++) -isysroot$(shell xcrun --show-sdk-path)
build_darwin_AR:=$(shell xcrun -f ar)
build_darwin_RANLIB:=$(shell xcrun -f ranlib)
build_darwin_STRIP:=$(shell xcrun -f strip)
Expand All @@ -10,8 +10,8 @@ build_darwin_SHA256SUM=shasum -a 256
build_darwin_DOWNLOAD=curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o

#darwin host on darwin builder. overrides darwin host preferences.
darwin_CC=$(shell xcrun -f clang) -mmacosx-version-min=$(OSX_MIN_VERSION)
darwin_CXX:=$(shell xcrun -f clang++) -mmacosx-version-min=$(OSX_MIN_VERSION) -stdlib=libc++
darwin_CC=$(shell xcrun -f clang) -mmacosx-version-min=$(OSX_MIN_VERSION) -isysroot$(shell xcrun --show-sdk-path)
darwin_CXX:=$(shell xcrun -f clang++) -mmacosx-version-min=$(OSX_MIN_VERSION) -stdlib=libc++ -isysroot$(shell xcrun --show-sdk-path)
darwin_AR:=$(shell xcrun -f ar)
darwin_RANLIB:=$(shell xcrun -f ranlib)
darwin_STRIP:=$(shell xcrun -f strip)
Expand Down

0 comments on commit e92bcf9

Please sign in to comment.