Skip to content

Commit

Permalink
revert darwin changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobtoht committed Dec 10, 2024
1 parent 56b6e5b commit d5ab49b
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 125 deletions.
29 changes: 10 additions & 19 deletions contrib/depends/hosts/darwin.mk
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
OSX_MIN_VERSION=11
OSX_MIN_VERSION=10.13
OSX_SDK_VERSION=11.0
XCODE_VERSION=12.2
XCODE_BUILD_ID=12B45b
LD64_VERSION=711
LD64_VERSION=609

OSX_SDK=$(host_prefix)/native/SDK

darwin_native_toolchain=darwin_sdk
darwin_native_toolchain=darwin_sdk native_cctools

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")

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")
darwin_LIBTOOL=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-libtool-darwin")

# Flag explanations:
#
Expand Down Expand Up @@ -46,23 +37,23 @@ darwin_LIBTOOL=$(shell $(SHELL) $(.SHELLFLAGS) "command -v llvm-libtool-darwin")
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 \
$(clang_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
-isysroot$(OSX_SDK) \
-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 \
$(clangxx_prog) --target=$(host) -mmacosx-version-min=$(OSX_MIN_VERSION) \
-B$(build_prefix)/bin -mlinker-version=$(LD64_VERSION) \
-isysroot$(OSX_SDK) -nostdlibinc \
-iwithsysroot/usr/include/c++/v1 \
-iwithsysroot/usr/include -iframeworkwithsysroot/System/Library/Frameworks

darwin_CFLAGS=-pipe -std=c11 -mmacosx-version-min=$(OSX_MIN_VERSION) -mlinker-version=$(LD64_VERSION)
darwin_CXXFLAGS=-pipe -std=c++17 -mmacosx-version-min=$(OSX_MIN_VERSION) -mlinker-version=$(LD64_VERSION)
darwin_LDFLAGS=-Wl,-platform_version,macos,$(OSX_MIN_VERSION),$(OSX_SDK_VERSION) -Wl,-no_adhoc_codesign -fuse-ld=lld
darwin_CFLAGS=-pipe
darwin_CXXFLAGS=$(darwin_CFLAGS)
darwin_ARFLAGS=cr

darwin_release_CFLAGS=-O2
Expand Down
6 changes: 0 additions & 6 deletions contrib/depends/packages/darwin_sdk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ $(package)_version=12.2
$(package)_download_path=https://bitcoincore.org/depends-sources/sdks
$(package)_file_name=Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz
$(package)_sha256_hash=df75d30ecafc429e905134333aeae56ac65fac67cb4182622398fd717df77619
$(package)_patches=setup.sh

define $(package)_config_cmds
env host_prefix="$(host_prefix)" host="$(host)" bash $($(package)_patch_dir)/setup.sh
endef

define $(package)_stage_cmds
mkdir -p $($(package)_staging_dir)/$(host_prefix)/native/SDK &&\
rm -rf usr/include/readline && \
mv bin $($(package)_staging_dir)/$(host_prefix)/native/ && \
mv * $($(package)_staging_dir)/$(host_prefix)/native/SDK
endef
19 changes: 5 additions & 14 deletions contrib/depends/packages/libusb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ $(package)_version=1.0.27
$(package)_download_path=https://github.com/libusb/libusb/releases/download/v$($(package)_version)
$(package)_file_name=$(package)-$($(package)_version).tar.bz2
$(package)_sha256_hash=ffaa41d741a8a3bee244ac8e54a72ea05bf2879663c098c82fc5757853441575
$(package)_patches=no-c11.patch

ifeq ($(host_os),darwin)
define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/no-c11.patch && \
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . && \
autoreconf -i
endef
else
define $(package)_preprocess_cmds
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . && \
autoreconf -i
endef
endif
define $(package)_preprocess_cmds
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . && \
autoreconf -i
endef

define $(package)_set_vars
$(package)_config_opts=--disable-shared
Expand All @@ -27,7 +18,7 @@ define $(package)_set_vars
endef

define $(package)_config_cmds
$($(package)_autoconf) ac_c_dialect=c
$($(package)_autoconf) AR_FLAGS=$($(package)_arflags)
endef

define $(package)_build_cmd
Expand Down
37 changes: 37 additions & 0 deletions contrib/depends/packages/native_cctools.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package=native_cctools
$(package)_version=04663295d0425abfac90a42440a7ec02d7155fea
$(package)_download_path=https://github.com/tpoechtrager/cctools-port/archive
$(package)_download_file=$($(package)_version).tar.gz
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=70a7189418c2086d20c299c5d59250cf5940782c778892ccc899c66516ed240e
$(package)_build_subdir=cctools
$(package)_patches=no-build-date.patch
$(package)_dependencies=native_libtapi

define $(package)_set_vars
$(package)_config_opts=--target=$(host) --disable-lto-support --with-libtapi=$(host_prefix)
$(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib
$(package)_cc=$(clang_prog)
$(package)_cxx=$(clangxx_prog)
endef

define $(package)_preprocess_cmds
cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub cctools
endef

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/no-build-date.patch
endef

define $(package)_config_cmds
$($(package)_autoconf)
endef

define $(package)_build_cmds
$(MAKE)
endef

define $(package)_stage_cmds
$(MAKE) DESTDIR=$($(package)_staging_dir) install && \
cp $($(package)_extract_dir)/cctools/misc/install_name_tool $($(package)_staging_prefix_dir)/bin/
endef
19 changes: 19 additions & 0 deletions contrib/depends/packages/native_libtapi.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package=native_libtapi
$(package)_version=664b8414f89612f2dfd35a9b679c345aa5389026
$(package)_download_path=https://github.com/tpoechtrager/apple-libtapi/archive
$(package)_download_file=$($(package)_version).tar.gz
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=62e419c12d1c9fad67cc1cd523132bc00db050998337c734c15bc8d73cc02b61
$(package)_patches=no_embed_git_rev.patch

define $(package)_preprocess_cmds
patch -p1 -i $($(package)_patch_dir)/no_embed_git_rev.patch
endef

define $(package)_build_cmds
CC=$(clang_prog) CXX=$(clangxx_prog) INSTALLPREFIX=$($(package)_staging_prefix_dir) ./build.sh
endef

define $(package)_stage_cmds
./install.sh
endef
1 change: 0 additions & 1 deletion contrib/depends/packages/openssl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ $(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$(
$(package)_config_env_android=ANDROID_NDK_ROOT="$(toolchain_prefix)" PATH="$(toolchain_prefix)/bin"
$(package)_build_env_android=ANDROID_NDK_ROOT="$(toolchain_prefix)"
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl --libdir=$(host_prefix)/lib
$(package)_config_opts+=no-asm
$(package)_config_opts+=no-capieng
$(package)_config_opts+=no-dso
$(package)_config_opts+=no-dtls1
Expand Down
2 changes: 1 addition & 1 deletion contrib/depends/packages/packages.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ mingw32_packages = $(hardware_packages)
mingw32_native_packages = $(hardware_native_packages)

ifneq ($(build_os),darwin)
darwin_native_packages += darwin_sdk
darwin_native_packages += darwin_sdk native_cctools native_libtapi
endif
2 changes: 1 addition & 1 deletion contrib/depends/packages/unbound.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ define $(package)_preprocess_cmds
endef

define $(package)_config_cmds
$($(package)_autoconf) ac_cv_func_getentropy=no
$($(package)_autoconf) ac_cv_func_getentropy=no AR_FLAGS=$($(package)_arflags)
endef

define $(package)_build_cmds
Expand Down
3 changes: 2 additions & 1 deletion contrib/depends/packages/zeromq.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ define $(package)_set_vars
$(package)_config_opts=--without-documentation --disable-shared --without-libsodium --disable-curve
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_freebsd=--with-pic
$(package)_cxxflags=-std=c++11
endef

define $(package)_config_cmds
$($(package)_autoconf)
$($(package)_autoconf) AR_FLAGS=$($(package)_arflags)
endef

define $(package)_build_cmds
Expand Down
24 changes: 0 additions & 24 deletions contrib/depends/patches/darwin_sdk/setup.sh

This file was deleted.

35 changes: 0 additions & 35 deletions contrib/depends/patches/libusb/no-c11.patch

This file was deleted.

12 changes: 12 additions & 0 deletions contrib/depends/patches/native_cctools/no-build-date.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/cctools/ld64/src/ld/Options.cpp b/cctools/ld64/src/ld/Options.cpp
index 3bb8324..033760d 100644
--- a/cctools/ld64/src/ld/Options.cpp
+++ b/cctools/ld64/src/ld/Options.cpp
@@ -4279,7 +4279,6 @@ void Options::buildSearchPaths(int argc, const char* argv[])
fVerbose = true;
extern const char ldVersionString[];
fprintf(stderr, "%s", ldVersionString);
- fprintf(stderr, "BUILD " __TIME__ " " __DATE__"\n");
fprintf(stderr, "configured to support archs: %s\n", ALL_SUPPORTED_ARCHS);
// if only -v specified, exit cleanly
if ( argc == 2 ) {
31 changes: 31 additions & 0 deletions contrib/depends/patches/native_libtapi/no_embed_git_rev.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/src/llvm/CMakeLists.txt b/src/llvm/CMakeLists.txt
index ab92717c8..4ad621ea3 100644
--- a/src/llvm/CMakeLists.txt
+++ b/src/llvm/CMakeLists.txt
@@ -752,9 +752,10 @@ set(LLVM_SRPM_USER_BINARY_SPECFILE ${CMAKE_CURRENT_SOURCE_DIR}/llvm.spec.in
set(LLVM_SRPM_BINARY_SPECFILE ${CMAKE_CURRENT_BINARY_DIR}/llvm.spec)
set(LLVM_SRPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/srpm")

-# SVN_REVISION and GIT_COMMIT get set by the call to add_version_info_from_vcs.
-# DUMMY_VAR contains a version string which we don't care about.
-add_version_info_from_vcs(DUMMY_VAR)
+# A call to add_version_info_from_vcs() was removed, leaving SVN_REVISION
+# and GIT_COMMIT unset. Accordingly, LLVM_RPM_SPEC_REVISION is left empty.
+# This variable appears to be unused. Since it may be used in a future
+# update of native_libtapi this change serves as a precautionairy measure.
if ( SVN_REVISION )
set(LLVM_RPM_SPEC_REVISION "r${SVN_REVISION}")
elseif ( GIT_COMMIT )
diff --git a/src/llvm/cmake/modules/GenerateVersionFromCVS.cmake b/src/llvm/cmake/modules/GenerateVersionFromCVS.cmake
index 6b1c71983..e16326ed6 100644
--- a/src/llvm/cmake/modules/GenerateVersionFromCVS.cmake
+++ b/src/llvm/cmake/modules/GenerateVersionFromCVS.cmake
@@ -24,7 +24,7 @@ include(VersionFromVCS)
set(ENV{TERM} "dumb")

function(append_info name path)
- add_version_info_from_vcs(REVISION ${path})
+ set(REVISION "git-0000000")
string(STRIP "${REVISION}" REVISION)
file(APPEND "${HEADER_FILE}.txt"
"#define ${name} \"${REVISION}\"\n")
23 changes: 4 additions & 19 deletions contrib/depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,35 +82,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(_CMAKE_TOOLCHAIN_PREFIX @prefix@/native/bin/${CONF_TRIPLE}-)
SET(CMAKE_C_COMPILER @CC@)
SET(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_C_FLAGS_INIT "@CFLAGS@")
SET(CMAKE_C_FLAGS "@CFLAGS@")
SET(CMAKE_C_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
SET(CMAKE_CXX_COMPILER @CXX@ -stdlib=libc++)
SET(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_CXX_FLAGS_INIT @CXXFLAGS@)
SET(CMAKE_CXX_FLAGS "@CXXFLAGS@")

set(CMAKE_EXE_LINKER_FLAGS_INIT " -L/usr/lib @LDFLAGS@ -v")
set(CMAKE_MODULE_LINKER_FLAGS_INIT " -L/usr/lib @LDFLAGS@ -v")
set(CMAKE_SHARED_LINKER_FLAGS_INIT " -L/usr/lib @LDFLAGS@ -v")

SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")

set(CMAKE_EXE_LINKER_FLAGS " -L/usr/lib @LDFLAGS@ -v")
set(CMAKE_MODULE_LINKER_FLAGS "-L/usr/lib @LDFLAGS@ -v")
set(CMAKE_SHARED_LINKER_FLAGS "-L/usr/lib @LDFLAGS@ -v")

set(CMAKE_INSTALL_NAME_TOOL llvm-install-name-tool)

SET(CMAKE_CXX_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
SET(CMAKE_ASM_COMPILER clang)
SET(CMAKE_ASM-ATT_COMPILER llvm-as)
SET(CMAKE_ASM-ATT_COMPILER as)
SET(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET})
SET(CMAKE_ASM-ATT_COMPILER_TARGET ${CLANG_TARGET})
SET(APPLE True)
SET(BUILD_64 ON)
SET(BREW OFF)
SET(PORT OFF)
SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "11")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
SET(CMAKE_CXX_STANDARD 17)
SET(LLVM_ENABLE_PIC OFF)
SET(LLVM_ENABLE_PIE OFF)
Expand Down
25 changes: 24 additions & 1 deletion contrib/guix/libexec/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,20 @@ for p in "${PATHS[@]}"; do
done

# Disable Guix ld auto-rpath behavior
export GUIX_LD_WRAPPER_DISABLE_RPATH=yes
case "$HOST" in
*darwin*)
# The auto-rpath behavior is necessary for darwin builds as some native
# tools built by depends refer to and depend on Guix-built native
# libraries
#
# After the native packages in depends are built, the ld wrapper should
# no longer affect our build, as clang would instead reach for
# x86_64-apple-darwin-ld from cctools
;;
*android*)
;;
*) export GUIX_LD_WRAPPER_DISABLE_RPATH=yes ;;
esac

# Make /usr/bin if it doesn't exist
[ -e /usr/bin ] || mkdir -p /usr/bin
Expand Down Expand Up @@ -193,6 +206,16 @@ export GLIBC_DYNAMIC_LINKER=${glibc_dynamic_linker}
# Environment variables for determinism
export TAR_OPTIONS="--owner=0 --group=0 --numeric-owner --mtime='@${SOURCE_DATE_EPOCH}' --sort=name"
export TZ="UTC"
case "$HOST" in
*darwin*)
# cctools AR, unlike GNU binutils AR, does not have a deterministic mode
# or a configure flag to enable determinism by default, it only
# understands if this env-var is set or not. See:
#
# https://github.com/tpoechtrager/cctools-port/blob/55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/ar/archive.c#L334
export ZERO_AR_DATE=yes
;;
esac

####################
# Depends Building #
Expand Down
5 changes: 2 additions & 3 deletions contrib/guix/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ chain for " target " development."))
(list
gcc-toolchain-11
(list gcc-toolchain-12 "static")
clang-toolchain-17
lld-17
(make-lld-wrapper lld-17 #:lld-as-ld? #t)))
clang-toolchain-11
binutils))
(else '())))))

0 comments on commit d5ab49b

Please sign in to comment.