Subject: Re: on solaris 2.7
To: Manuel Bouyer <>
From: Todd Vierling <>
List: tech-toolchain
Date: 03/27/2002 18:46:11
I'll get back to you in private about the attached diff; please don't commit
as-is.  There's some nits that need to be cleaned up in the process.


On Wed, 27 Mar 2002, Manuel Bouyer wrote:

: First is the shell problem. /bin/sh isn't good enouth and remplacing it isn't
: an option for me. I added a new variable to, HOST_SHELL, which
: defaults to /bin/sh. I added call to $HOST_SHELL in various places in makefiles
: and scripts.

The transition to $HOST_SHELL is plausible, but it would ideally default to
"sh" (no pathname).  (My instructions to put /usr/xpg4/bin earlier in $PATH
than /usr/bin would make sure that you get the Right shell with just "sh".)

However, this conflicts with the following, so defaulting to "/bin/sh" is ok
by me.

: make has the path to the shell hardcoded.


: Second I found that 'config.h' for the compat stuff was a bad name, because
: there are several config.h around in the tree. Sometimes the wrong one was
: used.

When?  The stuff in src/tools certainly shouldn't have that problem.

However, I'm open to possibly renaming it.


: I added a HOST_CPPFLAGS variable to (it already had HOST_CLFLAGS and

That should be ok.

: I had to use a -idirafter in HOST_CPPFLAGS, but host-mkdep didn't't handle it,

Why?  This should certainly not be necessary on Solaris 7.


: I also found an issue with UPDATE in -u sets UPDATE
: to yes, not the empty string. __archiveinstall uses a construct which
: assumes that UPDATE is empty when defined.

Luke fixed this udage of UPDATE in rev. 1.199 of


: makelintstub uses cpp, I made it use "${CPP}" instead of "cpp".

This is the right thing to do.  Ideally it should be made to use ${CC} -E,
as direct use of ${CPP} should be considered deprecated.  I'll look into
doing that.


: Some tools can't be compiled or used on non-NetBSD hosts yet (e.g.
: sparc-installboot), I added a test for NetBSD in tools/Makefile and
: use it to exclude some hosts tools.

That's fine.  dbsym should be in this category, too.


: tools/makefs/Makefile uses a ln -f which solaris's ln doens't understant.
: As there is an explicit rm just before, -f isn't needed here.

Did you remember to put /usr/xpg4/bin earlier in your $PATH than /usr/bin as
I keep mentioning?  It's pretty important, and that's why it is
mentioned in src/tools/compat/README...!

The use of /usr/xpg4/bin is MANDATORY so as to provide a decently
standards-conforming command environment.  The tools in /usr/bin have some
subtle but annoying breakage from a standards point-of-view.  We don't need
to modify our Makefiles when the commands they use are pretty much Standard.


: xlint wants to use MAP_ANON, I added a check for this in compat/configure,
: and defaults to malloc if not available.

This can be corrected in a much better way, and I'll provide the fix.
(There's a canned autoconf test that can determine if MAP_ANON exists, and
if not, tries mmap of /dev/zero instead.)


: rpc.pcnfsd uses a local makefile hack to make genetared headers depend on the
: rpcgen binary. Other rpc utilities don't do that so I removed it. If we really
: want this we'll have to make it in share/mk and use it for all makefiles
: calling rpc.

Um, this is done in a bunch of other places.  Look in src/lib/librpcsvc, for
one.  The test probably just needs to be fixed to be uniform with the rest;
I'll check.


: For some tools solaris's glob isn't good enouth. I added __glob13.c/glob.h to
: libcompat.
: On solaris some tools also want -lsocket, I added a check for this in
: tools/compat/comfigure.

Sounds good; I'll look at it.


: Here are the unresolved issue yet:
: First a few host tools can't be compiled on non-NetBSD hosts.
: sparc-installboot and dbsym aren't critical for now. dbsym could use
: a trick similar to mips-elf2ecoff (use cut-down NetBSD headers in tool
: dir),

No.  dbsym already uses bfd; it just needs to be converted to use bfd
*completely*.  I try to avoid using NetBSD's own headers on the host
wherever possible; the few exceptions in src/tools/compat were mostly

(mips-elf2ecoff should be converted to use BFD as well, and/or it should be
replaced by specialized linker scripts and objcopy.)


: but sparc-installboot needs fondamental rework as it wants to work
: on devices.

Known.  It needs treatment similar to how alpha's installboot can deal with
fs images.


: A more annoying one is mklocale. It's brocken because it uses types and
: unions defined in md header (machine/ansi.h) to dump a binary file
: for the target host. For now it's not a problem for NetBSD->NetBSD compiles,
: because the types and unions are the same on all NetBSD-suppored arch.
: But when NetBSD will be ported to a machine with different alignement
: constraints, or a non-32bit int this will become a problem.
: I don't know how to solve this, exept duplicating the part we need from
: ansi.h for all NetBSD archs, in the tool dir. Idea welcome.

The locale stuff is somewhat ugly, and needs work.  However, mklocale was
supposed to be fixed some time ago to use #ifdef'd portions of the .h files
that use only bit-sized types.  Provided those structs have the GCC
attribute((packed)), there should be no problems with differently-aligned

Also, all major architectures currently in use have alignments of no more
than the size of the type itself for integer types.  That is, the following
struct has no gaps in space, even for alpha and sparc64:

struct foo {
	char var1;
	int8_t var2;
	int16_t var3;
	int32_t var4;
	int64_t var5;

Provided the struct obeys this strictly, there should be no problem even if


: My make build has stopped on build of host tools that are not in the
: src/tools dir: mk* in bin/sh, mkmagic in usr/bin/file, etc ...
: The probleme here is that these tools are build without src/tools/compat.

Yes, although the majority of *these* tools should be capable of being more
compatible with non-NetBSD hosts without necessarily using libcompat.
(Quite a few tools in src/tools have only passing need for libcompat.)

: It should be easy to add path and library calls to HOST_* from share/mk,
: but the problem here is that we need to include tools/compat/,
: and this one changes DPADD and LDADD. It should change HOST_DPADD and
: HOST_LDADD instead, and get DPADD/LDADD updated in
: I didn't look at this yet.

I'll look into it.

-- Todd Vierling <>  *  Wasabi & NetBSD:  Run with it.
-- CDs, Integration, Embedding, Support --