Couple of snags cross-installing after cross-compiling

Nathan Dorfman na at rtfm.net
Sat Jan 4 19:35:21 UTC 2014


Hello all,

I have a small FreeBSD/mips machine (the EdgeRouter Lite), and I want to
cross-build world and kernel on my larger amd64 machine, then install the
result on the target system. I'm doing this by exporting via NFS from the build
machine, and it seems to be working well, just two small snafus along the way.
Hopefully this isn't considered crazy and unsupported, because it almost
works. :)

Note: this is releng/10 (r260251), not head.

The only trouble is that buildworld produces a toolchain for the host, not
target, machine in $WORLDTMP, which is first in the PATH for subsequent
commands. So, when installkernel is run on the mips64 target, it tries to
execute those amd64 binaries:

    --------------------------------------------------------------
    >>> Installing kernel ERL
    --------------------------------------------------------------
    cd /usr/obj/usr/src/sys/ERL; [...]
PATH=/usr/obj/usr/src/tmp/legacy/usr/sbin:/usr/obj/usr/src/tmp/legacy/usr/bin:/usr/obj/usr/src/tmp/legacy/usr/games:/usr/obj/usr/src/tmp/legacy/bin:/usr/obj/usr/src/tmp/usr/sbin:/usr/obj/usr/src/tmp/usr/bin:/usr/obj/usr/src/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin
 make  KERNEL=kernel install

    cc: Exec format error
    make[2]: "/usr/src/share/mk/bsd.compiler.mk" line 9: warning: "cc
--version" returned non-zero status
    [...]

If for some reason installworld is run first, it fails similarly. To get around
this, all that's needed is rm -rf $WORLDTMP. The install proceeds using the
tools in /bin and /usr/bin. I also tried changing the definition of WORLDTMP in
Makefile.inc1 from just 'tmp' to 'tmp.$(MACHINE_ARCH)' before running the
buildworld, and that works to stop this error before it occurs.

This probably isn't right since I think I want to be running new, not
previously installed, binaries here. There's no cross-compiling of $WORLDTMP,
but can I just point it at the entire freshly built world, /usr/obj/usr/src,
instead? In any case, for the time being, with the wrong-arch $WORLDTMP not
there, installkernel succeeds and installworld proceeds to fail slightly later,
with this:

    ===> lib/libc (install)
    install -C -o root -g wheel -m 444   libc.a /usr/lib
    install -C -o root -g wheel -m 444   libc_p.a /usr/lib
    install -s -o root -g wheel -m 444   -fschg -S  libc.so.7 /lib
    install: exec(strip): No such file or directory

Here, the default system path (/usr/bin, etc.) is not in the PATH; it consists
only of the various subdirs of $WORLDTMP, followed by one new directory
/tmp/install.3aqj2XwQ. I noticed that this path was only just created by a
preceding step, and easily fixed the error by adding strip to the list of
ITOOLS= in Makefile.inc1.

Here's what's confusing: why does that /tmp/install directory exist in the
first place? It's behind $WORLDTMP in the path, so under normal circumstances,
it wouldn't be used. I began to suspect that might be unintentional, but I
don't know much about the FreeBSD build system, so I'd like to ask someone who
does!

Anyway, after adding strip to ITOOLS, installworld also succeeds, and life is
good.

Thanks,
-nd.


More information about the freebsd-mips mailing list