X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=deterministic-build-wrappers%2Frustc;fp=deterministic-build-wrappers%2Frustc;h=2f356770fa0bf90512667c0fd2a02a2f94ba02a9;hp=0000000000000000000000000000000000000000;hb=bcbf891d3fd4452080692bbb980864ceeaeb0736;hpb=4d85902c5191f9139c2d0be26c040ada0f19117f diff --git a/deterministic-build-wrappers/rustc b/deterministic-build-wrappers/rustc new file mode 100755 index 0000000..2f35677 --- /dev/null +++ b/deterministic-build-wrappers/rustc @@ -0,0 +1,30 @@ +#!/bin/bash +# rustc calculates a unique metadata tag to mangle symbols which includes the +# actual path to the crate. This breaks our deterministic builds as we depend +# on a copy of rust-lightning via a path. We insert this shim between cargo and +# rustc and edit the metadata tag for rust-lightning. +# While we could just set RUSTFLAGS="-C metadata=42", this would break if we +# ever (indirectly) depend on multiple versions of the same crate. +args=("$@") +IS_LIGHTNING=false +for ((i=0; i<"${#args[@]}"; ++i)); do + case ${args[i]} in + --crate-name) + if [ "${args[i+1]}" = "lightning" ]; then + IS_LIGHTNING=true + fi + ;; + esac +done +for ((i=0; i<"${#args[@]}"; ++i)); do + case ${args[i]} in + metadata*) + if [ "$IS_LIGHTNING" = "true" ]; then + # Pick any random value for metadata, it doesn't matter + args[i]="metadata=42" + fi + ;; + esac +done + +/usr/bin/rustc "${args[@]}"