@@ -6,20 +6,28 @@ LD64_VERSION=711
66
77OSX_SDK =$(SDK_PATH ) /Xcode-$(XCODE_VERSION ) -$(XCODE_BUILD_ID ) -extracted-SDK-with-libcxx-headers
88
9- darwin_native_binutils =native_cctools
10-
119ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG ) ) ,)
12- # FORCE_USE_SYSTEM_CLANG is empty, so we use our depends-managed, pinned clang
10+ # FORCE_USE_SYSTEM_CLANG is empty, so we use our depends-managed, pinned LLVM
1311# from llvm.org
1412
15- # Clang is a dependency of native_cctools when FORCE_USE_SYSTEM_CLANG is empty
16- darwin_native_toolchain =native_cctools
13+ darwin_native_toolchain =native_llvm
1714
1815clang_prog =$(build_prefix ) /bin/clang
1916clangxx_prog =$(clang_prog ) ++
2017llvm_config_prog =$(build_prefix ) /bin/llvm-config
2118
22- darwin_OBJDUMP =$(build_prefix ) /bin/$(host ) -objdump
19+ llvm_TOOLS =AR NM OBJDUMP RANLIB STRIP
20+
21+ # Make-only lowercase function
22+ lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
23+
24+ # For well-known tools provided by LLVM, make sure that their well-known
25+ # variable is set to the full path of the tool, just like how AC_PATH_{TOO,PROG}
26+ # would.
27+ $(foreach TOOL,$(llvm_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/llvm-$(call lc,$(TOOL))))
28+
29+ # Clang expects dsymutil to be called dsymutil
30+ darwin_DSYMUTIL =$(build_prefix ) /bin/dsymutil
2331
2432else
2533# FORCE_USE_SYSTEM_CLANG is non-empty, so we use the clang from the user's
@@ -40,19 +48,14 @@ llvm_config_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-config")
4048
4149llvm_lib_dir =$(shell $(llvm_config_prog ) --libdir)
4250
51+ darwin_AR =$(shell $(SHELL ) $(.SHELLFLAGS ) "command -v llvm-ar")
52+ darwin_DSYMUTIL =$(shell $(SHELL ) $(.SHELLFLAGS ) "command -v dsymutil")
53+ darwin_NM =$(shell $(SHELL ) $(.SHELLFLAGS ) "command -v llvm-nm")
4354darwin_OBJDUMP =$(shell $(SHELL ) $(.SHELLFLAGS ) "command -v llvm-objdump")
55+ darwin_RANLIB =$(shell $(SHELL ) $(.SHELLFLAGS ) "command -v llvm-ranlib")
56+ darwin_STRIP =$(shell $(SHELL ) $(.SHELLFLAGS ) "command -v llvm-strip")
4457endif
4558
46- cctools_TOOLS =AR RANLIB STRIP NM DSYMUTIL
47-
48- # Make-only lowercase function
49- lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
50-
51- # For well-known tools provided by cctools, make sure that their well-known
52- # variable is set to the full path of the tool, just like how AC_PATH_{TOO,PROG}
53- # would.
54- $(foreach TOOL,$(cctools_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/$$(host)-$(call lc,$(TOOL))))
55-
5659# Flag explanations:
5760#
5861# -mlinker-version
@@ -62,7 +65,7 @@ $(foreach TOOL,$(cctools_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/$$(
6265#
6366# -B$(build_prefix)/bin
6467#
65- # Explicitly point to our binaries (e.g. cctools) so that they are
68+ # Explicitly point to our binaries so that they are
6669# ensured to be found and preferred over other possibilities.
6770#
6871# -isysroot$(OSX_SDK) -nostdlibinc
@@ -79,6 +82,11 @@ $(foreach TOOL,$(cctools_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/$$(
7982#
8083# Indicate to the linker the platform, the oldest supported version,
8184# and the SDK used.
85+ #
86+ # -no_adhoc_codesign
87+ #
88+ # Disable adhoc codesigning (for now) when using LLVM tooling, to avoid
89+ # non-determinism issues with the Identifier field.
8290
8391darwin_CC =env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
8492 -u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
@@ -104,6 +112,7 @@ darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION)
104112ifneq ($(build_os ) ,darwin)
105113darwin_CFLAGS += -mlinker-version=$(LD64_VERSION )
106114darwin_CXXFLAGS += -mlinker-version=$(LD64_VERSION )
115+ darwin_LDFLAGS += -Wl,-no_adhoc_codesign -fuse-ld=lld
107116endif
108117
109118darwin_release_CFLAGS =-O2
0 commit comments