[cfe-dev] netbsd & gcc 4.6 triple

James K. Lowden jklowden at schemamania.org
Tue Apr 24 07:12:30 PDT 2012


On Tue, 24 Apr 2012 14:32:51 +0200
Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> On Mon, Apr 23, 2012 at 10:30:24PM -0400, James K. Lowden wrote:
> > I am building Clang 3.0.99 with gcc 4.6.  The message below suggests
> > Triple.cpp is confused.  The enumerated type "NetBSD" should be
> > defined in the enum in Triple.h on line 93.  The message says that
> > its value is 199905, which appears to come from the preprocessor.
> 
> The real question is where sys/param.h is pulled in.

I'm always delighted to answer real questions!  It's being checked in
configure.ac, probably because it's used in some header files, see
below.  

But why?  If someone could answer that, perhaps we can craft portable
conditional compilation.  :-)  

AFAIK sys/param.h is non-standard.  opengroup.org mentions it only once
that I see, calling it "traditional":
http://pubs.opengroup.org/onlinepubs/009604599/basedefs/sys/stat.h.html.  

clang finds two unwanted preprocessor definitions
in /usr/include/sys/param.h, both defined unconditionally: 

	NetBSD
	FSCALE

$ grep -nE '(#define.NetBSD)|FSCALE' /usr/include/sys/param.h 
83:#define      NetBSD  199905          /* NetBSD version (year &
month). */ 
373:#define     FSCALE  (1<<FSHIFT)

Out of sheer orneriness I got it to compile.  I sprinkled #undef in
about 6 files, some generated.  

Autoconf references:

$ grep sys/param.h *conf* autoconf/*
config.log:| #include <sys/param.h>
config.log:configure:15117: checking sys/param.h usability
config.log:configure:15175: checking sys/param.h presence
config.log:configure:15250: checking for sys/param.h
configure:  # See if sys/param.h defines the BYTE_ORDER macro.
configure:#include <sys/param.h>
configure:#include <sys/param.h>
configure:for ac_header in sys/mman.h sys/param.h sys/resource.h
sys/time.h sys/uio.h configure:/* Assume that all systems that can run
configure have sys/param.h.  */ configure:#   include <sys/param.h>
configure.lineno:  # See if sys/param.h defines the BYTE_ORDER macro.
configure.lineno:#include <sys/param.h>
configure.lineno:#include <sys/param.h>
configure.lineno:for ac_header in sys/mman.h sys/param.h sys/resource.h
sys/time.h sys/uio.h configure.lineno:/* Assume that all systems that
can run configure have sys/param.h.  */ configure.lineno:#   include
<sys/param.h> autoconf/config.guess:#include <sys/param.h>
autoconf/config.guess:#  include <sys/param.h>
autoconf/configure.ac:AC_CHECK_HEADERS([sys/mman.h sys/param.h
sys/resource.h sys/time.h sys/uio.h])

References in header files:

$ find work/ -name *.h -exec grep  sys/param.h {} + \
	| grep -E '#[[:space:]]*include' 
work/llvm/lib/Support/Unix/Unix.h:#include <sys/param.h>
work/.buildlink/gcc46/include/c+
+/x86_64-unknown-netbsd5.0.2/bits/ctype_base.h:#include <sys/param.h>
work/.buildlink/gcc46/lib/gcc/x86_64-unknown-netbsd5.0.2/4.6.3/plugin/include/system.h:#
include <sys/param.h>

--jkl



More information about the cfe-dev mailing list