From 363ddf0a1c1ed1a26f70d95d06e841b30eacad17 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Tue, 26 Dec 2023 21:53:47 +0100 Subject: [PATCH 1/4] Add zig-srpm-macros --- redhat-rpm-config.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 62241d0..0e8c200 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -4,7 +4,7 @@ # 2) When making changes, increment the version (in baserelease) by 1. # rpmdev-bumpspec and other tools update the macro below, which is used # in Version: to get the desired effect. -%global baserelease 271 +%global baserelease 272 Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config @@ -114,6 +114,7 @@ Requires: pyproject-srpm-macros Requires: fpc-srpm-macros Requires: gnat-srpm-macros Requires: ansible-srpm-macros +Requires: zig-srpm-macros %endif Requires: rpm >= 4.11.0 @@ -255,6 +256,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua %doc buildflags.md %changelog +* Tue Dec 26 2023 Jan Drögehoff - 272-1 +- Add zig-srpm-macros + * Fri Nov 03 2023 Stephen Gallagher - 271-1 - ELN: Enable frame pointers for RHEL 11+ (for now) From 5fca01af521462ee2cd2b29963312890512c288a Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 2 Jan 2024 16:44:30 +0100 Subject: [PATCH 2/4] Pack relative ELF relocations by default Leftover from the Fedora 39 toolchain changes. --- buildflags.md | 13 +++++++++++++ macros | 5 ++++- redhat-rpm-config.spec | 5 ++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/buildflags.md b/buildflags.md index 1a13c60..811e1cb 100644 --- a/buildflags.md +++ b/buildflags.md @@ -290,6 +290,16 @@ For example, this can be required if shared objects are used for their side effects in ELF constructors, or for making them available to dynamically loaded plugins. +### Switching to legacy relative relocations + +By default, ELF objects use the architecture-independent `DT_RELR` +mechanism for relative relocations. To switch to the older, +architecture-specific relocation scheme, add this to the RPM spec file: + + %undefine _ld_pack_relocs + +This adds `-Wl,-z,pack-relative-relocs` to the linker flags (`LDFLAGS`). + ### Specifying the build-id algorithm If you want to specify a different build-id algorithm for your builds, you @@ -631,6 +641,9 @@ to the compiler driver `gcc`, and not directly to the link editor for shared objects that actually provide symbols required by the link. Shared objects which are not needed to fulfill symbol dependencies are essentially ignored due to this flag. +* `-z pack-relative-relocs`: Use the portable `DT_RELR` scheme for + relative relocations, resulting in reduced startup time compared to + legacy architecture-specific relocations. * `-z defs`: Refuse to link shared objects (DSOs) with undefined symbols (optional, see above). diff --git a/macros b/macros index 0e75747..95b5ceb 100644 --- a/macros +++ b/macros @@ -79,7 +79,7 @@ # the flags, while intended for ld, are still passed through the gcc # compiler driver. At the beginning of %%build, the environment # variable RPM_LD_FLAGS to this value. -%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags} %{?_distro_extra_ldflags} +%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_ld_pack_relocs_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags} %{?_distro_extra_ldflags} # Expands to shell code to set the compiler/linker environment # variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they @@ -372,6 +372,9 @@ for k,_ in pairs(stripped_flags) do print(k .. " ") end %_ld_as_needed 1 %_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed} +%_ld_pack_relocs 1 +%_ld_pack_relocs_flags %{?_ld_pack_relocs:-Wl,-z,pack-relative-relocs} + # LTO is the default in Fedora. # "%define _lto_cflags %{nil}" to opt out # diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 0e8c200..49169d1 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -4,7 +4,7 @@ # 2) When making changes, increment the version (in baserelease) by 1. # rpmdev-bumpspec and other tools update the macro below, which is used # in Version: to get the desired effect. -%global baserelease 272 +%global baserelease 273 Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config @@ -256,6 +256,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua %doc buildflags.md %changelog +* Tue Jan 2 2024 Florian Weimer - 273-1 +- Pack relative ELF relocations by default + * Tue Dec 26 2023 Jan Drögehoff - 272-1 - Add zig-srpm-macros From 4daef93aa92347a850cb60b625f5d4993c6267e6 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 3 Jan 2024 17:18:20 +0100 Subject: [PATCH 3/4] Missing packed relative relocation support on aarch64, s390x (#2256645) --- buildflags.md | 3 ++- macros | 5 +++-- redhat-rpm-config.spec | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/buildflags.md b/buildflags.md index 811e1cb..4e53c85 100644 --- a/buildflags.md +++ b/buildflags.md @@ -643,7 +643,8 @@ to the compiler driver `gcc`, and not directly to the link editor are essentially ignored due to this flag. * `-z pack-relative-relocs`: Use the portable `DT_RELR` scheme for relative relocations, resulting in reduced startup time compared to - legacy architecture-specific relocations. + legacy architecture-specific relocations. (`-z pack-relative-relocs` + is currently disabled on aarch64 and s390x due to toolchain limitations.) * `-z defs`: Refuse to link shared objects (DSOs) with undefined symbols (optional, see above). diff --git a/macros b/macros index 95b5ceb..2eca9bb 100644 --- a/macros +++ b/macros @@ -372,8 +372,9 @@ for k,_ in pairs(stripped_flags) do print(k .. " ") end %_ld_as_needed 1 %_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed} -%_ld_pack_relocs 1 -%_ld_pack_relocs_flags %{?_ld_pack_relocs:-Wl,-z,pack-relative-relocs} +# aarch64 and s390x currently do not support packed relocations. +%_ld_pack_relocs %[ "%{_arch}" == "x86_64" || "%{_arch}" == "i386" || "%{_arch}" == "ppc64le" ] +%_ld_pack_relocs_flags %[0%{?_ld_pack_relocs} ? "-Wl,-z,pack-relative-relocs" : ""] # LTO is the default in Fedora. # "%define _lto_cflags %{nil}" to opt out diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 49169d1..aaf3a16 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -4,7 +4,7 @@ # 2) When making changes, increment the version (in baserelease) by 1. # rpmdev-bumpspec and other tools update the macro below, which is used # in Version: to get the desired effect. -%global baserelease 273 +%global baserelease 274 Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config @@ -256,6 +256,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua %doc buildflags.md %changelog +* Wed Jan 3 2024 Florian Weimer - 275-1 +- Missing packed relative relocation support on aarch64, s390x (#2256645) + * Tue Jan 2 2024 Florian Weimer - 273-1 - Pack relative ELF relocations by default From 19a840bac0dadfc7e04417dc969ec300e5456e0b Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Thu, 4 Jan 2024 21:31:24 -0500 Subject: [PATCH 4/4] Define RUSTFLAGS only when rust macros are installed Now that rust-packaging absorbed rust-srpm-macros in Fedora, RHEL rust will need to provide an srpm-macros subpackage so that no part of rust-packaging will be pulled into RHEL 10. This will then allow rust-packaging (minus macros.rust-srpm) to exist in EPEL. --- macros | 5 +++-- redhat-rpm-config.spec | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/macros b/macros index 2eca9bb..cc0f895 100644 --- a/macros +++ b/macros @@ -86,13 +86,14 @@ # have not been set already. RPM_OPT_FLAGS and RPM_LD_FLAGS have already # been set implicitly at the start of the %%build section. # LT_SYS_LIBRARY_PATH is used by libtool script. +# RUSTFLAGS is only set when %%{build_rustflags} is available. %set_build_flags \ CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \ CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \ FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \ FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \ - VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ; \ - RUSTFLAGS="${RUSTFLAGS:-%{build_rustflags}}" ; export RUSTFLAGS ; \ + VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ;%{?build_rustflags: + RUSTFLAGS="${RUSTFLAGS:-%{build_rustflags}}" ; export RUSTFLAGS ;} \ LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \ LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH ; \ CC="${CC:-%{__cc}}" ; export CC ; \ diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index aaf3a16..c15643e 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -4,7 +4,7 @@ # 2) When making changes, increment the version (in baserelease) by 1. # rpmdev-bumpspec and other tools update the macro below, which is used # in Version: to get the desired effect. -%global baserelease 274 +%global baserelease 275 Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config @@ -256,7 +256,10 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora common.lua %doc buildflags.md %changelog -* Wed Jan 3 2024 Florian Weimer - 275-1 +* Fri Jan 05 2024 Yaakov Selkowitz - 275-1 +- Define RUSTFLAGS only when rust macros are installed + +* Wed Jan 3 2024 Florian Weimer - 274-1 - Missing packed relative relocation support on aarch64, s390x (#2256645) * Tue Jan 2 2024 Florian Weimer - 273-1