Skip to content

Commit

Permalink
Set lto=thin for Rust static builds elsewhere
Browse files Browse the repository at this point in the history
rustc's `lto` flag is incompatible with the new `embed-bitcode=no`. The
release notes for Rust 1.45 recommend controlling LTO with Cargo
profiles, and one way to do that is setting `CARGO_PROFILE_<name>_LTO`
in the environment.
  • Loading branch information
iliana committed Aug 7, 2020
1 parent 23750da commit 8f9306c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion macros/cargo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
%__cargo_env CARGO_TARGET_DIR="${HOME}/.cache" SKIP_README="true"
%__cargo_cross_pkg_config PKG_CONFIG_PATH="%{_cross_pkgconfigdir}" PKG_CONFIG_ALLOW_CROSS=1
%__cargo_cross_env %{__cargo_env} %{__cargo_cross_pkg_config} TARGET_CC="%{_cross_triple}-gnu-gcc"
%__cargo_cross_env_static %{__cargo_env} %{__cargo_cross_pkg_config} TARGET_CC="%{_cross_triple}-musl-gcc"
%__cargo_cross_env_static %{__cargo_env} %{__cargo_cross_pkg_config} TARGET_CC="%{_cross_triple}-musl-gcc" CARGO_PROFILE_RELEASE_LTO=thin

%cargo_prep (\
%{__mkdir} -p %{_builddir}/.cargo \
Expand Down
2 changes: 1 addition & 1 deletion macros/rust
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
%__global_rustflags_shared -Cprefer-dynamic %__global_rustflags

# Enable LTO and static C runtime.
%__global_rustflags_static -Clto=thin -Ctarget-feature=+crt-static -Clink-arg=-lgcc %__global_rustflags
%__global_rustflags_static -Ctarget-feature=+crt-static -Clink-arg=-lgcc %__global_rustflags

%__global_rustflags_shared_toml [%{lua:
for arg in string.gmatch(rpm.expand("%{__global_rustflags_shared}"), "%S+") do
Expand Down

0 comments on commit 8f9306c

Please sign in to comment.