# NanoBSD Build Failure



## tomdean (May 21, 2012)

I am attempting to rebuild nanoBSD on an AMD64 system, using the same config file I used a couple years ago on a 32-bit system.

The host system (system I am building on)

```
> uname -a
FreeBSD P9X79.tddhome 9.0-STABLE FreeBSD 9.0-STABLE #2: Fri May 11 20:41:54 PDT 2012     tomdean@P9X79.tddhome:/usr/src/sys/GENERIC  amd64
```

The target system is a TS5700 SBC.  From dmesg:

```
...
FreeBSD 6.2-PRERELEASE #0: Sun Oct 15 16:25:50 PDT 2006
    tomdean@asus.tddhome:/usr/obj/nanobsd.full/usr/src/sys/GENERIC
...
CPU: AMD Enhanced Am486DX4/Am5x86 Write-Back (486-class CPU)
  Origin = "AuthenticAMD"  Id = 0x494  Stepping = 4
  Features=0x1<FPU>
real memory  = 67108864 (64 MB)
...
```

The buildworld part finished Ok.  The gcc arguments seem OK for a 32-bit system.

Buildkernel fails:


```
--------------------------------------------------------------
>>> Kernel build for MYKERNEL started on Sun May 20 19:36:28 PDT 2012
--------------------------------------------------------------
===> MYKERNEL
mkdir -p /usr/obj/nanobsd.TS5700//usr/src/sys
--------------------------------------------------------------
>>> stage 1: configuring the kernel
--------------------------------------------------------------
cd /usr/src/sys/amd64/conf; PATH=/usr/obj/nanobsd.TS5700//usr/src/tmp/legacy/usr/sbin:/usr/obj/nanobsd.TS5700//usr/src/tmp/legacy/usr/bin:/usr/obj/nanobsd.TS5700//usr/src/tmp/legacy/usr/games:/usr/obj/nanobsd.TS5700//usr/src/tmp/usr/sbin:/usr/obj/nanobsd.TS5700//usr/src/tmp/usr/bin:/usr/obj/nanobsd.TS5700//usr/src/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin  config  -d /usr/obj/nanobsd.TS5700//usr/src/sys/MYKERNEL /usr/home/tomdean/nanoBSD/MYKERNEL
/usr/home/tomdean/nanoBSD/MYKERNEL: unknown option "I486_CPU"
*** Error code 1
1 error
*** Error code 2
1 error
```

Any ideas?

Tom Dean


----------



## johnd (May 21, 2012)

Just a wild guess: a missing TARGET= in front of I486_CPU in your kernel configuration file MYKERNEL.


----------



## tomdean (May 21, 2012)

I was building in the AMD64 tree as someone pointed out in another list.

I plan to installl 8.2 i386 for working with nanoBSD.


----------



## SirDice (May 21, 2012)

No need to install a seperate system. I think you can get away with running an i386 jail on your amd64 host. That should enable you to build it.


----------



## tomdean (May 21, 2012)

Your earlier reply supplied a hint. I added 
	
	



```
NANO_TARGET=i386
```
 to my nanoBSD.config and got past the kernel configuration stage.

Now, it fails in getassym.c because there is no -m32 in the CFLAGS.


```
cd /usr/obj/nanobsd.TS5700//i386.i386/usr/src/sys/MYKERNEL;
cc -c -O -pipe -std=c99 -g -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes
 -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -Wmissing-include-dirs
 -fdiagnostics-show-option -nostdinc -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq
 -I/usr/src/sys/contrib/ipfilter -I/usr/src/sys/contrib/pf -I/usr/src/sys/dev/ath -I/usr/src/sys/dev/ath/ath_hal
 -I/usr/src/sys/contrib/ngatm -I/usr/src/sys/dev/twa -I/usr/src/sys/gnu/fs/xfs/FreeBSD
 -I/usr/src/sys/gnu/fs/xfs/FreeBSD/support -I/usr/src/sys/gnu/fs/xfs -I/usr/src/sys/dev/cxgb
 -I/usr/src/sys/dev/cxgbe -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -finline-limit=8000
 --param inline-unit-growth=100 --param large-function-growth=1000 -mno-align-long-strings
 -mpreferred-stack-boundary=2 -mno-mmx -mno-sse -msoft-float -ffreestanding -fstack-protector
 /usr/src/sys/i386/i386/genassym.c
```
Adding -m32 to this command allows it to succeed.

Now, where to get -m32?


----------



## tomdean (May 21, 2012)

I managed to creats a nanoBSd image, mount it, etc. in amd64.

I changed src/tools/tools/nanobsd/nanoBSD.cfg

```
diff nanoBSD.cfg~ nanoBSD.cfg
7a8,9
> NANO_ARCH=i386
> NANO_PMAKE="make -j 3 TARGET=i386 TARGET_ARCH=i386"
P9X79: {519} diff -c nanoBSD.cfg~ nanoBSD.cfg
*** nanoBSD.cfg~        Sun May 20 20:54:21 2012
--- nanoBSD.cfg Mon May 21 11:37:11 2012
***************
*** 5,10 ****
--- 5,12 ----
  NANO_SRC=/usr/src
  NANO_KERNEL=MYKERNEL
  NANO_IMAGES=2
+ NANO_ARCH=i386
+ NANO_PMAKE="make -j 3 TARGET=i386 TARGET_ARCH=i386"
  
  CONF_BUILD='
  NO_KLDLOAD=YES
```
to override the definition of NANO_PMAKE and NANO_ARCH in 
sys/src/tools/tools/nanobsd/nanobsd.sh.

The result is a set of 32-bit executables and a 32-bit kernel in the nanoBSD images,
_.disk.full and _.disk.image.


----------

