build: make outputs independent of the checkout path - #226
Conversation
Add -ffile-prefix-map so the absolute build directory is not embedded in compiled objects. The same commit built at different paths currently produces different binaries; see Blockstream#225.
Pass the top-level source root to buildgdk_rust.sh and add --remap-path-prefix so file!() expansions and debug info do not embed the absolute build directory. RUSTFLAGS was assigned rather than appended for Android targets, so caller flags were silently dropped; flags are now collected and applied to whichever source Cargo consults. See Blockstream#225.
Fail rather than silently update Cargo.lock, pinning dependency versions for both security and reproducibility. Requested in Blockstream#225.
|
Hi @jgriffiths — friendly nudge on this one. The three commits are split as you asked: C++ path remap, Rust path remap, and Since opening the PR I also ran a two-root acceptance check on the patched tree. The same commit built at
Neither checkout path appears in the finished artifacts or in the C/C++ object files. Two checks worth calling out specifically: the Rust remap does not discard Android's required These patched hashes are not expected to match the old Scope is the arm64 Android build only; I have not tested other Android architectures, iOS, macOS, Windows or Linux. One other thing worth flagging: no CI has run on this PR at all, so it may be waiting on maintainer approval for workflows from a first-time contributor's fork. Happy to rebase, split things differently, or extend coverage to other targets — just say the word. Build logs available if useful. |
|
Hi @xrviv We have been inundated with questions/scans/reports (many automated/AI) for all products/libraries as a result of the Coldcard issue last week, and have to do due diligence by investigating them all for validity/duplicates etc and mitigation if required. This backlog will take some time to complete. |
Summary
Make GDK’s C++ and Rust outputs independent of the absolute checkout path.
This fixes #225 and allows third parties to reproduce GDK without recreating Blockstream’s CI directory structure.
Problem
GDK embedded its absolute source directory into compiled output.
Using
release_0.77.6, the same source, builder image, dependencies, and build command produced different Android libraries at different checkout paths:libgreen_gdk_java.soSHA-256/root/gdkb60ce800…/root/gdk/gdk440ca6ed…/builds/blockstream/gdkfbcd5f11…/builds/blockstream/green/gdk13d4ba62…Only the final path reproduced the published library.
Changes
-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.to supported C and C++ builds.--remap-path-prefixwithout discarding inherited flags.-L…/libgccflag.CARGO_ENCODED_RUSTFLAGSwhen Cargo uses it instead ofRUSTFLAGS.--lockedto Cargo, as requested in Android release_0.77.6 tarball does not reproduce from documented GitLab CI recipe #225.The C++ and Rust changes are separate commits. I kept
--lockedin a third commit because dependency locking has a separate rationale, but I am happy to fold it into the Rust commit if preferred.Verification
Tested commit
4cf8443ad17aaae66a13a0de2b5f927b925c3d9cwith the pinned builder:I made two clean arm64 Android Release builds with identical inputs but different checkout paths:
/builds/blockstream/green/gdk/root/gdkAll four outputs were byte-for-byte identical:
src/libgreen_gdk.a48ce7e4313decc8220b0479032632a77b7b79e73292619ee147475ecb88d1ab0gdk-rust/libgdk_rust.aa2157fcadb08e9990e277e43a64e8c7819450665faeab6e6439d71c9d7471f45libgreen_gdk_java.so1aa34e6fd3f565f759350909d16ee57ee58aa4c4d709f5b211b7b49a4515644elibgreen_gdk_java.syms48b8dcb14034b1c0b7eb52c86e4f838d5958348923e01271add8201875c99ac5Additional checks:
--remap-path-prefixfor each build.-L…/libgccflag remained present.--locked..symsfile still resolved a machine address to a real function and source line.The patched hashes are intentionally different from the old release hash because path remapping changes the recorded strings. The relevant result is that the two patched builds match each other.
Scope
The acceptance test covers the arm64 Android Release build. No wallet behavior, protocol handling, or key-management code is changed.