[cfe-dev] netbsd & gcc 4.6 triple

James K. Lowden jklowden at schemamania.org
Tue Apr 24 13:50:27 PDT 2012

On Tue, 24 Apr 2012 14:32:51 +0200
Joerg Sonnenberger <joerg at britannica.bec.de> wrote:

> The real question is where sys/param.h is pulled in.

[Second reply, better information.]

I was able to build clang trunk as of today with gcc 4.6 by modifying
one gcc header file.   I don't say it's a great solution, but it does
narrow down the problem.  

In ctype_base.h, after 

	#include <sys/param.h>

I added 

	# ifdef NetBSD
	#  undef NetBSD
	# endif
	# ifdef FSCALE
	#  undef FSCALE
	# endif

(I know, the ifdefs aren't needed.)  

For simplicity, I added this guard to Clang's header file:

$ svn diff
Index: include/llvm/ADT/SmallVector.h
--- include/llvm/ADT/SmallVector.h      (revision 155441)
+++ include/llvm/ADT/SmallVector.h      (working copy)
@@ -23,6 +23,12 @@
 #include <iterator>
 #include <memory>
+#ifdef NetBSD
+# if NetBSD == 199905
+#  error "NetBSD has been defined by sys/param.h"
+# endif
 namespace llvm {
And a good thing I did, too, because that error trapped several times
before I managed to define DNU_SYS_PARAMS_H to the preprocessor.  Now I
can build after invoking configure as follows:

#! /bin/sh
OPTIONS=$(grep ^-- ../.build_options)


set -x 
../configure ${OPTIONS}

What to do?  I'm not sure whose "fault" it is.  From where I sit,
nothing should ever expressly search for or reference sys/param.h.
"man hier" says include/sys holds "system C include files (kernel data
structures)". But *both* clang and gcc probe for it and use it.  I
suppose it falls to us NetBSD fans to find out why they do that, and
how better the question being asked could be answered.  

Can anyone on the clang dev team shed any light on this?  I don't want
to muck with configure.ac blindly.  I can make it work on my system,
but it's hard to come up with a good patch without understanding the


More information about the cfe-dev mailing list