Discussion:
Cross-compiler
IT geek 31
2014-04-22 11:36:02 UTC
Permalink
Hi,

I'm running NetBSD 5.2.2 on a few Cobalt Qubes and I think they're
fantastic.

However, when it comes to building packages from pkgsrc, they're not so
great... mainly due to their 200MHz processor.

Would it be possible to cross-compile for the Qube architecture on my
NetBSD i386 box (which is infinitely more powerful)?

If so, could someone point me in the direction of a guide on how to do this?

Many thanks,


-Mark
Greg Troxel
2014-04-22 22:52:27 UTC
Permalink
Post by IT geek 31
Hi,
I'm running NetBSD 5.2.2 on a few Cobalt Qubes and I think they're
fantastic.
However, when it comes to building packages from pkgsrc, they're not so
great... mainly due to their 200MHz processor.
Would it be possible to cross-compile for the Qube architecture on my
NetBSD i386 box (which is infinitely more powerful)?
If so, could someone point me in the direction of a guide on how to do this?
Really cross-compiling is pretty hard. See /usr/pkgsrc/doc/*cross*.

But, I can suggest two things that will help and are less hard.

1) Set up ccache, with a big enough cache size. See the guide, but I
have in mk.conf:
PKGSRC_COMPILER= ccache gcc
CCACHE_DIR= /home/gdt/.ccache

2) Use distcc and on the remote machine run the NetBSD toolchain that
you built cross with buidl.sh. Still do the build on the Qube, but have
it use distcc to outsource the actual compiling. This is vastly easier
because the build process for each package will not perceive that
anything is cross. You'll have to do some hackery to get a distcc call
that wants "gcc" to really get the cross version from the TOOLDIR, but
that's way easier than actually making cross-compiling work right. And
it should just be fiddly, not truly hard. I have not done this, just
thought about it. If you do figure out a nice way, it would be great to
document it for others.
Michael van Elst
2014-04-22 22:52:01 UTC
Permalink
Post by IT geek 31
Hi,
I'm running NetBSD 5.2.2 on a few Cobalt Qubes and I think they're
fantastic.
However, when it comes to building packages from pkgsrc, they're not so
great... mainly due to their 200MHz processor.
Would it be possible to cross-compile for the Qube architecture on my
NetBSD i386 box (which is infinitely more powerful)?
If so, could someone point me in the direction of a guide on how to do this?
Cross building packages is difficult because lots of software comes with
build systems (Makefiles, configure scripts) that expect to run natively
or that create their own build tools (e.g. miniperl). There is work going
on, but I doubt that it will ever allow to cross build all of pkgsrc.

However, it is possible to build packages natively and only defer the compiler
to a faster machine. See

http://wiki.netbsd.org/tutorials/pkgsrc/cross_compile_distcc/

for a tutorial.

For some packages this is even the only workable build method as the
native machine wouldn't have enough RAM to run the compiler.
Greg Troxel
2014-04-22 23:09:12 UTC
Permalink
Post by Michael van Elst
However, it is possible to build packages natively and only defer the compiler
to a faster machine. See
http://wiki.netbsd.org/tutorials/pkgsrc/cross_compile_distcc/
for a tutorial.
I forgot about that page. I now remember looking at it, and concluding
that I'd have to figure out how to set the PATH for ssh commands from
particular machines, because I don't use distccd listening in the
clear. With ssh's ControlMaster feature, I find that leaving one ssh
open makes the multiple invocations from distcc go very fast.

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p


Probably I just need a shell script distcc in an early directory that
looks at the ssh variable that denotes the from host, and prepends the
right tooldir.

Loading...