Files
dragonx/depends/packages/librustzcash.mk
DanS ac95106abe build(win): make the mingw cross-compile link and find librustzcash
Three things broke the x86_64-w64-mingw32 build; two are real and fixed
here (the third was a stale-object contamination from building Linux and
Windows in the same tree, resolved by a clean rebuild — not a code fix).

1. Single-pass mingw ld could not resolve the cross-references DragonX
   added between the internal static archives (libbitcoin_util/common
   objects pulling in UniValue; util<->common mutual deps). GNU ld on
   Linux re-scans archives so it never surfaced; ld64 on macOS rejects
   the grouping flag outright. Bracket each binary's _LDADD in
   -Wl,--start-group/--end-group, delivered via AC_SUBST(LINK_GROUP_*)
   so automake does not reject the linker flag inside _LDADD, and left
   empty on every non-Windows target.

2. The Rust build emits the mingw archive as rustzcash.lib, but the
   link line asks for -lrustzcash, i.e. librustzcash.a. Normalize the
   staged filename to librustzcash.a for every host (a no-op on
   Linux/macOS, where the basename was already librustzcash.a).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-27 03:56:23 -05:00

59 lines
2.3 KiB
Makefile

package=librustzcash
$(package)_version=0.1
$(package)_download_path=https://github.com/zcash/$(package)/archive/
$(package)_file_name=$(package)-$($(package)_git_commit).tar.gz
$(package)_download_file=$($(package)_git_commit).tar.gz
$(package)_sha256_hash=9909ec59fa7a411c2071d6237b3363a0bc6e5e42358505cf64b7da0f58a7ff5a
$(package)_git_commit=06da3b9ac8f278e5d4ae13088cf0a4c03d2c13f5
$(package)_dependencies=rust $(rust_crates)
$(package)_patches=cargo.config 0001-Start-using-cargo-clippy-for-CI.patch remove-dev-dependencies.diff no-groth16.patch
$(package)_rust_target=$(if $(rust_rust_target_$(canonical_host)),$(rust_rust_target_$(canonical_host)),$(canonical_host))
ifeq ($(host_os),mingw32)
$(package)_library_file=target/x86_64-pc-windows-gnu/release/rustzcash.lib
else ifneq ($(canonical_host),$(build))
ifeq ($(host_os),darwin)
$(package)_library_file=target/x86_64-apple-darwin/release/librustzcash.a
else
$(package)_library_file=target/$($(package)_rust_target)/release/librustzcash.a
endif
else
$(package)_library_file=target/release/librustzcash.a
endif
define $(package)_set_vars
$(package)_build_opts=--frozen --release
ifneq ($(canonical_host),$(build))
ifeq ($(host_os),darwin)
$(package)_build_opts+=--target=x86_64-apple-darwin
else
$(package)_build_opts+=--target=$($(package)_rust_target)
endif
endif
endef
define $(package)_preprocess_cmds
patch -p1 -d pairing < $($(package)_patch_dir)/0001-Start-using-cargo-clippy-for-CI.patch && \
patch -p1 < $($(package)_patch_dir)/remove-dev-dependencies.diff && \
mkdir .cargo && \
cat $($(package)_patch_dir)/cargo.config | sed 's|CRATE_REGISTRY|$(host_prefix)/$(CRATE_REGISTRY)|' > .cargo/config
endef
ifeq ($(build_os),darwin)
define $(package)_build_cmds
CARGO=$(HOME)/.cargo/bin/cargo RUSTC=$(HOME)/.cargo/bin/rustc $(HOME)/.cargo/bin/cargo build --package librustzcash $($(package)_build_opts)
endef
else
define $(package)_build_cmds
$(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts)
endef
endif
define $(package)_stage_cmds
mkdir $($(package)_staging_dir)$(host_prefix)/lib/ && \
mkdir $($(package)_staging_dir)$(host_prefix)/include/ && \
cp $($(package)_library_file) $($(package)_staging_dir)$(host_prefix)/lib/librustzcash.a && \
cp librustzcash/include/librustzcash.h $($(package)_staging_dir)$(host_prefix)/include/
endef