Skip to content

Commit 7fa6374

Browse files
committed
Merge bitcoin#2280: [Depends] Cleanup Rust and add multi-arch linux support
92bebbe Use statically linked rust toolchain (Fuzzbawls) 7dd7161 Depends: allow for non-x86_64 build hosts for rust linux (Fuzzbawls) fc7acb3 [Depends] Switch to `cargo vendor` for Rust dependencies (Fuzzbawls) Pull request description: The first commit here comes from zcash/zcash#4725 and provides a significant cleanup in terms of number of files needed in the depends tree. The second commit re-works the way we fetch the Rust dependencies to allow depends to be built for linux on non-x86_64 systems. Currently I've compiled native toolchains for `x86_64`, `arm`, `armv7`, and `aarch64` The third commit addresses bitcoin#2127 by re-compiling the rust toolchains with static linking. The fourth commit is temporary, and will be removed prior to merging. Top commit has no ACKs. Tree-SHA512: c3143bc02f230e7b96f66fcaeebd27912be71e37ae354c9c211364a99f545788af8f3be93131f590ec24c02da7f05dbecc632ebc9a0b45b5c8de70cdc3feefe1
2 parents ee62d8e + 92bebbe commit 7fa6374

File tree

78 files changed

+117
-1231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+117
-1231
lines changed

depends/Makefile

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ HASH_LENGTH:=11
4848
DOWNLOAD_CONNECT_TIMEOUT:=30
4949
DOWNLOAD_RETRIES:=3
5050
CRATE_REGISTRY:=vendored-sources
51+
CRATE_ARCHIVE = $(SOURCES_PATH)/vendored-crates.tar.gz
5152
HOST_ID_SALT ?= salt
5253
BUILD_ID_SALT ?= salt
5354

54-
LIBRUSTZCASH_OVERRIDE ?=
5555

5656
host:=$(BUILD)
5757
ifneq ($(HOST),)
@@ -135,7 +135,7 @@ natpmp_packages_$(NO_NATPMP) = $(natpmp_packages)
135135

136136
zmq_packages_$(NO_ZMQ) = $(zmq_packages)
137137

138-
packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(rust_packages) $(wallet_packages_) $(upnp_packages_) $(natpmp_packages_)
138+
packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_) $(natpmp_packages_)
139139
native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages)
140140

141141
ifneq ($(qt_packages_),)
@@ -169,6 +169,12 @@ $(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages)
169169
$(AT)echo copying packages: $^
170170
$(AT)echo to: $(@D)
171171
$(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); )
172+
$(AT)if test -f "$(CRATE_ARCHIVE)"; \
173+
then echo Extracting pre-vendored crates from $(CRATE_ARCHIVE)...; \
174+
tar xf $(CRATE_ARCHIVE) -C $(@D); \
175+
else echo Vendoring crates...; \
176+
$(@D)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(@D)/$(CRATE_REGISTRY); \
177+
fi
172178
$(AT)touch $@
173179

174180
$(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id)
@@ -186,7 +192,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
186192
-e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \
187193
-e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \
188194
-e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \
189-
-e 's|@rust_target@|$(call rust_target,rust,$(canonical_host),$(host_os))|' \
195+
-e 's|@rust_target@|$(call rust_target,native_rust,$(canonical_host),$(host_os))|' \
190196
-e 's|@allow_host_packages@|$(ALLOW_HOST_PACKAGES)|' \
191197
-e 's|@no_qt@|$(NO_QT)|' \
192198
-e 's|@no_zmq@|$(NO_ZMQ)|' \
@@ -213,9 +219,13 @@ define check_or_remove_sources
213219
endef
214220

215221
check-packages:
216-
@$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));)
222+
@$(foreach package,$(packages),$(call check_or_remove_cached,$(package));)
223+
@$(foreach package,$(rust_crates),$(call check_or_remove_cached,$(package));)
224+
@$(foreach package,$(native_packages),$(call check_or_remove_cached,$(package));)
217225
check-sources:
218-
@$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));)
226+
@$(foreach package,$(packages),$(call check_or_remove_sources,$(package));)
227+
@$(foreach package,$(rust_crates),$(call check_or_remove_sources,$(package));)
228+
@$(foreach package,$(native_packages),$(call check_or_remove_sources,$(package));)
219229

220230
$(host_prefix)/share/config.site: check-packages
221231

@@ -230,6 +240,18 @@ clean:
230240
install: check-packages $(host_prefix)/share/config.site
231241

232242

243+
crates_download_dir=$(base_download_dir)/crates
244+
download-crates: native_rust
245+
$(AT)echo Vendoring crates...
246+
$(AT)mkdir -p $(SOURCES_PATH)
247+
$(AT)rm -rf $(crates_download_dir)
248+
$(AT)mkdir -p $(crates_download_dir)
249+
$(AT)tar xf $(native_rust_cached) -C $(crates_download_dir)
250+
$(AT)$(crates_download_dir)/native/bin/cargo vendor --locked --manifest-path $(BASEDIR)/../Cargo.toml $(crates_download_dir)/$(CRATE_REGISTRY)
251+
$(AT)cd $(crates_download_dir); find $(CRATE_REGISTRY) | sort | tar --no-recursion -czf $(CRATE_ARCHIVE) -T -
252+
$(AT)rm -rf $(crates_download_dir)
253+
254+
233255
download-one: check-sources $(all_sources)
234256

235257
download-osx:
@@ -238,8 +260,8 @@ download-linux:
238260
@$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one
239261
download-win:
240262
@$(MAKE) -s HOST=x86_64-w64-mingw32 download-one
241-
download: download-osx download-linux download-win
263+
download: download-crates download-osx download-linux download-win
242264

243265
$(foreach package,$(all_packages),$(eval $(call ext_add_stages,$(package))))
244266

245-
.PHONY: install cached clean clean-all download-one download-osx download-linux download-win download check-packages check-sources
267+
.PHONY: install cached clean clean-all download-crates download-one download-osx download-linux download-win download check-packages check-sources

depends/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ build script logic) are searched for among the host system packages using
9595
`pkg-config`. It allows building with packages of other (newer) versions</dd>
9696
<dt>DEBUG</dt>
9797
<dd>disable some optimizations and enable more runtime checking</dd>
98-
<dt>LIBRUSTZCASH_OVERRIDE</dt>
99-
<dd>Path to a local librustzcash repository</dd>
10098
<dt>HOST_ID_SALT</dt>
10199
<dd>Optional salt to use when generating host package ids</dd>
102100
<dt>BUILD_ID_SALT</dt>

depends/funcs.mk

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,6 @@ define fetch_file
3434
$(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(3),$(4),$(5))))
3535
endef
3636

37-
define generate_crate_checksum
38-
$(BASEDIR)/cargo-checksum.sh "$($(1)_file_name)" "$(build_SHA256SUM)" "\"$($(1)_sha256_hash)\""
39-
endef
40-
41-
define generate_unpackaged_crate_checksum
42-
$(BASEDIR)/cargo-checksum.sh "$($(1)_file_name)" "$(build_SHA256SUM)" "null"
43-
endef
44-
45-
define vendor_crate_source
46-
mkdir -p $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY) && \
47-
cp -r $($(1)_extract_dir) $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_name) && \
48-
cd $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_versioned_name) && \
49-
rm -r `basename $($(1)_patch_dir)` .stamp_* .$($(1)_file_name).hash
50-
endef
51-
5237
define int_get_build_recipe_hash
5338
$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) | cut -d" " -f1))
5439
$(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1))
@@ -65,11 +50,11 @@ final_build_id_long+=$($(package)_build_id_long)
6550
#override platform specific files and hashes
6651
$(eval $(1)_file_name=$(if $($(1)_exact_file_name),$($(1)_exact_file_name),$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name))))
6752
$(eval $(1)_sha256_hash=$(if $($(1)_exact_sha256_hash),$($(1)_exact_sha256_hash),$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash))))
53+
$(eval $(1)_download_file=$(if $($(1)_exact_download_file),$($(1)_exact_download_file),$(if $($(1)_download_file_$(host_os)),$($(1)_download_file_$(host_os)),$(if $($(1)_download_file),$($(1)_download_file),$($(1)_file_name)))))
6854

6955

7056
#compute package-specific paths
7157
$(1)_build_subdir?=.
72-
$(1)_download_file?=$($(1)_file_name)
7358
$(1)_source_dir:=$(SOURCES_PATH)
7459
$(1)_source:=$$($(1)_source_dir)/$($(1)_file_name)
7560
$(1)_staging_dir=$(base_staging_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)

depends/packages/crate_aes.mk

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

depends/packages/crate_aes_soft.mk

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

depends/packages/crate_aesni.mk

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

depends/packages/crate_arrayref.mk

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

depends/packages/crate_arrayvec.mk

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

depends/packages/crate_autocfg.mk

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

depends/packages/crate_bellman.mk

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

0 commit comments

Comments
 (0)