Inject linker script to generate package notes

https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects
Macros are used only if defined. Definitions are provided in the
package-notes-srpm-macros, which is now Required (on Fedora).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2022-01-13 14:05:52 +01:00
parent 9183c1c8d4
commit 57edf0cad7
3 changed files with 23 additions and 2 deletions

View File

@ -246,6 +246,22 @@ it is possible to add `-fcommon` to the flags by defining `%_legacy_common_suppo
Properly fixing the failure is always preferred!
### Package note on ELF objects
A note that describes the package name, version, and architecture is
inserted via a linker script (`%_package_note_file`). The script is
generated when `%set_build_flags` is called. The linker option that
injects the linker script is added to `%{build_ldflags}` via the
`%{_package_note_flags}` macro.
To opt out of the use of the linker script, include this in the spec file:
%undefine _package_note_flags
To opt out of generation of the linker script, include this in the spec file:
%undefine _generate_package_note_file
### Post-build ELF object processing
By default, DWARF debugging information is separated from installed

3
macros
View File

@ -72,7 +72,7 @@
# When clang is used as a linker driver, it does not auto-detect the LTO
# bytecode and neither does bfd, so we need to explicitly pass the -flto
# flag when linking.
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_lto_cflags}" : "" ] %{_build_id_flags}
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_lto_cflags}" : "" ] %{_build_id_flags} %{?_package_note_flags}
# Expands to shell code to set the compiler/linker environment
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have
@ -80,6 +80,7 @@
# been set implicitly at the start of the %%build section.
# LT_SYS_LIBRARY_PATH is used by libtool script.
%set_build_flags \
%{?_generate_package_note_file} ; \
CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \

View File

@ -6,7 +6,7 @@
Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config
Version: 208
Version: 209
Release: 1%{?dist}
# No version specified.
License: GPL+
@ -102,6 +102,7 @@ Requires: rpmautospec-rpm-macros
Requires: fpc-srpm-macros
Requires: gnat-srpm-macros
Requires: nim-srpm-macros
Requires: package-notes-srpm-macros
%endif
Requires: rpm >= 4.11.0
@ -190,6 +191,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
%doc buildflags.md
%changelog
* Thu Jan 13 2022 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 209-1
- Add package ELF note to the default LDFLAGS
* Tue Jan 04 2022 Tom Stellard <tstellar@redhat.com> - 208-1
- Call %%set_build_flags before %%build, %%check, and %%install stages