# cross-compile problems



## bigdweeb (Apr 22, 2013)

Hi,
I used to be a heavy FreeBSD user years ago but I'm out of practice.  I have been trying to build NanoBSD for a Soekris Net4501 I just picked up, but I'm running into problems.

I have never built NanoBSD or cross-compiled anything really, so I'm guessing I'm missing some steps.  I've tried following the how-to and any other information I've been able to piece together, but I'm stuck at this point.

Here's where I'm at.  I am running FreeBSD 8.3-RELEASE in a VM.  I started with 9.1, but I've read there can be problems with systems with small amounts of RAM like the Soekris.  Also, I am running an AMD64 environment and trying to cross-compile to i386.  I have a GENERIC install running and I have installed a lot of ports from source.  I pieced together what I think are the necessary files, an kernel config and a conf file.  It seems that the buildworld completes, but the kernel will not compile and I get an error.

Here's what I'm working with:

The base system I am using to build NanoBSD

```
$ uname -a
FreeBSD freebsd-83.bc.edu 8.3-RELEASE FreeBSD 8.3-RELEASE #0: Mon Apr  9 21:23:18 UTC 2012     root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
```


----------



## bigdweeb (Apr 22, 2013)

My kernel configuration for NanoBSD:

```
cpu             I486_CPU
ident           CLANG
options         CPU_ELAN
options         CPU_SOEKRIS
options         HZ=150
options         CPU_ELAN_PPS
options         CPU_GEODE
#options        CPU_ELAN_XTAL

# To statically compile in device wiring instead of /boot/device.hints
#hints          "GENERIC.hints"         # Default places to look for devices.

# Use the following to compile in values accessible to the kernel
# through getenv() (or kenv(1) in userland). The format of the file
# is 'variable=value', see kenv(1)
#
# env           "GENERIC.env"

#makeoptions    DEBUG=-g                # Build kernel with gdb(1) debug symbols

options         SCHED_ULE               # ULE scheduler
options         PREEMPTION              # Enable kernel thread preemption
options         INET                    # InterNETworking
options         INET6                   # IPv6 communications protocols
options         SCTP                    # Stream Control Transmission Protocol
options         FFS                     # Berkeley Fast Filesystem
#options        SOFTUPDATES             # Enable FFS soft updates support
#options        UFS_ACL                 # Support for access control lists
#options        UFS_DIRHASH             # Improve performance on big directories
#options        UFS_GJOURNAL            # Enable gjournal-based UFS journaling
options         MD_ROOT                 # MD is a potential root device
options         NFSCLIENT               # Network Filesystem Client
#options        NFSSERVER               # Network Filesystem Server
options         NFSLOCKD                # Network Lock Manager
#options        NFS_ROOT                # NFS usable as /, requires NFSCLIENT
#options        MSDOSFS                 # MSDOS Filesystem
#options        CD9660                  # ISO 9660 Filesystem
#options        PROCFS                  # Process filesystem (requires PSEUDOFS)
#options        PSEUDOFS                # Pseudo-filesystem framework
#options        GEOM_PART_GPT           # GUID Partition Tables.
options         GEOM_LABEL              # Provides labelization
options         COMPAT_43TTY            # BSD 4.3 TTY compat (sgtty)
#options        COMPAT_FREEBSD4         # Compatible with FreeBSD4
#options        COMPAT_FREEBSD5         # Compatible with FreeBSD5
#options        COMPAT_FREEBSD6         # Compatible with FreeBSD6
#options        COMPAT_FREEBSD7         # Compatible with FreeBSD7
options         SCSI_DELAY=5000         # Delay (in ms) before probing SCSI
#options        KTRACE                  # ktrace(1) support
#options        STACK                   # stack(9) support
options         SYSVSHM                 # SYSV-style shared memory
options         SYSVMSG                 # SYSV-style message queues
options         SYSVSEM                 # SYSV-style semaphores
options         P1003_1B_SEMAPHORES     # POSIX-style semaphores
options         _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options         PRINTF_BUFR_SIZE=128    # Prevent printf output being interspersed.
options         KBD_INSTALL_CDEV        # install a CDEV entry in /dev
#options        HWPMC_HOOKS             # Necessary kernel hooks for hwpmc(4)
#options        AUDIT                   # Security event auditing
#options        MAC                     # TrustedBSD MAC Framework
#options        KDTRACE_HOOKS           # Kernel DTrace hooks
options         INCLUDE_CONFIG_FILE     # Include this file in kernel

#options        KDB                     # Kernel debugger related code
#options        KDB_TRACE               # Print a stack trace for a panic

# To make an SMP kernel, the next two lines are needed
#options        SMP                     # Symmetric MultiProcessor Kernel
#device         apic                    # I/O APIC

# CPU frequency control
#device         cpufreq

# Bus support.
#device         acpi
device          eisa
device          pci

# Floppy drives
#device         fdc

# ATA and ATAPI devices
device          ata
device          atadisk         # ATA disk drives
#device         ataraid         # ATA RAID drives
#device         atapicd         # ATAPI CDROM drives
#device         atapifd         # ATAPI floppy drives
#device         atapist         # ATAPI tape drives
options         ATA_STATIC_ID   # Static device numbering

# atkbdc0 controls both the keyboard and the PS/2 mouse
#device         atkbdc          # AT keyboard controller
#device         atkbd           # AT keyboard
#device         psm             # PS/2 mouse

#device         kbdmux          # keyboard multiplexer

#device         vga             # VGA video card driver

#device         splash          # Splash screen and screen saver support

# syscons is the default console driver, resembling an SCO console
#device         sc

#device         agp             # support several AGP chipsets

# Power management support (see NOTES for more options)
#device         apm
# Add suspend/resume support for the i8254.
device          pmtimer

# PCCARD (PCMCIA) support
# PCMCIA and cardbus bridge support
#device         cbb             # cardbus (yenta) bridge
#device         pccard          # PC Card (16-bit) bus
#device         cardbus         # CardBus (32-bit) bus

# Serial (COM) ports
device          uart            # Generic UART driver

# Parallel port
#device         ppc
#device         ppbus           # Parallel port bus (required)
#device         lpt             # Printer
#device         plip            # TCP/IP over parallel
#device         ppi             # Parallel port interface device
#device         vpo             # Requires scbus and da

#device         puc             # Multi I/O cards and multi-channel UARTs

# PCI Ethernet NICs that use the common MII bus controller code.
# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
device          miibus          # MII bus support
device          sis             # Silicon Integrated Systems SiS 900/SiS 7016

# Pseudo devices.
device          loop            # Network loopback
device          random          # Entropy device
device          ether           # Ethernet support
device          vlan            # 802.1Q VLAN support
device          tun             # Packet tunnel.
device          pty             # BSD-style compatibility pseudo ttys
device          md              # Memory "disks"
device          gif             # IPv6 and IPv4 tunneling
device          faith           # IPv6-to-IPv4 relaying (translation)
device          firmware        # firmware assist module

# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
device          bpf             # Berkeley packet filter
```


----------



## bigdweeb (Apr 22, 2013)

Here is my configuration file:

```
freebsd-83# cat clang.conf
NANO_NAME=clang
NANO_SRC=/usr/src
NANO_KERNEL=CLANG
NANO_ARCH=i386
NANO_IMAGES=2
#NANO_MD_BACKING=swap
NANO_PMAKE="make -j 4"

#NANO_PACKAGE_LIST='. -name *.tbz'
CONF_BUILD='
'

CONF_INSTALL='
WITHOUT_TOOLCHAIN=YES
WITHOUT_CPP=YES
WITHOUT_INSTALLLIB=YES
'

CONF_WORLD='
TARGET=i386
TARGET_ARCH=i386
WITHOUT_MODULES=YES
WITHOUT_ACPI=YES
WITHOUT_ASSERT_DEBUG=YES
WITHOUT_AUDIT=YES
WITHOUT_AUTHPF=YES
WITHOUT_BIND=YES
WITHOUT_CALENDAR=YES
WITHOUT_CDDL=YES
WITHOUT_CVS=YES
WITHOUT_CTM=YES
WITHOUT_DICT=YES
WITHOUT_DYNAMICROOT=YES
WITHOUT_EXAMPLES=YES
WITHOUT_FLOPPY=YES
WITHOUT_FORTRAN=YES
WITHOUT_GAMES=YES
WITHOUT_GCOV=YES
WITHOUT_GDB=YES
WITHOUT_GPIB=YES
WITHOUT_GROFF=YES
WITHOUT_HTML=YES
WITHOUT_I4B=YES
WITHOUT_INFO=YES
#WITHOUT_IPFILTER=YES
WITHOUT_IPX=YES
WITHOUT_KERBEROS=YES
WITHOUT_LPR=YES
WITHOUT_MAILWRAPPER=YES
#WITHOUT_MAN=YES
#WITHOUT_NETCAT=YES
WITHOUT_NETGRAPH=YES
WITHOUT_NIS=YES
WITHOUT_NLS=YES
WITHOUT_NLS_CATALOGS=YES
WITHOUT_NS_CACHING=YES
WITHOUT_OBJC=YES
WITHOUT_OFED=YES
WITHOUT_PF=YES
WITHOUT_PPP=YES
WITHOUT_PROFILE=YES
WITHOUT_RCMDS=YES
WITHOUT_RCS=YES
WITHOUT_RESCUE=YES
WITHOUT_SENDMAIL=YES
WITHOUT_SHAREDOCS=YES
WITHOUT_SSP=YES
WITHOUT_SYSCONS=YES
WITHOUT_USB=YES
WITHOUT_WIRELESS=YES
WITHOUT_WPA_SUPPLICANT_EAPOL=YES
WITHOUT_NCP=YES
WITHOUT_ZFS=YES
'


FlashDevice SanDisk 4G

cust_nobeastie() (
    touch ${NANO_WORLDDIR}/boot/loader.conf
    echo "beastie_disable=\"YES\"" >> ${NANO_WORLDDIR}/boot/loader.conf
)


customize_cmd cust_comconsole
customize_cmd cust_pkg
customize_cmd cust_allow_ssh_root
customize_cmd cust_install_files
customize_cmd cust_nobeastie
```


----------



## bigdweeb (Apr 22, 2013)

Here is the error from my _.bk file after running the following command: `freebsd-83# sh nanobsd.sh -c clang.conf -w`

```
===> 3dfx (depend)
machine -> /usr/src/sys/i386/include
awk -f /usr/src/sys/tools/vnode_if.awk /usr/src/sys/kern/vnode_if.src -p
awk -f /usr/src/sys/tools/vnode_if.awk /usr/src/sys/kern/vnode_if.src -q
@ -> /usr/src/sys
awk -f /usr/src/sys/tools/miidevs2h.awk /usr/src/sys/dev/mii/miidevs
machine -> /usr/src/sys/i386/include
awk -f @/tools/makeobjops.awk @/dev/pci/pci_if.m -h
awk -f @/tools/makeobjops.awk @/kern/bus_if.m -h
awk -f @/tools/makeobjops.awk @/kern/device_if.m -h
awk -f /usr/src/sys/tools/pccarddevs2h.awk /usr/src/sys/dev/pccard/pccarddevs
rm -f .depend
awk -f /usr/src/sys/tools/vnode_if.awk /usr/src/sys/kern/vnode_if.src -c
mkdep -f .depend -a   -nostdinc -D_KERNEL -DKLD_MODULE -DHAVE_KERNEL_OPTION_HEADERS -I. -I@ -I@/contrib/altq -I/usr/obj/nanobsd.clan
g/i386/usr/src/sys/CLANG /usr/src/sys/modules/3dfx/../../dev/tdfx/tdfx_pci.c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/ata/ata_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/eisa/eisa_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/mii/miibus_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/mmc/mmcbr_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/mmc/mmcbus_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pccard/card_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pccard/power_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pci_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pcib_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/uart/uart_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/geom/part/g_part_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/isa/isa_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/bus_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/clock_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/cpufreq_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/device_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/linker_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/serdev_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/acpica/acpi_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/acpi_support/acpi_wmi_if.m -c
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/ata/ata_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/eisa/eisa_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/mii/miibus_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/mmc/mmcbr_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/mmc/mmcbus_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pccard/card_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pccard/power_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pci_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/pci/pcib_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/uart/uart_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/geom/part/g_part_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/isa/isa_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/bus_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/clock_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/cpufreq_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/device_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/linker_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/serdev_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/acpica/acpi_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/dev/acpi_support/acpi_wmi_if.m -h
awk -f /usr/src/sys/tools/vnode_if.awk /usr/src/sys/kern/vnode_if.src -h
cc -c -O2 -pipe -fno-strict-aliasing -std=c99 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -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-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding /usr/src/sys/i386/i386/genassym.c
/usr/src/sys/i386/i386/genassym.c:1: error: -mpreferred-stack-boundary=2 is not between 4 and 12
*** Error code 1
===> 3dfx_linux (depend)
@ -> /usr/src/sys
machine -> /usr/src/sys/i386/include
rm -f .depend
mkdep -f .depend -a   -nostdinc -D_KERNEL -DKLD_MODULE -DHAVE_KERNEL_OPTION_HEADERS -I. -I@ -I@/contrib/altq -I/usr/obj/nanobsd.clang/i386/usr/src/sys/CLANG /usr/src/sys/modules/3dfx_linux/../../dev/tdfx/tdfx_linux.c
===> aac (depend)
@ -> /usr/src/sys
machine -> /usr/src/sys/i386/include
ln -sf /usr/obj/nanobsd.clang/i386/usr/src/sys/CLANG/opt_scsi.h opt_scsi.h
ln -sf /usr/obj/nanobsd.clang/i386/usr/src/sys/CLANG/opt_cam.h opt_cam.h
ln -sf /usr/obj/nanobsd.clang/i386/usr/src/sys/CLANG/opt_aac.h opt_aac.h
awk -f @/tools/makeobjops.awk @/dev/pci/pci_if.m -h
awk -f @/tools/makeobjops.awk @/kern/bus_if.m -h
awk -f @/tools/makeobjops.awk @/kern/device_if.m -h
rm -f .depend
mkdep -f .depend -a   -nostdinc -D_KERNEL -DKLD_MODULE -DHAVE_KERNEL_OPTION_HEADERS -I. -I@ -I@/contrib/altq -I/usr/obj/nanobsd.clang/i386/usr/src/sys/CLANG /usr/src/sys/modules/aac/../../dev/aac/aac.c /usr/src/sys/modules/aac/../../dev/aac/aac_pci.c /usr/src/sys/modules/aac/../../dev/aac/aac_disk.c /usr/src/sys/modules/aac/../../dev/aac/aac_cam.c
===> aac/aac_linux (depend)
@ -> /usr/src/sys
machine -> /usr/src/sys/i386/include
rm -f .depend
mkdep -f .depend -a   -nostdinc -D_KERNEL -DKLD_MODULE -DHAVE_KERNEL_OPTION_HEADERS -I. -I@ -I@/contrib/altq -I/usr/obj/nanobsd.clang/i386/usr/src/sys/CLANG /usr/src/sys/modules/aac/aac_linux/../../../dev/aac/aac_linux.c
/usr/src/sys/modules/aac/aac_linux/../../../dev/aac/aac_linux.c:42:38: error: machine/../linux32/linux.h: No such file or directory
/usr/src/sys/modules/aac/aac_linux/../../../dev/aac/aac_linux.c:43:46: error: machine/../linux32/linux32_proto.h: No such file or directory
mkdep: compile failed
*** Error code 1
1 error
*** Error code 2
1 error
*** Error code 2
1 error
*** Error code 2
2 errors
*** Error code 2
1 error
*** Error code 2
1 error
```


----------



## bigdweeb (Apr 22, 2013)

I figured it out.  I had been trying to build with out the TARGET=i386 and TARGET_ARCH=i386 variables in my configuration file originally.  I had corrected that and then tried to build the kernel without rerunning the buildworld part of the NanoBSD process.  Once I started from scratch, it successfully built an image.


----------

