Skip to content

Commit

Permalink
Avoid dependencies of build-deps on MacOS by pinning cc
Browse files Browse the repository at this point in the history
Sadly we have to hack around cargo to make this work with
`-Zbuild-std`.
  • Loading branch information
TheBlueMatt committed Oct 5, 2023
1 parent 849a253 commit bc731d6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion genbindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,20 @@ if [ "$HOST_PLATFORM" = "x86_64-unknown-linux-gnu" ]; then
LLVM_V=$(rustc +nightly --version --verbose | grep "LLVM version" | awk '{ print substr($3, 0, 2); }')
if [ -x "$(which clang-$LLVM_V)" ]; then
cargo +nightly clean
cargo +nightly rustc $CARGO_BUILD_ARGS -Zbuild-std=std,panic_abort --target x86_64-unknown-linux-gnu -v -- -Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes
# -Zbuild-std fails if we have any dependencies of build-deps, which
# cc added in 1.0.80, thus we pin back to 1.0.79 to avoid that.
pushd lightning-c-bindings
cargo update -p cc --precise "1.0.79" --verbose
popd
# Sadly, std also depends on cc, and we can't pin it in that tree
# directly. Instead, we have to delete the file out of the cargo
# registry and build --offline to avoid it using the latest version.
NEW_CC_DEP="$CARGO_HOME"
[ "$NEW_CC_DEP" = "" ] && NEW_CC_DEP="$HOME"
mv "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-1.0.79.crate ./
rm -f "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/cc-*.crate
mv ./cc-1.0.79.crate "$NEW_CC_DEP/.cargo/registry/cache/github.com-"*/
cargo +nightly rustc --offline $CARGO_BUILD_ARGS -Zbuild-std=std,panic_abort --target x86_64-unknown-linux-gnu -v -- -Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes
mv target/x86_64-unknown-linux-gnu/debug/libldk.* target/debug/

# Sadly, std doesn't seem to compile into something that is memsan-safe as of Aug 2020,
Expand Down

0 comments on commit bc731d6

Please sign in to comment.