From 9fe3124eb701de6e7c371aff50e211864b78ccdd Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 23 Nov 2020 10:20:10 -0500 Subject: [PATCH] Use CARGO_PROFILE_RELEASE_LTO to fix bindings build on new cargo Newer versions of cargo broke `cargo rustc -- -Clto` by passing `-Cembed-bitcode=no` even in `--release`. Its somewhat unclear why this is still the case on latest cargo given it broke, at least, compilation of Firefox, as discovered by Val at [1]. We take the approach they used there, even though they later walked it back [2] but the issues noted there, especially in [3] don't seem particularly concerning in our case. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1640982 [2] https://bugzilla.mozilla.org/show_bug.cgi?id=1654465 [3] https://bugzilla.mozilla.org/show_bug.cgi?id=1654465#c5 --- genbindings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/genbindings.sh b/genbindings.sh index 010296584..ae2a23578 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -167,7 +167,7 @@ else fi # Now build with LTO on on both C++ and rust, but without cross-language LTO: -cargo rustc -v --release -- -C lto +CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C lto clang++ -std=c++11 -Wall -flto -O2 -pthread demo.cpp target/release/libldk.a -ldl echo "C++ Bin size and runtime with only RL (LTO) optimized:" ls -lha a.out @@ -179,7 +179,7 @@ if [ "$HOST_PLATFORM" != "host: x86_64-apple-darwin" -a "$CLANGPP" != "" ]; then # or Ubuntu packages). This should work fine on Distros which do more involved # packaging than simply shipping the rustup binaries (eg Debian should Just Work # here). - cargo rustc -v --release -- -C linker-plugin-lto -C lto -C link-arg=-fuse-ld=lld + CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C linker-plugin-lto -C lto -C link-arg=-fuse-ld=lld $CLANGPP -Wall -std=c++11 -flto -fuse-ld=lld -O2 -pthread demo.cpp target/release/libldk.a -ldl echo "C++ Bin size and runtime with cross-language LTO:" ls -lha a.out -- 2.39.5