%define lib_major 2 %define lib_name_orig %{package_prefix}%mklibname binutils %define lib_name %{lib_name_orig}%{lib_major} %define dev_name %mklibname binutils -d %define rpm_ver 2.43 %define tar_ver 2.43 %define rel 1 # Define if building a cross-binutils %define build_cross 0 %{expand: %{?cross: %%global build_cross 1}} %if %{build_cross} %define target_cpu %{cross} %define target_platform %{target_cpu}-%_real_vendor-linux%{gnuext} %define program_prefix %{target_platform}- %define package_prefix cross-%{target_cpu}- %else %ifarch armv7hl %define _host_cpu armv7hl %define _gnu -gnueabi %endif %define target_cpu %{_target_cpu} %define target_platform %{_target_platform} %define program_prefix %{nil} %define package_prefix %{nil} %endif %define arch %(echo %{target_cpu}|sed -e "s/\(i.86\|athlon\)/i386/" -e "s/amd64/x86_64/") %define isarch() %(case " %* " in (*" %{arch} "*) echo 1;; (*) echo 0;; esac) %if %{build_cross} %if %isarch %arm %define gnuext -gnueabi %else %define gnuext -gnu %endif %endif # List of targets where gold can be enabled %define gold_arches %{ix86} x86_64 %{arm} aarch64 Summary: GNU Binary Utility Development Utilities Name: %{package_prefix}binutils Epoch: 1 Version: %{rpm_ver} Release: %mkrel %{rel} License: GPLv3+ Group: Development/Other URL: https://www.gnu.org/software/binutils/ Source0: https://ftp.gnu.org/gnu/binutils/binutils-%{tar_ver}.tar.xz Source1: build_cross_binutils.sh Source2: binutils-2.19.50.0.1-output-format.sed Source3: binutils-git.sh %if "%{name}" == "binutils" Provides: %{lib_name} = %{epoch}:%{version}-%{release} %endif # (wally) force build with gcc 14 BuildRequires: gcc >= 14.0.1-0.20240317.1 # (wally) force binutils 2.42 BuildRequires: binutils >= 1:2.42 BuildRequires: autoconf BuildRequires: automake BuildRequires: bison BuildRequires: flex BuildRequires: gettext BuildRequires: texinfo-tex BuildRequires: dejagnu BuildRequires: pkgconfig(zlib) # make check'ing requires libdl.a BuildRequires: glibc-static-devel # gold make check'ing requires libstdc++.a BuildRequires: libstdc++-static-devel # revert devel enabling on branch Source101: binutils-disable-development.patch # upstream master branch from 200 # patches once liberated from Fedora: # NOTE! Do not add more without maintainer approval Patch301: binutils-2.20.51.0.2-libtool-lib64.patch Patch302: binutils-2.37-export-demangle.h.patch Patch303: binutils-2.22.52.0.4-no-config-h-check.patch # Mageia patches Source401: binutils-2.39-linux32.patch Patch402: binutils-2.42-skip-gold-check.patch %description Binutils is a collection of binary utilities, including: * ar: creating modifying and extracting from archives * nm: for listing symbols from object files * objcopy: for copying and translating object files * objdump: for displaying information from object files * ranlib: for generating an index for the contents of an archive * size: for listing the section sizes of an object or archive file * strings: for listing printable strings from files * strip: for discarding symbols (a filter for demangling encoded C++ symbols * addr2line: for converting addresses to file and line * nlmconv: for converting object code into an NLM Install binutils if you need to perform any of these types of actions on binary files. Most programmers will want to install binutils. %package -n %{dev_name} Summary: Main library for %{name} Group: Development/Other Provides: %{name}-devel = %{epoch}:%{version}-%{release} Provides: %{lib_name}-devel = %{epoch}:%{version}-%{release} Requires: zlib-devel # filter out self-requries %global __requires_exclude ^devel\\(libbfd-%{version} %description -n %{dev_name} This package contains BFD and opcodes static libraries and associated header files. Only *.a libraries are included, because BFD doesn't have a stable ABI. Developers starting new projects are strongly encouraged to consider using libelf instead of BFD. %prep %setup -q -n binutils-%{tar_ver} %autopatch -p1 # remove to force regenerating it because of reverts in P10-P12 rm -f ld/ldlex.c %build # Additional targets ADDITIONAL_TARGETS="" case %{target_cpu} in i*86 | athlon*) ADDITIONAL_TARGETS="x86_64-%{_target_vendor}-%{_target_os}" ;; esac if [[ -n "$ADDITIONAL_TARGETS" ]]; then TARGET_CONFIG="$TARGET_CONFIG --enable-targets=$ADDITIONAL_TARGETS" fi case %{target_cpu} in i*86 | athlon* | aarch64*) TARGET_CONFIG="$TARGET_CONFIG --enable-64-bit-bfd" ;; esac case %{target_cpu} in x86_64*|i?86*|arm*|aarch64*) TARGET_CONFIG="$TARGET_CONFIG --enable-targets=x86_64-pep" ;; esac %if "%{name}" != "binutils" %define _program_prefix %{program_prefix} TARGET_CONFIG="$TARGET_CONFIG --target=%{target_platform}" %endif # Don't build shared libraries in cross binutils %if "%{name}" == "binutils" TARGET_CONFIG="$TARGET_CONFIG --enable-shared --with-pic" %endif # Binutils comes with its own custom libtool # [gb] FIXME: but system libtool also works and has relink fix %define __libtoolize /bin/true # Build main binaries rm -rf objs mkdir objs pushd objs CONFIGURE_TOP=.. %configure $TARGET_CONFIG --with-bugurl=https://bugs.mageia.org/ \ --enable-gold \ --enable-plugins \ --enable-compressed-debug-sections=none \ --enable-gprofng=no \ --enable-relro=yes \ --enable-new-dtags --disable-rpath \ --with-system-zlib \ # There seems to be some problems with builds of gold randomly failing whenever # going through the build system, so let's try workaround this by trying to do # make once again when it happens... %make_build tooldir=%{_prefix} || make tooldir=%{_prefix} popd %check # All Tests must pass on x86 and x86_64 # rtp: some ld-arm tests are failing. # they're fixed in 2.21 but didn't find the fixes echo ====================TESTING========================= %if %isarch i386 x86_64 %make_build -C objs check LDFLAGS="" || : # random build failures with gold seems to happen during check as well... make -k -C objs gold-check LDFLAGS="" || : %else %make_build -C objs -k check LDFLAGS="" || : %endif echo ====================TESTING END===================== logfile="%{name}-%{version}-%{release}.log" rm -f $logfile; find . -name "*.sum" | xargs cat >> $logfile %install # disable 'check-rpaths' only from warning about standard RPATHs (0x0001) # (tmb) TODO / FIXME better ??? export QA_RPATHS=0x0001 mkdir -p $RPM_BUILD_ROOT%{_prefix} %make_install -C objs rm -f $RPM_BUILD_ROOT%{_mandir}/man1/{dlltool,nlmconv,windres}* rm -f $RPM_BUILD_ROOT%{_infodir}/dir rm -f $RPM_BUILD_ROOT%{_libdir}/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/lib{bfd,opcodes}.so %if "%{name}" == "binutils" make -C objs prefix=$RPM_BUILD_ROOT%{_prefix} infodir=$RPM_BUILD_ROOT%{_infodir} install-info install -m 644 include/libiberty.h $RPM_BUILD_ROOT%{_includedir}/ %if %isarch %mips install -m 644 objs/libiberty/libiberty.a $RPM_BUILD_ROOT%{_libdir}/ # Ship with the PIC libiberty %else install -m 644 objs/libiberty/pic/libiberty.a $RPM_BUILD_ROOT%{_libdir}/ %endif rm -rf $RPM_BUILD_ROOT%{_prefix}/%{_target_platform}/ # Sanity check --enable-64-bit-bfd really works. %if %isarch i*86 athlon* grep '^#define BFD_ARCH_SIZE 64$' %{buildroot}%{_prefix}/include/bfd.h %endif # Fix multilib conflicts of generated values by __WORDSIZE-based expressions. %if %isarch %{ix86} x86_64 sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include ~;}' \ -e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \ -e 's/^#define BFD_HOST_64BIT_LONG [01] *$/#define BFD_HOST_64BIT_LONG (__WORDSIZE == 64)/' \ -e 's/^#define BFD_HOST_64_BIT \(long \)\?long *$/#if __WORDSIZE == 32\ #define BFD_HOST_64_BIT long long\ #else\ #define BFD_HOST_64_BIT long\ #endif/' \ -e 's/^#define BFD_HOST_U_64_BIT unsigned \(long \)\?long *$/#define BFD_HOST_U_64_BIT unsigned BFD_HOST_64_BIT/' \ %{buildroot}%{_prefix}/include/bfd.h %endif touch -r bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h # Generate .so linker scripts for dependencies; imported from glibc/Makerules: # This fragment of linker script gives the OUTPUT_FORMAT statement # for the configuration we are building. OUTPUT_FORMAT="\ /* Ensure this .so library will not be used by a link for a different format on a multi-architecture system. */ $(gcc $CFLAGS $LDFLAGS -shared -x c /dev/null -o /dev/null -Wl,--verbose -v 2>&1 | sed -n -f "%{SOURCE2}")" tee %{buildroot}%{_libdir}/libbfd.so <> binutils.lang cat ld.lang >> binutils.lang cat gold.lang>> binutils.lang cat gprof.lang >> binutils.lang %find_lang opcodes %find_lang bfd cat opcodes.lang >> binutils.lang cat bfd.lang >> binutils.lang %files -f binutils.lang %{_bindir}/%{program_prefix}addr2line %{_bindir}/%{program_prefix}ar %{_bindir}/%{program_prefix}as %{_bindir}/%{program_prefix}c++filt %{_bindir}/%{program_prefix}dwp %{_bindir}/%{program_prefix}elfedit %{_bindir}/%{program_prefix}gprof %{_bindir}/%{program_prefix}ld %{_bindir}/%{program_prefix}ld.bfd %if %isarch %{gold_arches} %{_bindir}/%{program_prefix}ld.gold %endif %{_bindir}/%{program_prefix}nm %{_bindir}/%{program_prefix}objcopy %{_bindir}/%{program_prefix}objdump %{_bindir}/%{program_prefix}ranlib %{_bindir}/%{program_prefix}readelf %{_bindir}/%{program_prefix}size %{_bindir}/%{program_prefix}strings %{_bindir}/%{program_prefix}strip %{_mandir}/man1/* %if "%{name}" == "binutils" %{_infodir}/*info* %{_libdir}/bfd-plugins/libdep.so %{_libdir}/libbfd-%{version}*.so %{_libdir}/libctf.so.0{,.*} %{_libdir}/libctf-nobfd.so.0{,.*} %{_libdir}/libopcodes-%{version}*.so %{_libdir}/libsframe.so.1{,.*} %else %{_prefix}/%{target_platform}/bin/* %{_prefix}/%{target_platform}/lib/ldscripts %endif %if "%{name}" == "binutils" %files -n %{dev_name} %{_includedir}/*.h %{_libdir}/libbfd.a %{_libdir}/libbfd.so %{_libdir}/libctf.a %{_libdir}/libctf.so %{_libdir}/libctf-nobfd.a %{_libdir}/libctf-nobfd.so %{_libdir}/libiberty.a %{_libdir}/libopcodes.a %{_libdir}/libopcodes.so %{_libdir}/libsframe.a %{_libdir}/libsframe.so %endif