build: make outputs independent of the checkout path - #226
Open
xrviv wants to merge 3 commits into
Open
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.