On Mon, 2007-06-11 at 15:42 -0600, Brendan Conoboy wrote: > Yep, we've been through this a few times. Having discussed this with > you a number of times before, I know where you're coming from. We > really should be able to build gcc without having to build parts of > glibc in the process. Do we _actually_ need to build parts of glibc? Could we not get away with a fake DSO which just provides the few symbols libgcc uses? Or do we even need to build the dynamic libgcc _with_ the compiler at all? > That said, this is really only an exercise in bootstrapping which > doesn't happen very often. Actually it happens for me every time I build a cross-compiler. But perhaps it doesn't _need_ to; you're right. > Let us, for example, pretend we're just discussing cross compilation for > existing archs. That's a very good place to start. Especially if you realise that it doesn't _really_ restrict us to 'existing architectures' -- it restricts us to those architectures for which we can cobble together 'native' packages for gcc, etc. Which is actually not much of a restriction at all. > Because of the iterative nature of these builds, > everything we need is already there to build the cross compiler. We > have kernel headers and we have a glibc rpm for the target arch. All > that we need in some machinery to pull in files from a different arch > and extract them into a sys-root. That would be an interesting answer, yes. It only solves the _build_ part of the problem though. The packaging side remains -- you'll want to end up a cross-compiler package for the host arch, but libgcc etc. for the target. RPM doesn't currently let you spit out even .noarch.rpm and $ARCH.rpm simultaneously -- to build both i686-linux-gnu-gcc-$V-$R.ppc.rpm and libgcc-$V-$R.i386.rpm you'll almost certainly need a separate rpmbuild run _anyway_. So how will we handle that? > As gcc matures, it's likely that the libgcc problem will go away by it > being split out. At that time, the chicken/egg problem will be solved > without having to resort to clever hacks. I think we need to accelerate that rather than waiting for it. Binutils at least should be relatively easy. Here's a patch against binutils/F-7 which lets me: make DIST_DEFINES='--define "binutils_target i686-linux-gnu"' ppc Even for this we have build system questions... how best to build it for each target architecture we want? Index: binutils.spec =================================================================== RCS file: /cvs/pkgs/rpms/binutils/F-7/binutils.spec,v retrieving revision 1.115 diff -u -p -r1.115 binutils.spec --- binutils.spec 14 Apr 2007 15:21:02 -0000 1.115 +++ binutils.spec 12 Jun 2007 15:30:56 -0000 @@ -1,5 +1,13 @@ +%if "%{?binutils_target}" == "" +%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.17.50.0.12 Release: 4 License: GPL @@ -51,7 +59,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~ @@ -66,7 +74,7 @@ to consider using libelf instead of BFD. %patch8 -p0 -b .osabi~ %patch9 -p0 -b .rh235747~ -# 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* @@ -78,24 +86,36 @@ 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 +sed -i -e 's/^ PACKAGE=/ PACKAGE=%{?cross}/' */configure %build -mkdir build-%{_target_platform} -cd build-%{_target_platform} +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 +case %{binutils_target} in + sparc*|ppc*|s390*) + CARGS=--enable-64-bit-bfd + ;; + ia64*) + CARGS=--enable-targets=i386-linux + ;; +esac +%if %isnative + SHAREDARGS=--enable-shared + TARGET=%{binutils_target} + SYSROOT= +%else + SHAREDARGS=--disable-shared + TARGET="--target %{binutils_target} --host %{_target_platform}" + SYSROOT="--with-sysroot=/usr/%{binutils_target}" %endif CC="gcc -L`pwd`/bfd/.libs/" CFLAGS="${CFLAGS:-%optflags}" ../configure \ - %{_target_platform} --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} \ + $TARGET --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} $SHAREDARGS $CARGS --disable-werror $SYSROOT make %{_smp_mflags} tooldir=%{_prefix} all make %{_smp_mflags} tooldir=%{_prefix} info make -k check < /dev/null > check.log 2>&1 || : @@ -107,8 +127,9 @@ cd .. %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* @@ -130,10 +151,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 @@ -151,22 +168,36 @@ sed -i -e '/^#include "ansidecl.h"/{p;s~ %endif touch -r ../bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h +%else # native +# For cross-binutils we drop the documentation. +rm -rf %{buildroot}%{_infodir} +#rm -rf %{buildroot}%{_prefix}/share/locale +#rm -rf %{buildroot}%{_mandir} +rm -rf %{buildroot}%{_prefix}/%{_lib}/libiberty.a +%endif # native + +# 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 @@ -197,12 +228,14 @@ exit 0 if [ $1 = 0 ] ;then /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/bfd.info.gz || : fi +%endif # native -%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* @@ -212,6 +245,7 @@ fi %{_prefix}/include/* %{_prefix}/%{_lib}/lib*.a %{_infodir}/bfd*info* +%endif # native %changelog * Sat Apr 14 2007 Jakub Jelinek <jakub@xxxxxxxxxx> 2.17.50.0.12-4 -- dwmw2 -- fedora-devel-list mailing list fedora-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-devel-list