hubertf's NetBSD Blog
Send interesting links to hubert at feyrer dot de!
 
[20081203] One step further in crosscompiling from Solaris (Updated)
In the past few weeks, I've slowly worked to get the NetBSD 5.0 release branch compiling on Solaris. I've made another small step forward today, after fixing the ISO creation process.

The errors that I've stumbled across recently are all of the same sort: Syntax errors from sh, i.e. it breaks immediately while parsing the commands, not later while executing it. As such, tracing is a bit awkward. The core problem is that Solaris' shell trips over for-loops with no variables expanded:

	for foo in
	do ...
Now Solaris' /bin/sh is known to be buggy, but this also happens with /usr/xpg4/bin/sh. The above situation can occur in a Makefile if a make(1) variable is empty, but still expanded, i.e.
	for foo in ${MAKE_VAR}         \
	do ...
A workaround for this was suggested by Alan Barrett, and this is what should be used instead to keep NetBSD crosscompile-able from Solaris:
	shell_var="${MAKE_VAR}";       \
	for foo in $${shell_var};      \
	do ...
There are other workarounds for this situation, but the above is what I've used so far, and it got the build going one step further each time.

Now off to another build, and see where it fails next time! :-)

Update: In private, Jörg pointed out that Alan actually suggested a different solution than what I wrote here, i.e. using ${MAKE_VAR:Q} to quote any strange chars in the variable, instead of simply putting it into double quotes. This is e.g. important if the variable has values with `` which would be expanded in my case. For the case at hands -- NetBSD(:-) -- this doesn't make a difference.

After the change described above, NetBSD's base system and kernels can be cross compiled from Solaris (woot!). Only X is still struggling and after making sure NetBSD's (tool)awk is used instead of Solaris' native awk in one place, a "make build" in src/external/mit/xorg works, too. Right now I'm only seeing some strange errors when doing a full "build.sh -x", but I hope to have that going soon, too. Stay tuned!

[Tags: , ]


Disclaimer: All opinion expressed here is purely my own. No responsibility is taken for anything.

Access count: 36037945
Copyright (c) Hubert Feyrer