Skip to content

Commit

Permalink
merge bitcoin#30201: remove FORCE_USE_SYSTEM_CLANG
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Dec 31, 2024
1 parent 8e53003 commit e0af33a
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 107 deletions.
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8

export CONTAINER_NAME=ci_macos_cross
export HOST=x86_64-apple-darwin
export PACKAGES="cmake zip"
export PACKAGES="clang cmake lld llvm zip"
export XCODE_VERSION=15.0
export XCODE_BUILD_ID=15A240d
export RUN_UNIT_TESTS=false
Expand Down
6 changes: 3 additions & 3 deletions contrib/devtools/symbol-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ def check_MACHO_sdk(binary) -> bool:
return True
return False

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

Expand Down Expand Up @@ -295,7 +295,7 @@ def check_ELF_ABI(binary) -> bool:
('DYNAMIC_LIBRARIES', check_MACHO_libraries),
('MIN_OS', check_MACHO_min_os),
('SDK', check_MACHO_sdk),
('LD64', check_MACHO_ld64),
('LLD', check_MACHO_lld),
],
lief.EXE_FORMATS.PE: [
('DYNAMIC_LIBRARIES', check_PE_libraries),
Expand Down
3 changes: 1 addition & 2 deletions contrib/guix/libexec/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ make -C depends --jobs="$JOBS" HOST="$HOST" \
x86_64_linux_AR=x86_64-linux-gnu-gcc-ar \
x86_64_linux_RANLIB=x86_64-linux-gnu-gcc-ranlib \
x86_64_linux_NM=x86_64-linux-gnu-gcc-nm \
x86_64_linux_STRIP=x86_64-linux-gnu-strip \
FORCE_USE_SYSTEM_CLANG=1
x86_64_linux_STRIP=x86_64-linux-gnu-strip


###########################
Expand Down
6 changes: 3 additions & 3 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ inspecting signatures in Mach-O binaries.")
((string-contains target "darwin")
(list ;; Native GCC 11 toolchain
gcc-toolchain-11
clang-toolchain-17
lld-17
(make-lld-wrapper lld-17 #:lld-as-ld? #t)
clang-toolchain-18
lld-18
(make-lld-wrapper lld-18 #:lld-as-ld? #t)
python-signapple
zip))
(else '())))))
2 changes: 0 additions & 2 deletions depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ all_packages = $(packages) $(native_packages)

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

$(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain)

include funcs.mk

final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in)
Expand Down
11 changes: 4 additions & 7 deletions depends/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ The paths are automatically configured and no other options are needed unless ta

#### For macOS cross compilation

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

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

#### For Win64 cross compilation
Expand Down Expand Up @@ -124,9 +124,6 @@ The following can be set when running make: `make FOO=bar`
- `DEBUG`: Disable some optimizations and enable more runtime checking
- `HOST_ID_SALT`: Optional salt to use when generating host package ids
- `BUILD_ID_SALT`: Optional salt to use when generating build package ids
- `FORCE_USE_SYSTEM_CLANG`: (EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the
system's `$PATH` rather than the default prebuilt release of Clang
from llvm.org. Clang 8 or later is required
- `LOG`: Use file-based logging for individual packages. During a package build its log file
resides in the `depends` directory, and the log file is printed out automatically in case
of build error. After successful build log files are moved along with package archives
Expand Down
1 change: 0 additions & 1 deletion depends/builders/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ darwin_STRIP:=$(shell xcrun -f strip)
darwin_OBJDUMP:=$(shell xcrun -f objdump)
darwin_NM:=$(shell xcrun -f nm)
darwin_DSYMUTIL:=$(shell xcrun -f dsymutil)
darwin_native_toolchain=

x86_64_darwin_CFLAGS += -arch x86_64
x86_64_darwin_CXXFLAGS += -arch x86_64
Expand Down
5 changes: 1 addition & 4 deletions depends/funcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ endef

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

#create build targets
$(foreach package,$(all_packages),$(eval $(call int_add_cmds,$(package))))

#special exception: if a toolchain package exists, all non-native packages depend on it
$(foreach package,$(packages),$(eval $($(package)_extracted): |$($($(host_arch)_$(host_os)_native_toolchain)_cached) ))
46 changes: 3 additions & 43 deletions depends/hosts/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,10 @@ OSX_MIN_VERSION=11.0
OSX_SDK_VERSION=14.0
XCODE_VERSION=15.0
XCODE_BUILD_ID=15A240d
LD64_VERSION=711
LLD_VERSION=711

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

ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),)
# FORCE_USE_SYSTEM_CLANG is empty, so we use our depends-managed, pinned LLVM
# from llvm.org

darwin_native_toolchain=native_llvm

clang_prog=$(build_prefix)/bin/clang
clangxx_prog=$(clang_prog)++
llvm_config_prog=$(build_prefix)/bin/llvm-config

llvm_TOOLS=AR NM OBJDUMP RANLIB STRIP

# Make-only lowercase function
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))))))))))))))))))))))))))

# For well-known tools provided by LLVM, make sure that their well-known
# variable is set to the full path of the tool, just like how AC_PATH_{TOO,PROG}
# would.
$(foreach TOOL,$(llvm_TOOLS),$(eval darwin_$(TOOL) = $$(build_prefix)/bin/llvm-$(call lc,$(TOOL))))

# Clang expects dsymutil to be called dsymutil
darwin_DSYMUTIL=$(build_prefix)/bin/dsymutil

else
# FORCE_USE_SYSTEM_CLANG is non-empty, so we use the clang from the user's
# system

darwin_native_toolchain=

# We can't just use $(shell command -v clang) because GNU Make handles builtins
# in a special way and doesn't know that `command` is a POSIX-standard builtin
# prior to 1af314465e5dfe3e8baa839a32a72e83c04f26ef, first released in v4.2.90.
Expand All @@ -44,17 +15,13 @@ darwin_native_toolchain=
# Source: https://lists.gnu.org/archive/html/bug-make/2017-11/msg00017.html
clang_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang")
clangxx_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v clang++")
llvm_config_prog=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-config")

llvm_lib_dir=$(shell $(llvm_config_prog) --libdir)

darwin_AR=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ar")
darwin_DSYMUTIL=$(shell $(SHELL) $(.SHELLFLAGS) "command -v dsymutil")
darwin_NM=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-nm")
darwin_OBJDUMP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-objdump")
darwin_RANLIB=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-ranlib")
darwin_STRIP=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-strip")
endif

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

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

ifneq ($(build_os),darwin)
darwin_CFLAGS += -mlinker-version=$(LD64_VERSION)
darwin_CXXFLAGS += -mlinker-version=$(LD64_VERSION)
darwin_CFLAGS += -mlinker-version=$(LLD_VERSION)
darwin_CXXFLAGS += -mlinker-version=$(LLD_VERSION)
darwin_LDFLAGS += -Wl,-no_adhoc_codesign -fuse-ld=lld
endif

Expand Down
31 changes: 0 additions & 31 deletions depends/packages/native_llvm.mk

This file was deleted.

10 changes: 0 additions & 10 deletions depends/packages/packages.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,3 @@ multiprocess_packages = libmultiprocess capnp
multiprocess_native_packages = native_libmultiprocess native_capnp

usdt_linux_packages=systemtap

darwin_native_packages =

ifneq ($(build_os),darwin)

ifeq ($(strip $(FORCE_USE_SYSTEM_CLANG)),)
darwin_native_packages+= native_llvm
endif

endif

0 comments on commit e0af33a

Please sign in to comment.