From owner-freebsd-current Tue Jul 10 13:33:52 2001 Delivered-To: freebsd-current@freebsd.org Received: from alpo.whistle.com (s206m1.whistle.com [207.76.206.1]) by hub.freebsd.org (Postfix) with ESMTP id E62F937B403 for ; Tue, 10 Jul 2001 13:33:42 -0700 (PDT) (envelope-from mark@whistle.com) Received: from [207.76.207.129] (PBG4.whistle.com [207.76.207.129]) by alpo.whistle.com (8.9.1a/8.9.1) with ESMTP id NAA61134; Tue, 10 Jul 2001 13:30:13 -0700 (PDT) Mime-Version: 1.0 X-Sender: mark-ml@207.76.206.1 Message-Id: In-Reply-To: References: <200107082141.f68LfVJ13849@harmony.village.org> Date: Tue, 10 Jul 2001 13:29:32 -0700 To: Dag-Erling Smorgrav , Warner Losh From: Mark Peek Subject: Re: Cross building FYI Cc: current@FreeBSD.ORG Content-Type: text/plain; charset="us-ascii" ; format="flowed" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 3:15 AM +0200 7/9/01, Dag-Erling Smorgrav wrote: >Warner Losh writes: >> cc: ../../libbfd/libbfd.a: No such file or directory >> cc: ../../libiberty/libiberty.a: No such file or directory >> cc: ../../libopcodes/libopcodes.a: No such file or directory >> *** Error code 1 > >Funny, mine got past that and didn't die until much later. Below are patches which allowed me to run an alpha cross build through to completion using: make -DNOPERL MACHINE_ARCH=alpha MAKEOBJDIRPREFIX=/usr/aobj buildworld and a normal build using make -DNOPERL MAKEOBJDIRPREFIX=/usr/iobj buildworld (Note: at this time I decided not to see whether PERL would DTRT in a cross environment.) Here's a quick summary of the build stages to make my explanation a little clearer. For a cross build: HOST == BUILD_ARCH == the system you're doing the build on TARGET == MACHINE_ARCH == the architecture you're wanting to build stage 1: build bootstrap tools (HOST format, HOST object directory) - Builds build tools which are required to come from the new source code tree. stage 2: build tools (HOST format, TARGET object directory) - Builds build tools which are required to run on the host machine in the context of the TARGET build (stage 4). We must compile them with the host compiler and not the cross compiler. stage 3: cross tools (HOST format, HOST object directory) - Builds the cross compiler to run on the HOST machine and generate TARGET machine code. stage 4: build everything (TARGET format, TARGET object directory) - Builds the TARGET libraries and binaries using the cross compilation tools from stage 3 and the build tools from stage 2. The changes I made are: 1. Make the build-tools with the build architecture, not the target. 2. Make the object directories intended for building stage 4 Directories were bring created in the object directory based on the build architecture and not the target architecture. This caused problems building during stage 4 (for an example, look at lib/Makefile in how it builds the csu library). An assumption with this fix is that the build tools object directories will be properly made during this pass. (Note: the cross build probably wouldn't work if this assumption wasn't made). 3. Move the compiler tools from the build tools stage to the cross compilation stage The problem with cc_tools is it creates includes and binaries in stage 2 in the TARGET object directory but the includes are for the HOST system and not the TARGET system. When building stage 4, the binaries from stage 2 are run to create the insn-* files but the includes are not regenerated. This breaks the build since there is now a mixture of HOST and TARGET related data in the same directory. Note: even if the include files were regenerated, there is still Makefile dependencies which will cause the gen* binaries to be regenerated as well. To fix this, I build the tools during stage 3 in the HOST directories, put the HOST directory into the PATH and run the HOST versions when running stage 4. This keeps the 2 sets of files separate. 4. Fix the fortran build tool similar to #3 above It would be nice if someone could reproduce my results and review the patches. Mark -------------------- Index: Makefile.inc1 =================================================================== RCS file: /cvs/freebsd/src/Makefile.inc1,v retrieving revision 1.205 diff -u -r1.205 Makefile.inc1 --- Makefile.inc1 2001/06/14 01:35:22 1.205 +++ Makefile.inc1 2001/07/10 19:36:13 @@ -130,7 +130,7 @@ WORLDTMP= ${OBJTREE}${.CURDIR}/${BUILD_ARCH} # /usr/games added for fortune which depend on strfile STRICTTMPPATH= ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games -TMPPATH= ${STRICTTMPPATH}:${PATH} +TMPPATH= ${STRICTTMPPATH}:${WORLDTMP}${.CURDIR}/gnu/usr.bin/cc/cc_tools:${WORLDTMP}${.CURDIR}/gnu/usr.bin/cc/f771:${PATH} OBJFORMAT_PATH?= /usr/libexec TMPDIR?= /tmp @@ -185,13 +185,14 @@ # build-tool stage TMAKEENV= MAKEOBJDIRPREFIX=${OBJTREE} \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ + MACHINE_ARCH=${BUILD_ARCH} \ PATH=${TMPPATH} TMAKE= ${TMAKEENV} ${MAKE} -f Makefile.inc1 # cross-tool stage XMAKEENV= ${BOOTSTRAPENV} \ TARGET_ARCH=${MACHINE_ARCH} -XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \ +XMAKE= ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_GDB \ -DNOHTML -DNOINFO -DNOMAN -DNOPIC -DNOPROFILE \ -DNOSHARED @@ -272,12 +273,15 @@ @echo ">>> stage 2: cleaning up the object tree" @echo "--------------------------------------------------------------" cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/} +.if ${MACHINE_ARCH} != ${BUILD_ARCH} + cd ${.CURDIR}; ${XMAKE} ${CLEANDIR:S/^/par-/} +.endif .endif @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2: rebuilding the object tree" @echo "--------------------------------------------------------------" - cd ${.CURDIR}; ${TMAKE} par-obj + cd ${.CURDIR}; ${WMAKE} par-obj @echo @echo "--------------------------------------------------------------" @echo ">>> stage 2: build tools" @@ -584,10 +588,6 @@ _share= share/syscons/scrnmaps .endif -.if !defined(NO_FORTRAN) -_fortran= gnu/usr.bin/cc/f771 -.endif - .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \ !defined(NOCRYPT) && defined(MAKE_KERBEROS4) _libroken4= kerberosIV/lib/libroken @@ -599,7 +599,7 @@ .endif build-tools: -.for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \ +.for _tool in bin/csh bin/sh ${_games} \ ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.sbin/sysinstall cd ${.CURDIR}/${_tool}; ${MAKE} build-tools .endfor @@ -630,7 +630,14 @@ _perl= gnu/usr.bin/perl/libperl gnu/usr.bin/perl/miniperl .endif +.if !defined(NO_FORTRAN) +_fortran= gnu/usr.bin/cc/f771 +.endif + cross-tools: +.for _tool in gnu/usr.bin/cc/cc_tools ${_fortran} + cd ${.CURDIR}/${_tool}; ${MAKE} obj; ${MAKE} build-tools +.endfor .for _tool in ${_btxld} ${_elf2exe} ${_perl} \ gnu/usr.bin/binutils usr.bin/objformat gnu/usr.bin/cc cd ${.CURDIR}/${_tool}; \ Index: gnu/usr.bin/cc/cc_tools/Makefile =================================================================== RCS file: /cvs/freebsd/src/gnu/usr.bin/cc/cc_tools/Makefile,v retrieving revision 1.51 diff -u -r1.51 Makefile --- gnu/usr.bin/cc/cc_tools/Makefile 2001/03/02 03:00:41 1.51 +++ gnu/usr.bin/cc/cc_tools/Makefile 2001/07/10 19:36:13 @@ -22,13 +22,13 @@ .for F in attr codes config flags insn-$F.h: gen$F ${MD_FILE} - ./gen$F ${MD_FILE} > insn-$F.h + gen$F ${MD_FILE} > insn-$F.h GENSRCS+= insn-$F.h .endfor .for F in attrtab emit extract opinit output peep recog insn-$F.c: gen$F ${MD_FILE} - ./gen$F ${MD_FILE} > insn-$F.c + gen$F ${MD_FILE} > insn-$F.c GENSRCS+= insn-$F.c .endfor @@ -66,7 +66,7 @@ .ORDER: genrtl.c genrtl.h genrtl.c genrtl.h: gengenrtl - ./gengenrtl genrtl.h genrtl.c + gengenrtl genrtl.h genrtl.c GENSRCS+= genrtl.c genrtl.h @@ -93,7 +93,7 @@ # Common parser stuff. tree-check.h: gencheck - ./gencheck > ${.TARGET} + gencheck > ${.TARGET} GENSRCS+= tree-check.h #----------------------------------------------------------------------- Index: gnu/usr.bin/cc/f771/Makefile =================================================================== RCS file: /cvs/freebsd/src/gnu/usr.bin/cc/f771/Makefile,v retrieving revision 1.6 diff -u -r1.6 Makefile --- gnu/usr.bin/cc/f771/Makefile 2000/03/15 05:13:53 1.6 +++ gnu/usr.bin/cc/f771/Makefile 2001/07/10 19:36:13 @@ -35,7 +35,7 @@ .for i in 1t 2t fo io nq op ot .ORDER: str-$i.h str-$i.j str-$i.j str-$i.h: str-$i.fin fini - ./fini ${GCCDIR}/f/str-$i.fin str-$i.j str-$i.h + fini ${GCCDIR}/f/str-$i.fin str-$i.j str-$i.h FINIHDRS+= str-$i.j str-$i.h .endfor To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message