Skip to content

Commit 9fe3124

Browse files
committed
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
1 parent 722a366 commit 9fe3124

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

genbindings.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ else
167167
fi
168168

169169
# Now build with LTO on on both C++ and rust, but without cross-language LTO:
170-
cargo rustc -v --release -- -C lto
170+
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C lto
171171
clang++ -std=c++11 -Wall -flto -O2 -pthread demo.cpp target/release/libldk.a -ldl
172172
echo "C++ Bin size and runtime with only RL (LTO) optimized:"
173173
ls -lha a.out
@@ -179,7 +179,7 @@ if [ "$HOST_PLATFORM" != "host: x86_64-apple-darwin" -a "$CLANGPP" != "" ]; then
179179
# or Ubuntu packages). This should work fine on Distros which do more involved
180180
# packaging than simply shipping the rustup binaries (eg Debian should Just Work
181181
# here).
182-
cargo rustc -v --release -- -C linker-plugin-lto -C lto -C link-arg=-fuse-ld=lld
182+
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C linker-plugin-lto -C lto -C link-arg=-fuse-ld=lld
183183
$CLANGPP -Wall -std=c++11 -flto -fuse-ld=lld -O2 -pthread demo.cpp target/release/libldk.a -ldl
184184
echo "C++ Bin size and runtime with cross-language LTO:"
185185
ls -lha a.out

0 commit comments

Comments
 (0)