Include linker flags for package note in %build_rustflags

%build_rustflags was used in %cargo_prep, which is executed in %prep,
when %buildsubdir is not set yet. To avoid this, insertion of flags is
moved to an environment variable that is set for %cargo_build and
%cargo_test.

The linker flag gets passed to rustc, and resulting binaries seem to have
note as expected.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-02-14 22:12:49 +01:00
parent 9d72601698
commit e1f911661f
2 changed files with 4 additions and 3 deletions

View file

@ -4,7 +4,7 @@
# it never writes to ~/.cargo during rpmbuild. # it never writes to ~/.cargo during rpmbuild.
# We also need RUSTC_BOOTSTRAP since we use -Z avoid-dev-deps # We also need RUSTC_BOOTSTRAP since we use -Z avoid-dev-deps
# until it gets stabilized: https://github.com/rust-lang/cargo/issues/5133 # until it gets stabilized: https://github.com/rust-lang/cargo/issues/5133
%__cargo %{_bindir}/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 %{_bindir}/cargo %__cargo %{_bindir}/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='%{build_rustflags}' %{_bindir}/cargo
%__cargo_common_opts %{?_smp_mflags} -Z avoid-dev-deps %__cargo_common_opts %{?_smp_mflags} -Z avoid-dev-deps
%__cargo_inspector %{_bindir}/cargo-inspector %__cargo_inspector %{_bindir}/cargo-inspector
@ -20,7 +20,6 @@ cat > .cargo/config << EOF \
[build]\ [build]\
rustc = "%{__rustc}"\ rustc = "%{__rustc}"\
rustdoc = "%{__rustdoc}"\ rustdoc = "%{__rustdoc}"\
rustflags = %{__global_rustflags_toml}\
\ \
[env]\ [env]\
CFLAGS = "%{build_cflags}"\ CFLAGS = "%{build_cflags}"\

View file

@ -5,7 +5,9 @@
%build_rustflags %{shrink: %build_rustflags %{shrink:
-Copt-level=3 -Copt-level=3
-Cdebuginfo=2 -Cdebuginfo=2
-Clink-arg=-Wl,-z,relro,-z,now -Clink-arg=-Wl,-z,relro
-Clink-arg=-Wl,-z,now
%{?_package_note_file:-Clink-arg=-Wl,-dT,%{_package_note_file}}
-Ccodegen-units=1 -Ccodegen-units=1
--cap-lints=warn --cap-lints=warn
} }