Skip to content

Commit 337f9d4

Browse files
committed
Merge bitcoin/bitcoin#30201: depends: remove FORCE_USE_SYSTEM_CLANG
7cbfd7a refactor: rename (macho) ld64 to lld (fanquake) d851451 ci: update deps for macOS cross build (fanquake) 9ebdd5e depends: update install docs for macOS cross compilation (fanquake) fb74fd6 depends: remove no-longer used llvm_* vars from macOS build (fanquake) 9043f12 depends: no-longer pass -B to clang in macOS cross-compile (fanquake) f9994b0 depends: remove native LLVM package (fanquake) e9a44fa depends: remove FORCE_USE_SYSTEM_CLANG (fanquake) 9946618 guix: use clang-toolchain-18 for macOS build (fanquake) Pull request description: Remove `FORCE_USE_SYSTEM_CLANG` in favour of always using the system Clang and lld for macOS cross-compilation; rather than downloading precompiled blobs. For example, anyone using Ubuntu 24.04 should be able to `apt install clang llvm lld .. etc`, and then cross-compile for macOS using: ```bash # clang --version Ubuntu clang version 18.1.3 (1) make -C depends HOST=arm64-apple-darwin FORCE_USE_SYSTEM_CLANG=1 ./autogen.sh CONFIG_SITE=/path/to/depends/arm64-apple-darwin/share/config.site ./configure make # file src/qt/bitcoin-qt src/qt/bitcoin-qt: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE|HAS_TLV_DESCRIPTORS> ``` Note that the minimum supported version of Clang we will support for macOS cross-compilation will likely be more recent than our other minimum supported version of Clang, due to compiler/linker option usage. ACKs for top commit: Sjors: tACK 7cbfd7a theuni: ACK 7cbfd7a TheCharlatan: Nice, ACK 7cbfd7a Tree-SHA512: 1499e29b3b238c5c85278c38e8fb6bb5e7883db3443f62b6bf397c5d761bedbc054962be645a9defce15266f0a969bb4b3ccd28b6e4dd874472857b928f185d1
2 parents 5bc9b64 + 7cbfd7a commit 337f9d4

File tree

11 files changed

+17
-108
lines changed

11 files changed

+17
-108
lines changed

ci/test/00_setup_env_mac_cross.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export LC_ALL=C.UTF-8
99
export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
1010

1111
export CONTAINER_NAME=ci_macos_cross
12-
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:22.04"
12+
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:24.04"
1313
export HOST=x86_64-apple-darwin
14-
export PACKAGES="zip"
14+
export PACKAGES="clang lld llvm zip"
1515
export XCODE_VERSION=15.0
1616
export XCODE_BUILD_ID=15A240d
1717
export RUN_UNIT_TESTS=false

contrib/devtools/symbol-check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ def check_MACHO_sdk(binary) -> bool:
239239
return True
240240
return False
241241

242-
def check_MACHO_ld64(binary) -> bool:
243-
if binary.build_version.tools[0].version == [17, 0, 6]:
242+
def check_MACHO_lld(binary) -> bool:
243+
if binary.build_version.tools[0].version == [18, 1, 6]:
244244
return True
245245
return False
246246

@@ -282,7 +282,7 @@ def check_ELF_ABI(binary) -> bool:
282282
('DYNAMIC_LIBRARIES', check_MACHO_libraries),
283283
('MIN_OS', check_MACHO_min_os),
284284
('SDK', check_MACHO_sdk),
285-
('LD64', check_MACHO_ld64),
285+
('LLD', check_MACHO_lld),
286286
],
287287
lief.EXE_FORMATS.PE: [
288288
('DYNAMIC_LIBRARIES', check_PE_libraries),

contrib/guix/libexec/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ make -C depends --jobs="$JOBS" HOST="$HOST" \
178178
x86_64_linux_AR=x86_64-linux-gnu-gcc-ar \
179179
x86_64_linux_RANLIB=x86_64-linux-gnu-gcc-ranlib \
180180
x86_64_linux_NM=x86_64-linux-gnu-gcc-nm \
181-
x86_64_linux_STRIP=x86_64-linux-gnu-strip \
182-
FORCE_USE_SYSTEM_CLANG=1
181+
x86_64_linux_STRIP=x86_64-linux-gnu-strip
183182

184183

185184
###########################

contrib/guix/manifest.scm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ inspecting signatures in Mach-O binaries.")
532532
((string-contains target "darwin")
533533
(list ;; Native GCC 11 toolchain
534534
gcc-toolchain-11
535-
clang-toolchain-17
536-
lld-17
537-
(make-lld-wrapper lld-17 #:lld-as-ld? #t)
535+
clang-toolchain-18
536+
lld-18
537+
(make-lld-wrapper lld-18 #:lld-as-ld? #t)
538538
python-signapple
539539
zip))
540540
(else '())))))

depends/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ all_packages = $(packages) $(native_packages)
181181

182182
meta_depends = Makefile config.guess config.sub funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk
183183

184-
$(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)
185-
186184
include funcs.mk
187185

188186
final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)

depends/README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ The paths are automatically configured and no other options are needed.
4949

5050
#### For macOS cross compilation
5151

52-
sudo apt-get install g++ zip
52+
apt install clang lld llvm g++ zip
5353

54-
Note: You must obtain the macOS SDK before proceeding with a cross-compile.
55-
Under the depends directory, create a subdirectory named `SDKs`.
56-
Then, place the extracted SDK under this new directory.
54+
Clang 18 or later is required. You must also obtain the macOS SDK before
55+
proceeding with a cross-compile. Under the depends directory, create a
56+
subdirectory named `SDKs`. Then, place the extracted SDK under this new directory.
5757
For more information, see [SDK Extraction](../contrib/macdeploy/README.md#sdk-extraction).
5858

5959
#### For Win64 cross compilation
@@ -119,9 +119,6 @@ The following can be set when running make: `make FOO=bar`
119119
- `DEBUG`: Disable some optimizations and enable more runtime checking
120120
- `HOST_ID_SALT`: Optional salt to use when generating host package ids
121121
- `BUILD_ID_SALT`: Optional salt to use when generating build package ids
122-
- `FORCE_USE_SYSTEM_CLANG`: (EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the
123-
system's `$PATH` rather than the default prebuilt release of Clang
124-
from llvm.org. Clang 8 or later is required
125122
- `LOG`: Use file-based logging for individual packages. During a package build its log file
126123
resides in the `depends` directory, and the log file is printed out automatically in case
127124
of build error. After successful build log files are moved along with package archives

depends/builders/darwin.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ darwin_STRIP:=$(shell xcrun -f strip)
1818
darwin_OBJDUMP:=$(shell xcrun -f objdump)
1919
darwin_NM:=$(shell xcrun -f nm)
2020
darwin_DSYMUTIL:=$(shell xcrun -f dsymutil)
21-
darwin_native_toolchain=
2221

2322
x86_64_darwin_CFLAGS += -arch x86_64
2423
x86_64_darwin_CXXFLAGS += -arch x86_64

depends/funcs.mk

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ endef
4646

4747
define int_get_build_id
4848
$(eval $(1)_dependencies += $($(1)_$(host_arch)_$(host_os)_dependencies) $($(1)_$(host_os)_dependencies))
49-
$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($($(1)_type)_native_toolchain) $($(1)_dependencies)))
49+
$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($(1)_dependencies)))
5050
$(foreach dep,$($(1)_all_dependencies),$(eval $(1)_build_id_deps+=$(dep)-$($(dep)_version)-$($(dep)_recipe_hash)))
5151
$(eval $(1)_build_id_long:=$(1)-$($(1)_version)-$($(1)_recipe_hash)-$(release_type) $($(1)_build_id_deps) $($($(1)_type)_id))
5252
$(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH)))
@@ -297,6 +297,3 @@ $(foreach package,$(all_packages),$(eval $(call int_config_attach_build_config,$
297297

298298
#create build targets
299299
$(foreach package,$(all_packages),$(eval $(call int_add_cmds,$(package))))
300-
301-
#special exception: if a toolchain package exists, all non-native packages depend on it
302-
$(foreach package,$(packages),$(eval $($(package)_extracted): |$($($(host_arch)_$(host_os)_native_toolchain)_cached) ))

depends/hosts/darwin.mk

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,10 @@ OSX_MIN_VERSION=11.0
22
OSX_SDK_VERSION=14.0
33
XCODE_VERSION=15.0
44
XCODE_BUILD_ID=15A240d
5-
LD64_VERSION=711
5+
LLD_VERSION=711
66

77
OSX_SDK=$(SDK_PATH)/Xcode-$(XCODE_VERSION)-$(XCODE_BUILD_ID)-extracted-SDK-with-libcxx-headers
88

9-
ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),)
10-
# FORCE_USE_SYSTEM_CLANG is empty, so we use our depends-managed, pinned LLVM
11-
# from llvm.org
12-
13-
darwin_native_toolchain=native_llvm
14-
15-
clang_prog=$(build_prefix)/bin/clang
16-
clangxx_prog=$(clang_prog)++
17-
llvm_config_prog=$(build_prefix)/bin/llvm-config
18-
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
31-
32-
else
33-
# FORCE_USE_SYSTEM_CLANG is non-empty, so we use the clang from the user's
34-
# system
35-
36-
darwin_native_toolchain=
37-
389
# We can't just use $(shell command -v clang) because GNU Make handles builtins
3910
# in a special way and doesn't know that `command` is a POSIX-standard builtin
4011
# prior to 1af314465e5dfe3e8baa839a32a72e83c04f26ef, first released in v4.2.90.
@@ -44,17 +15,13 @@ darwin_native_toolchain=
4415
# Source: https://lists.gnu.org/archive/html/bug-make/2017-11/msg00017.html
4516
clang_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang")
4617
clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
47-
llvm_config_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-config")
48-
49-
llvm_lib_dir=$(shell $(llvm_config_prog) --libdir)
5018

5119
darwin_AR=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ar")
5220
darwin_DSYMUTIL=$(shell $(SHELL) $(.SHELLFLAGS) "command -v dsymutil")
5321
darwin_NM=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-nm")
5422
darwin_OBJDUMP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-objdump")
5523
darwin_RANLIB=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ranlib")
5624
darwin_STRIP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-strip")
57-
endif
5825

5926
# Flag explanations:
6027
#
@@ -63,11 +30,6 @@ endif
6330
# Ensures that modern linker features are enabled. See here for more
6431
# details: https://github.com/bitcoin/bitcoin/pull/19407.
6532
#
66-
# -B$(build_prefix)/bin
67-
#
68-
# Explicitly point to our binaries so that they are
69-
# ensured to be found and preferred over other possibilities.
70-
#
7133
# -isysroot$(OSX_SDK) -nostdlibinc
7234
#
7335
# Disable default include paths built into the compiler as well as
@@ -92,15 +54,13 @@ darwin_CC=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
9254
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
9355
-u LIBRARY_PATH \
9456
$(clang_prog) --target=$(host) \
95-
-B$(build_prefix)/bin \
9657
-isysroot$(OSX_SDK) -nostdlibinc \
9758
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
9859

9960
darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
10061
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
10162
-u LIBRARY_PATH \
10263
$(clangxx_prog) --target=$(host) \
103-
-B$(build_prefix)/bin \
10464
-isysroot$(OSX_SDK) -nostdlibinc \
10565
-iwithsysroot/usr/include/c++/v1 \
10666
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks
@@ -110,8 +70,8 @@ darwin_CXXFLAGS=-pipe -std=$(CXX_STANDARD) -mmacosx-version-min=$(OSX_MIN_VERSIO
11070
darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION)
11171

11272
ifneq ($(build_os),darwin)
113-
darwin_CFLAGS += -mlinker-version=$(LD64_VERSION)
114-
darwin_CXXFLAGS += -mlinker-version=$(LD64_VERSION)
73+
darwin_CFLAGS += -mlinker-version=$(LLD_VERSION)
74+
darwin_CXXFLAGS += -mlinker-version=$(LLD_VERSION)
11575
darwin_LDFLAGS += -Wl,-no_adhoc_codesign -fuse-ld=lld
11676
endif
11777

depends/packages/native_llvm.mk

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)