From 764e9a6c8262f50ff2e8930b9ff5700946574fc4 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 16 Aug 2024 14:24:37 +0100 Subject: [PATCH] NVR Bump to allow rebuilding with GTS-14 gcc. Resolves: RHEL-53516 --- binutils.spec | 162 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 105 insertions(+), 57 deletions(-) diff --git a/binutils.spec b/binutils.spec index 2743149..67629ea 100644 --- a/binutils.spec +++ b/binutils.spec @@ -9,7 +9,7 @@ BuildRequires: scl-utils-build Summary: A GNU collection of binary utilities Name: %{?scl_prefix}binutils Version: 2.41 -Release: 1%{?dist} +Release: 2%{?dist} License: GPL-3.0-or-later AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND GFDL-1.3-or-later AND GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later URL: https://sourceware.org/binutils @@ -154,6 +154,13 @@ URL: https://sourceware.org/binutils #---------------------------------------------------------------------------- +# Bootstrapping: Set this to 1 to build annobin with the system gcc. +# Then once GTS-gcc is built and in the buildroot, reset this variable +# to 0, bump the NVR and rebuild GTS-binutils. +%define bootstrapping 0 + +#---------------------------------------------------------------------------- + # Note - the Linux Kernel binutils releases are too unstable and contain # too many controversial patches so we stick with the official FSF version # instead. @@ -359,77 +366,116 @@ BuildRequires: autoconf, automake, perl, sed, coreutils, make BuildRequires: clang compiler-rt %else -# XXX Bootstrapping - build with the system gcc first. - -# Use the GTS version of gcc to build the binutils so that the built static libraries -# (libfd.a, libopcodes.a libiberty.a libsframe.a) use the same LTO version as the one -# that will be used by consumers of GTS binutils. -# Note - during GTS bootstrap these have to be changed to the systemOS versions. -# XXX BuildRequires: %%{?scl_prefix}gcc -# XXX BuildRequires: %%{?scl_prefix}annobin-plugin-gcc -# XXX BuildRequires: %%{?scl_prefix}gcc-c++ - -BuildRequires: gcc -BuildRequires: gcc-c++ - -# XXX %%define gcc_for_libraries %%{?_scl_root}/usr/bin/gcc -# XXX %%define gxx_for_libraries %%{?_scl_root}/usr/bin/g++ - -%define gcc_for_libraries /usr/bin/gcc -%define gxx_for_libraries /usr/bin/g++ +%if %{bootstrapping} +# Note - during GTS bootstrap these have to use the system compiler. # Note - during GTS bootstrap it may be necessary to build the binutils without # annobin annotations. # %%undefine _annotated_build +%define gcc_package gcc +%define gxx_package gcc-c++ + +%define gcc_for_binutils /usr/bin/gcc +%define gxx_for_binutils /usr/bin/g++ + +%else + +# Use the GTS version of gcc to build the binutils so that the built static libraries +# (libfd.a, libopcodes.a libiberty.a libsframe.a) use the same LTO version as the one +# that will be used by consumers of GTS binutils. + +%define gcc_package %{?scl_prefix}gcc +%define gxx_package %{?scl_prefix}gcc-c++ + +BuildRequires: %{?scl_prefix}annobin-plugin-gcc + +%define gcc_for_binutils %{_scl_root}/usr/bin/gcc +%define gxx_for_binutils %{_scl_root}/usr/bin/g++ + %endif +BuildRequires: %{gcc_package} +BuildRequires: %{gxx_package} + +%endif + +#---------------------------------------------------------------------------- + %if %{with gold} # Gold needs bison in order to build gold/yyscript.c. The GOLD testsuite needs a static libc++ BuildRequires: bison, m4, libstdc++-static %if ! %{with clang} -# XXX BuildRequires: %%{?scl_prefix}gcc-c++ + +%if %{bootstrapping} BuildRequires: gcc-c++ +%else +BuildRequires: %{?scl_prefix}gcc-c++ +%endif + %endif %endif +#---------------------------------------------------------------------------- + %if %{without bootstrap} + BuildRequires: gettext, flex, jansson-devel + %if %{with systemzlib} BuildRequires: zlib-devel %endif + %endif +#---------------------------------------------------------------------------- + %if %{with docs} + BuildRequires: texinfo >= 4.0 # BZ 920545: We need pod2man in order to build the manual pages. BuildRequires: /usr/bin/pod2man + %else + BuildRequires: findutils + %endif +#---------------------------------------------------------------------------- + +%if %{with testsuite} + # Required for: ld-bootstrap/bootstrap.exp bootstrap with --static # It should not be required for: ld-elf/elf.exp static {preinit,init,fini} array -%if %{with testsuite} # relro_test.sh uses dc which is part of the bc rpm, hence its inclusion here. # sharutils is needed so that we can uuencode the testsuite results. BuildRequires: dejagnu, glibc-static, sharutils, bc, libstdc++ + %if %{with systemzlib} BuildRequires: zlib-devel %endif + %endif +#---------------------------------------------------------------------------- + %if %{with debuginfod} BuildRequires: elfutils-debuginfod-client-devel %endif +#---------------------------------------------------------------------------- + %{?scl:Requires:%scl_runtime} -# XXX %%define alternatives_cmd %%{_sbindir}/alternatives -# XXX %%define alternatives_cmdline %%{alternatives_cmd} +%if %{bootstrapping} +%define alternatives_cmd %{_sbindir}/alternatives +%define alternatives_cmdline %{alternatives_cmd} +%else %define alternatives_cmd %{!?scl:%{_sbindir}}%{?scl:%{_root_sbindir}}/alternatives %define alternatives_cmdline %{alternatives_cmd}%{?scl: --altdir %{_sysconfdir}/alternatives --admindir %{_scl_root}/var/lib/alternatives} +%endif Requires(post): %{alternatives_cmd} Requires(preun): %{alternatives_cmd} @@ -553,8 +599,8 @@ Requires: zlib-devel %endif BuildRequires: autoconf automake perl sed coreutils make findutils -BuildRequires: %{?scl_prefix}gcc -BuildRequires: %{?scl_prefix}gcc-c++ +BuildRequires: %{gcc_package} +BuildRequires: %{gxx_package} ExcludeArch: aarch64-linux-gnu aarch64-redhat-linux @@ -572,8 +618,8 @@ Requires: zlib-devel %endif BuildRequires: autoconf automake perl sed coreutils make findutils -BuildRequires: %{?scl_prefix}gcc -BuildRequires: %{?scl_prefix}gcc-c++ +BuildRequires: %{gcc_package} +BuildRequires: %{gxx_package} ExcludeArch: ppc64le-linux-gnu ppc64le-redhat-linux @@ -591,8 +637,8 @@ Requires: zlib-devel %endif BuildRequires: autoconf automake perl sed coreutils make findutils -BuildRequires: %{?scl_prefix}gcc -BuildRequires: %{?scl_prefix}gcc-c++ +BuildRequires: %{gcc_package} +BuildRequires: %{gxx_package} ExcludeArch: s390x-linux-gnu s390x-redhat-linux @@ -610,8 +656,8 @@ Requires: zlib-devel %endif BuildRequires: autoconf automake perl sed coreutils make findutils -BuildRequires: %{?scl_prefix}gcc -BuildRequires: %{?scl_prefix}gcc-c++ +BuildRequires: %{gcc_package} +BuildRequires: %{gxx_package} ExcludeArch: x86_64-linux-gnu x86_64-redhat-linux i686-linux-gnu i686-redhat-linux @@ -876,8 +922,8 @@ run_target_configuration() else RARGS="--disable-shared" fi - - ../configure --target=$target $CARGS $SARGS $RARGS $TARGS || cat config.log + + CC=%gcc_for_binutils CXX=%gxx_for_binutils ../configure --target=$target $CARGS $SARGS $RARGS $TARGS || cat config.log popd } @@ -894,10 +940,10 @@ build_target() %if %{with docs} # Because of parallel building, info has to be made after all. - %make_build %{_smp_mflags} tooldir=%{_prefix} all - %make_build %{_smp_mflags} tooldir=%{_prefix} info + %make_build %{_smp_mflags} tooldir=%{_prefix} CC=%gcc_for_binutils CXX=%gxx_for_binutils all + %make_build %{_smp_mflags} tooldir=%{_prefix} CC=%gcc_for_binutils CXX=%gxx_for_binutils info %else - %make_build %{_smp_mflags} tooldir=%{_prefix} MAKEINFO=true all + %make_build %{_smp_mflags} tooldir=%{_prefix} CC=%gcc_for_binutils CXX=%gxx_for_binutils MAKEINFO=true all %endif popd @@ -935,14 +981,14 @@ run_tests() # Run the tests and accumulate the logs - but ignore failures... if test x$native == x1 ; then - make -k check-gas check-binutils check-ld < /dev/null || : + make -k CC=%gcc_for_binutils CXX=%gxx_for_binutils check-gas check-binutils check-ld < /dev/null || : %if %{with gold} # The GOLD testsuite always returns an error code, even if no tests fail. - make -k check-gold < /dev/null || : + make -k CC=%gcc_for_binutils CXX=%gxx_for_binutils check-gold < /dev/null || : %endif else # Do not try running linking tests for the cross-binutils. - make -k check-gas check-binutils < /dev/null || : + make -k CC=%gcc_for_binutils CXX=%gxx_for_binutils check-gas check-binutils < /dev/null || : fi for f in {gas/testsuite/gas,ld/ld,binutils/binutils}.sum @@ -985,11 +1031,11 @@ run_tests() # Run the tests and this time fail if there are any errors. if test x$native == x1 ; then - make -k check-gas check-binutils check-ld < /dev/null + make -k CC=%gcc_for_binutils CXX=%gxx_for_binutils check-gas check-binutils check-ld < /dev/null # Ignore the gold tests - they always fail else # Do not try running linking tests for the cross-binutils. - make -k check-gas check-binutils < /dev/null + make -k CC=%gcc_for_binutils CXX=%gxx_for_binutils check-gas check-binutils < /dev/null fi popd @@ -1008,7 +1054,7 @@ run_tests() %define _with_cc_clang 1 %endif -# Disable LTO on arm due to: +# Disable LTO on Arm due to: # https://bugzilla.redhat.com/show_bug.cgi?id=1918924 %ifarch %{arm} %define enable_lto 0 @@ -1078,12 +1124,11 @@ install_binutils() if test x$native == x1 ; then %if %{with docs} - %make_install DESTDIR=%{buildroot} - make prefix=%{buildroot}%{_prefix} infodir=$local_infodir install-info + %make_install CC=%gcc_for_binutils CXX=%gxx_for_binutils DESTDIR=%{buildroot} + make CC=%gcc_for_binutils CXX=%gxx_for_binutils prefix=%{buildroot}%{_prefix} infodir=$local_infodir install-info %else - %make_install DESTDIR=%{buildroot} MAKEINFO=true + %make_install CC=%gcc_for_binutils CXX=%gxx_for_binutils DESTDIR=%{buildroot} MAKEINFO=true %endif - # Rebuild the static libiaries with -fPIC. # It would be nice to build the static libraries with -fno-lto so that # they can be used by programs that are built with a different version @@ -1091,23 +1136,23 @@ install_binutils() # warnings from annocheck. # Future: Remove libiberty together with its header file, projects should bundle it. - %make_build -s -C libiberty clean + %make_build -s -C libiberty CC=%gcc_for_binutils CXX=%gxx_for_binutils clean %set_build_flags - %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libiberty + %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libiberty CC=%gcc_for_binutils CXX=%gxx_for_binutils # Without the hidden visibility the 3rd party shared libraries would export # the bfd non-stable ABI. - %make_build -s -C bfd clean + %make_build -s -C bfd CC=%gcc_for_binutils CXX=%gxx_for_binutils clean %set_build_flags - %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd + %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd CC=%gcc_for_binutils CXX=%gxx_for_binutils - %make_build -s -C opcodes clean + %make_build -s -C opcodes clean CC=%gcc_for_binutils CXX=%gxx_for_binutils %set_build_flags - %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C opcodes + %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C opcodes CC=%gcc_for_binutils CXX=%gxx_for_binutils - %make_build -s -C libsframe clean + %make_build -s -C libsframe clean CC=%gcc_for_binutils CXX=%gxx_for_binutils %set_build_flags - %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libsframe + %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libsframe CC=%gcc_for_binutils CXX=%gxx_for_binutils install -m 644 bfd/.libs/libbfd.a $local_libdir install -m 644 libiberty/libiberty.a $local_libdir @@ -1184,7 +1229,7 @@ EOH local target_root=$local_root/$target - %make_install DESTDIR=%{buildroot} MAKEINFO=true + %make_install DESTDIR=%{buildroot} MAKEINFO=true CC=%gcc_for_binutils CXX=%gxx_for_binutils fi # This one comes from gcc @@ -1268,7 +1313,7 @@ exit 0 # RHEL-22818: Restire the SELinux context of the gprofng libraries. restorecon -R %{_libdir} # And the rc file. -restorecon /opt/rh/gcc-toolset-14/root/usr/etc/gprofng.rc +restorecon %{_scl_root}/usr/etc/gprofng.rc exit 0 %endif @@ -1413,7 +1458,7 @@ exit 0 %dir %{_libdir}/gprofng %{_libdir}/gprofng/* # FIXME: Work out the correct way to specify this file: -/opt/rh/gcc-toolset-14/root/etc/gprofng.rc +%{_scl_root}/etc/gprofng.rc %endif %if %{with crossbuilds} @@ -1446,5 +1491,8 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Fri Aug 16 2024 Nick Clifton - 2.41-2 +- NVR Bump to allow rebuilding with GTS-14 gcc. (RHEL-53516) + * Fri Apr 26 2024 Nick Clifton - 2.41-1 - Initial import of upstream 2.41 release with patches from Fedora 40.