At 3:15 AM +0200 7/9/01, Dag-Erling Smorgrav wrote:
>Warner Losh <[EMAIL PROTECTED]> 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.



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 @@
  # /usr/games added for fortune which depend on strfile
  STRICTTMPPATH=        ${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin:${WORLDTMP}/usr/games
  OBJFORMAT_PATH?=      /usr/libexec

  TMPDIR?=      /tmp
@@ -185,13 +185,14 @@
  # build-tool stage
                INSTALL="sh ${.CURDIR}/tools/" \
+               MACHINE_ARCH=${BUILD_ARCH} \
  TMAKE=                ${TMAKEENV} ${MAKE} -f Makefile.inc1

  # cross-tool stage
-XMAKE=         ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_FORTRAN -DNO_GDB \
+XMAKE=         ${XMAKEENV} ${MAKE} -f Makefile.inc1 -DNO_GDB \

@@ -272,12 +273,15 @@
        @echo ">>> stage 2: cleaning up the object tree"
        @echo "--------------------------------------------------------------"
        cd ${.CURDIR}; ${TMAKE} ${CLEANDIR:S/^/par-/}
+       cd ${.CURDIR}; ${XMAKE} ${CLEANDIR:S/^/par-/}
        @echo "--------------------------------------------------------------"
        @echo ">>> stage 2: rebuilding the object tree"
        @echo "--------------------------------------------------------------"
-       cd ${.CURDIR}; ${TMAKE} par-obj
+       cd ${.CURDIR}; ${WMAKE} par-obj
        @echo "--------------------------------------------------------------"
        @echo ">>> stage 2: build tools"
@@ -584,10 +588,6 @@
  _share=       share/syscons/scrnmaps

-.if !defined(NO_FORTRAN)
-_fortran= gnu/usr.bin/cc/f771
  .if exists(${.CURDIR}/kerberosIV) && exists(${.CURDIR}/crypto) && \
      !defined(NOCRYPT) && defined(MAKE_KERBEROS4)
  _libroken4= kerberosIV/lib/libroken
@@ -599,7 +599,7 @@

-.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
@@ -630,7 +630,14 @@
  _perl=        gnu/usr.bin/perl/libperl gnu/usr.bin/perl/miniperl

+.if !defined(NO_FORTRAN)
+_fortran= gnu/usr.bin/cc/f771
+.for _tool in gnu/usr.bin/cc/cc_tools ${_fortran}
+       cd ${.CURDIR}/${_tool}; ${MAKE} obj; ${MAKE} build-tools
  .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

  .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

@@ -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

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to