From 60d0d4f965b136a1e69541c9da9be6a02cdd80df Mon Sep 17 00:00:00 2001 From: RAVI SHANKAR BEJINI <130489622+unspecifiedcoder@users.noreply.github.com> Date: Sat, 21 Nov 2026 09:41:44 +0000 Subject: [PATCH] build: link chain archives before the common archive Emit the common archive after Bitcoin and Elements so GNU ld can resolve their references with test-utils enabled. Keep shared sources compiled once. Written with assistance from Codex (OpenAI). --- simplicity-sys/build.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/simplicity-sys/build.rs b/simplicity-sys/build.rs index c7d67534..b117c7bf 100644 --- a/simplicity-sys/build.rs +++ b/simplicity-sys/build.rs @@ -119,16 +119,6 @@ fn main() { build.include("wasm-sysroot"); } - // Chain-independent code goes in its own library, which each chain's library links against. - // Compiling it into every chain's library instead breaks the MSRV build: Rust 1.74 links native - // libraries with --whole-archive, so the duplicate objects collide. - build - .clone() - .files(sources(Library::Common)) - .file("depend/wrapper.c") - .file("depend/jets_wrapper.c") - .compile("RustSimplicityCommon"); - // Build the Bitcoin transaction environment's library. build .clone() @@ -137,7 +127,18 @@ fn main() { .compile("BitcoinSimplicity"); build + .clone() .files(sources(Library::Elements)) .file("depend/env.c") .compile("ElementsSimplicity"); + + // Chain-independent code goes in its own library, which each chain's library links against. + // Emit it last so linkers that scan archives in order can resolve the chain libraries' symbols. + // Compiling it into every chain's library instead breaks the MSRV build: Rust 1.74 links native + // libraries with --whole-archive, so the duplicate objects collide. + build + .files(sources(Library::Common)) + .file("depend/wrapper.c") + .file("depend/jets_wrapper.c") + .compile("RustSimplicityCommon"); }