Re: [PATCH] cross-compilation for binutils.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi David,

made some minor updates upon yours:
* Fixed the testsuite run for cross-builds.
* Fixed omitted --with-sysroot for the cross-builds.
* Replaced --with-sysroot /usr with %{_prefix}.
* Fixed %if F-10 rpm compatibility.

OK to commit it for Rawhide?


Regards,
Jan
--- ./binutils.spec	16 Jul 2008 18:39:54 -0000	1.134
+++ ./binutils.spec	26 Jul 2008 03:48:29 -0000
@@ -1,7 +1,19 @@
+# rpmbuild parameters:
+# --define "binutils_target arm-linux-gnu" to create arm-linux-gnu-binutils.
+# --without testsuite: Do not run the testsuite.  Default is to run it.
+
+%if 0%{!?binutils_target:1}
+%define binutils_target %{_target_platform}
+%define isnative 1
+%else
+%define cross %{binutils_target}-
+%define isnative 0
+%endif
+
 Summary: A GNU collection of binary utilities.
-Name: binutils
+Name: %{?cross}binutils
 Version: 2.18.50.0.6
-Release: 4%{?dist}
+Release: 5%{?dist}
 License: GPLv3+
 Group: Development/Tools
 URL: http://sources.redhat.com/binutils
@@ -54,7 +66,7 @@ have a stable ABI.  Developers starting 
 to consider using libelf instead of BFD.
 
 %prep
-%setup -q
+%setup -q -n binutils-%{version}
 %patch1 -p0 -b .ltconfig-multilib~
 %patch2 -p0 -b .ppc64-pie~
 %patch3 -p0 -b .place-orphan~
@@ -68,7 +80,7 @@ to consider using libelf instead of BFD.
 %patch7 -p0 -b .version~
 %patch8 -p0 -b .pclmul~
 
-# On ppc64 we might use 64K pages
+# On ppc64 we might use 64KiB pages
 sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*ppc.c
 # LTP sucks
 perl -pi -e 's/i\[3-7\]86/i[34567]86/g' */conf*
@@ -80,38 +92,65 @@ sed -i -e 's/^libbfd_la_LDFLAGS = /&-Wl,
 sed -i -e 's/^libopcodes_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' opcodes/Makefile.{am,in}
 fi
 touch */configure
+# $PACKAGE is used for the gettext catalog name.
+sed -i -e 's/^ PACKAGE=/ PACKAGE=%{?cross}/' */configure
+# Undo the name change to run the testsuite.
+for tool in binutils gas ld
+do
+  sed -i -e "2aDEJATOOL = $tool" $tool/Makefile.am
+  sed -i -e "s/^DEJATOOL = .*/DEJATOOL = $tool/" $tool/Makefile.in
+done
 
 %build
-mkdir build-%{_target_platform}
-cd build-%{_target_platform}
+echo target is %{binutils_target}
+mkdir build-%{binutils_target}
+cd build-%{binutils_target}
 CARGS=
-%ifarch sparc ppc s390
-CARGS=--enable-64-bit-bfd
-%endif
-%ifarch ia64
-CARGS=--enable-targets=i386-linux
-%endif
+case %{binutils_target} in
+    sparc*|ppc*|s390*)
+       CARGS="--enable-64-bit-bfd"
+       ;;
+    ia64*)
+       CARGS="--enable-targets=i386-linux"
+       ;;
+esac
+# We could optimize the cross builds size by --enable-shared but the produced
+# binaries may be less convenient in the embedded environment.
 CC="gcc -L`pwd`/bfd/.libs/" CFLAGS="${CFLAGS:-%optflags}" ../configure \
-  %{_target_platform} --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} \
+%if %{isnative}
+  %{binutils_target} \
+  --enable-shared \
+%else
+  --target %{binutils_target} --enable-targets=%{_host} \
+  --disable-shared \
+  --with-sysroot=%{_prefix}/%{binutils_target}/sys-root \
+%endif
+  $CARGS \
+  --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} \
   --bindir=%{_bindir} --sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} \
   --datadir=%{_datadir} --includedir=%{_includedir} --libdir=%{_libdir} \
   --libexecdir=%{_libexecdir} --localstatedir=%{_localstatedir} \
   --sharedstatedir=%{_sharedstatedir} --mandir=%{_mandir} \
-  --infodir=%{_infodir} --enable-shared $CARGS --disable-werror \
+  --infodir=%{_infodir} --disable-werror \
   --with-bugurl=http://bugzilla.redhat.com/bugzilla/
 make %{_smp_mflags} tooldir=%{_prefix} all
 make %{_smp_mflags} tooldir=%{_prefix} info
+%if 0%{?_without_testsuite:1}
+echo ====================TESTSUITE DISABLED=========================
+%else
 make -k check < /dev/null > check.log 2>&1 || :
 echo ====================TESTING=========================
 cat check.log
 echo ====================TESTING END=====================
 cd ..
+%endif
 
 %install
 rm -rf %{buildroot}
 mkdir -p %{buildroot}%{_prefix}
-cd build-%{_target_platform}
+cd build-%{binutils_target}
 %makeinstall
+%if %{isnative}
 make prefix=%{buildroot}%{_prefix} infodir=%{buildroot}%{_infodir} install-info
 gzip -q9f %{buildroot}%{_infodir}/*.info*
 
@@ -141,10 +180,6 @@ rm -f %{buildroot}%{_prefix}/%{_lib}/lib
 # Remove libtool files, which reference the .so libs
 rm -f %{buildroot}%{_prefix}/%{_lib}/lib{bfd,opcodes}.la
 
-# This one comes from gcc
-rm -f %{buildroot}%{_infodir}/dir
-rm -rf %{buildroot}%{_prefix}/%{_target_platform}
-
 %ifarch %{ix86} x86_64 ppc ppc64 s390 s390x sparc sparc64
 sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include <bits/wordsize.h>~;}' \
 %ifarch %{ix86} x86_64
@@ -162,22 +197,36 @@ sed -i -e '/^#include "ansidecl.h"/{p;s~
 %endif
 touch -r ../bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h
 
+%else # !%{isnative}
+# For cross-binutils we drop the documentation.
+rm -rf %{buildroot}%{_infodir}
+# We keep these as one can have native + cross binutils of different versions.
+#rm -rf %{buildroot}%{_prefix}/share/locale
+#rm -rf %{buildroot}%{_mandir}
+rm -rf %{buildroot}%{_prefix}/%{_lib}/libiberty.a
+%endif # !%{isnative}
+
+# This one comes from gcc
+rm -f %{buildroot}%{_infodir}/dir
+rm -rf %{buildroot}%{_prefix}/%{binutils_target}
+
 cd ..
-%find_lang binutils
-%find_lang opcodes
-%find_lang bfd
-%find_lang gas
-%find_lang ld
-%find_lang gprof
-cat opcodes.lang >> binutils.lang
-cat bfd.lang >> binutils.lang
-cat gas.lang >> binutils.lang
-cat ld.lang >> binutils.lang
-cat gprof.lang >> binutils.lang
+%find_lang %{?cross}binutils
+%find_lang %{?cross}opcodes
+%find_lang %{?cross}bfd
+%find_lang %{?cross}gas
+%find_lang %{?cross}ld
+%find_lang %{?cross}gprof
+cat %{?cross}opcodes.lang >> %{?cross}binutils.lang
+cat %{?cross}bfd.lang >> %{?cross}binutils.lang
+cat %{?cross}gas.lang >> %{?cross}binutils.lang
+cat %{?cross}ld.lang >> %{?cross}binutils.lang
+cat %{?cross}gprof.lang >> %{?cross}binutils.lang
 
 %clean
 rm -rf %{buildroot}
 
+%if %{isnative}
 %post
 /sbin/ldconfig
 /sbin/install-info --info-dir=%{_infodir} %{_infodir}/as.info.gz
@@ -208,12 +257,14 @@ exit 0
 if [ $1 = 0 ] ;then
   /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/bfd.info.gz || :
 fi
+%endif # %{isnative}
 
-%files -f binutils.lang
+%files -f %{?cross}binutils.lang
 %defattr(-,root,root)
 %doc README
 %{_prefix}/bin/*
 %{_mandir}/man1/*
+%if %{isnative}
 %{_prefix}/%{_lib}/lib*.so
 %{_infodir}/[^b]*info*
 %{_infodir}/binutils*info*
@@ -223,8 +274,15 @@ fi
 %{_prefix}/include/*
 %{_prefix}/%{_lib}/lib*.a
 %{_infodir}/bfd*info*
+%endif # %{isnative}
 
 %changelog
+* Sat Jul 26 2008 Jan Kratochvil <jan.kratochvil@xxxxxxxxxx> 2.18.50.0.6-5
+- Add %%{binutils_target} macro to support building cross-binutils.
+  (David Woodhouse)
+- Support `--without testsuite' to suppress the testsuite run.
+- Refresh the patchset with fuzz 0 (for new rpmbuild).
+
 * Wed Jul 16 2008 Jan Kratochvil <jan.kratochvil@xxxxxxxxxx> 2.18.50.0.6-4
 - include the `dist' tag in the Release number
 - libbfd.a symbols visibility is now hidden (for #447426, suggested by Jakub)
--- ./binutils-2.18.50.0.6-place-orphan.patch	4 Apr 2008 09:48:39 -0000	1.1
+++ ./binutils-2.18.50.0.6-place-orphan.patch	26 Jul 2008 03:48:29 -0000
@@ -2,8 +2,8 @@
 
 	* emulparams/elf64ppc.sh (OTHER_GOT_RELOC_SECTIONS): Add .rela.opd.
 
---- ld/emulparams/elf64ppc.sh.jj	2003-07-28 10:24:45.000000000 -0400
-+++ ld/emulparams/elf64ppc.sh	2003-08-05 08:35:58.000000000 -0400
+--- ld/emulparams/elf64ppc.sh	2007-03-16 16:48:30.000000000 +0100
++++ ld/emulparams/elf64ppc.sh	2008-07-25 20:11:20.000000000 +0200
 @@ -28,7 +28,8 @@ else
    .toc		0 : { *(.toc) }"
  fi
@@ -12,5 +12,5 @@
 +  .rela.toc	${RELOCATING-0} : { *(.rela.toc) }
 +  .rela.opd	${RELOCATING-0} : { *(.rela.opd) }"
  OTHER_READWRITE_SECTIONS="
-   .toc1		${RELOCATING-0}${RELOCATING+ALIGN(8)} : { *(.toc1) }
-   .opd		${RELOCATING-0}${RELOCATING+ALIGN(8)} : { KEEP (*(.opd)) }"
+   .toc1		${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { *(.toc1) }
+   .opd		${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { KEEP (*(.opd)) }
-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux