Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: Evaluate removing xcruns in darwin builder #18959

Closed
dongcarl opened this issue May 12, 2020 · 3 comments
Closed

macOS: Evaluate removing xcruns in darwin builder #18959

dongcarl opened this issue May 12, 2020 · 3 comments

Comments

@dongcarl
Copy link
Contributor

dongcarl commented May 12, 2020

When building on macOS, as in, using the depends/builders/darwin.mk, we currently use xcrun to determine the right paths for well-known tools.

build_darwin_CC:=$(shell xcrun -f clang) --sysroot $(shell xcrun --show-sdk-path)
build_darwin_CXX:=$(shell xcrun -f clang++) --sysroot $(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)
build_darwin_OTOOL:=$(shell xcrun -f otool)
build_darwin_NM:=$(shell xcrun -f nm)
build_darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
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) --sysroot $(shell xcrun --show-sdk-path)
darwin_CXX:=$(shell xcrun -f clang++) -mmacosx-version-min=$(OSX_MIN_VERSION) -stdlib=libc++ --sysroot $(shell xcrun --show-sdk-path)
darwin_AR:=$(shell xcrun -f ar)
darwin_RANLIB:=$(shell xcrun -f ranlib)
darwin_STRIP:=$(shell xcrun -f strip)
darwin_LIBTOOL:=$(shell xcrun -f libtool)
darwin_OTOOL:=$(shell xcrun -f otool)
darwin_NM:=$(shell xcrun -f nm)
darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool)
darwin_native_toolchain=

However, it seems like:

  1. We can just invoke the tools directly (e.g. clang vs $(xcrun -f clang))
  2. Invoking tools directly will give have behavior that we expect without extra flags: depends: Add --sysroot option to mac os native compile flags #18743 (comment)

My hypothesis is that the right way to invoke clang on macOS for non-Xcode projects like ours is to invoke it directly (which is what a naive build script would expect), and that $(xcrun -f clang) is being specialized for Xcode, which is why it doesn't work too well without extra flags as seen here: #18743

@ryanofsky
Copy link
Contributor

Practically, how should someone interested in this as a good first issue test the "hypothesis is that the right way to invoke clang" is to invoke it directly? Just drop xcrun calls and verify the depends and bitcoin builds don't fail?

Other thoughts:

  • This doesn't seem to be distinguishing between the build_darwin_CC etc variables used to build build dependencies and the darwin_CC etc variables used to build runtime dependencies. Previously I figured you could get away with not using the SDK for the build dependencies, but would have to use it for the runtime dependencies, especially qt.

  • For more background, Cory (@theuni) first suggested dropping xcrun in Multiprocess build support #16367 (comment), and I think it got a little bit of testing with ryanofsky@04bec8d from that PR and the saga described Multiprocess build support #18677 (comment) ending in depends: Add --sysroot option to mac os native compile flags #18743

  • While it seems silly to keep xcrun calls if they aren't needed, it's also not obvious what advantages would be gained from dropping them if they are working now. (Could be worth expanding issue description if there are advantages this is looking for.)

  • There are other possibilities besides:

    build_darwin_CC:=clang
    build_darwin_CXX:=clang++

    and

    build_darwin_CC:=$(shell xcrun -f clang)
    build_darwin_CXX:=$(shell xcrun -f clang++)

    Another option would be to use the default system compiler, whether or not is clang:

    build_darwin_CC:=cc
    build_darwin_CXX:=c++

    Or just delete these lines, in which case I think they will default automatically to cc c++ ar nm etc.

@ivanacostarubio
Copy link

ivanacostarubio commented Feb 27, 2021

I built the project on macOS Big Sur 11.2.2 after the change above ... it seems ok!

@fanquake
Copy link
Member

fanquake commented Mar 4, 2021

Closing this for now, per discussion in #21341.

@fanquake fanquake closed this as completed Mar 4, 2021
@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

No branches or pull requests

4 participants