Subject: Re: cross compile with Linux host fails with nbmake Illegal instruction
To: Jeremy C. Reed <reed@reedmedia.net>
From: James Chacon <jmc@NetBSD.org>
List: tech-toolchain
Date: 02/06/2005 01:21:21
On Sat, Feb 05, 2005 at 10:10:25PM -0800, Jeremy C. Reed wrote:
> I am trying cross compiling of -current on a Linux host. I have
> linux-kernel-headers-2.6.10, gcc3-c-3.3.4, gcc3-c++-3.3.4, bmake-20040220
> (no gmake installed), binutils-2.14.0.0, and mk-files-20040214 installed.

What kind of linux host? I have no issues with standard redhat builds
and I understand debian also works well.

You'll need to fully cross build, but you shouldn't need to set anything
provided a compiler is in your path.

James

> 
> I used HOST_CC to choose my gcc.
> 
> 1)
> HOST_CC=/usr/gcc3/bin/cc ./build.sh -m i386 -U tools
> 
> The above fails with:
> 
> ===> No nonexistent/bin/nbmake, needs building.
> ===> Bootstrapping nbmake
> checking for sh... /bin/sh
> checking for gcc... /usr/gcc3/bin/cc
> checking for C compiler default output... a.out
> checking whether the C compiler works... configure: error: cannot run C
> compiled programs.
> If you meant to cross compile, use `--host'.
> 
> "nonexistent/bin/nbmake" seems like a typo. But then I saw it in the
> build.sh. I don't understand why it didn't automatically create a
> destination for the to-be-built tools nor any object OBJDIR directory.
> 
> 2) Then I tried:
>  host_alias=i386-pc-linux-gnu HOST_CC=/usr/gcc3/bin/cc ./build.sh -m i386 -U tools
> 
> which failed with:
> 
> /usr/gcc3/bin/cc  -O -D_PATH_BSHELL="/bin/sh" -D_PATH_DEFSHELLDIR="/bin"
> -DHAVE_SETENV=1 -DHAVE_STRDUP=1 -DHAVE_STRERROR=1 -DHAVE_STRFTIME=1
> -DHAVE_VSNPRINTF=1  -DMAKE_BOOTSTRAP
> -I/home/reed/netbsd/src/tools/make/../../usr.bin/make -c
> /home/reed/netbsd/src/tools/make/../../usr.bin/make/lst.lib/lstSucc.c
> /usr/gcc3/bin/cc  -O -o nbmake *.o
> /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to
> 08049800
> ./build.sh: line 1078: 17835 Illegal instruction     ${runcmd} "${make}"
> -m ${TOP}/share/mk obj NOSUBDIR=
> 
> ERROR: Failed to make obj in tools
> *** BUILD ABORTED ***
> 
> 
> host_alias above sets --host for the type of system for the program to run
> on.
> 
> The builds were done in /tmp/nbbuild17195/ but that was promptly removed
> when this build was finished.
> 
> 3) So I commented out that trap that did that.
> 
> $ file /tmp/nbbuild17884/nbmake
> /tmp/nbbuild17884/nbmake: ELF 32-bit LSB executable, Intel 80386, version
> 1 (SYSV), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not
> stripped
> 
> $  /tmp/nbbuild17884/nbmake -v
> Illegal instruction
> 
> (Well I know -v doesn't do anything other than print out unknown option
> and Usage statement.)
> 
> 4) So I set USETOOLS=never and it still did the build of tools/make (and
> failed at end).
> 
> Any ideas?
> 
> How do I get it to not cross-compile (even though I don't see why that
> matters) for the tools?
> 
> (Please CC me on replies.)
> 
> Thank you,
> 
>  Jeremy C. Reed
> 
>  	  	 	 BSD News, BSD tutorials, BSD links
> 	  	 	 http://www.bsdnewsletter.com/
> 
> 
>