Bug 47147 - gcc 4.6 fails to compile on NetBSD
Summary: gcc 4.6 fails to compile on NetBSD
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Jonathan Wakely
URL:
Keywords: build, patch
Depends on:
Blocks: 47045
  Show dependency treegraph
 
Reported: 2011-01-01 17:43 UTC by js-gcc
Modified: 2011-02-02 18:03 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-01-02 22:41:11


Attachments
preprocessed source (3.84 KB, application/octet-stream)
2011-01-12 21:17 UTC, Jonathan Wakely
Details
fix bootstrap on NetBSD by checking for _X86_64_ANSI_H (672 bytes, patch)
2011-01-12 23:47 UTC, Jonathan Wakely
Details | Diff
handle _I386_ANSI_H as well as _X86_64_ANSI_H (748 bytes, patch)
2011-01-13 00:34 UTC, Jonathan Wakely
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description js-gcc 2011-01-01 17:43:38 UTC
/home/js/gcc-build/./prev-gcc/xgcc -B/home/js/gcc-build/./prev-gcc/ -B/usr/local/x86_64-unknown-netbsd5.1./bin/ -B/usr/local/x86_64-unknown-netbsd5.1./bin/ -B/usr/local/x86_64-unknown-netbsd5.1./lib/ -isystem /usr/local/x86_64-unknown-netbsd5.1./include -isystem /usr/local/x86_64-unknown-netbsd5.1./sys-include    -c -DHAVE_CONFIG_H -g -O2 -gtoggle  -I. -I/home/js/gcc-trunk/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  -fpic /home/js/gcc-trunk/libiberty/mempcpy.c -o pic/mempcpy.o; \
else true; fi
/home/js/gcc-trunk/libiberty/mempcpy.c:35:36: error: unknown type name ‘size_t’
/home/js/gcc-trunk/libiberty/mempcpy.c:38:34: error: unknown type name ‘size_t’

Looking at the file, it includes stddef.h, which does define size_t on NetBSD:

webkeks:/tmp$ cat test.c
#include <stddef.h>
size_t foo;
webkeks:/tmp$ gcc -c test.c
webkeks:/tmp$ 

So it seems that uding the build process, different headers are used which are broken.
Comment 1 Jonathan Wakely 2011-01-02 22:41:11 UTC
I can't verify it myself but I've had this reported to me in private too, so am going to confirm it.

Please provide your full configure command, thanks
Comment 2 js-gcc 2011-01-03 16:13:14 UTC
/home/js/gcc-trunk/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --enable-__cxa_atexit --enable-languages=c,c++,objc,obj-c++ --with-mpfr=/usr/local --with-mpc=/usr/local --with-gmp=/usr/local
Comment 3 Ralf Wildenhues 2011-01-06 19:40:57 UTC
Can you attach output of the failing command when '-o <FILE>' is removed and -c is replaced with -E?  And please post the full failing command, the one you posted has '; else true; fi' but no 'if' part.  Thanks.
Comment 4 Jonathan Wakely 2011-01-11 16:52:56 UTC
Still waiting for feedback

I'll investigate this myself (to expedite PR 47045) if there's a public NetBSD machine available in a compile farm somewhere, or if someone is able to give me ssh access to a box
Comment 5 Jonathan Wakely 2011-01-12 21:17:35 UTC
Created attachment 22952 [details]
preprocessed source

configured with 
../gcc-4.6-20110108/configure --prefix=/home/redi/work/sandbox --disable-libgomp --disable-bootstrap --disable-multilib
on netbsd-current

build fails in libstdc++-v3/libsupc++ with these errors:

In file included from ../../../../gcc-4.6-20110108/libstdc++-v3/libsupc++/tinfo.h:31:0,
                 from ../../../../gcc-4.6-20110108/libstdc++-v3/libsupc++/array_type_info.cc:25:
/disk/1/archive/tmp/redi/gcc-4.6-20110108/libstdc++-v3/libsupc++/cxxabi.h:70:17: error: 'size_t' was not declared in this scope
/disk/1/archive/tmp/redi/gcc-4.6-20110108/libstdc++-v3/libsupc++/cxxabi.h:70:17: note: suggested alternative:
/disk/1/archive/tmp/redi/objdir-4.6-20110108/x86_64-unknown-netbsd5.99.43/libstdc++-v3/include/x86_64-unknown-netbsd5.99.43/bits/c++config.h:88:26: note:   'std::size_t'

preprocessed source attached

I'll look into it more later and try a build without --disable-boostrap too ...
Comment 6 Jonathan Wakely 2011-01-12 21:34:13 UTC
./gcc/include/stddef.h is being included, but it doesn't define size_t

<machine/ansi.h> has the header guard _X86_64_ANSI_H_ but it appears that gcc's stddef.h is expecting _MACHINE_ANSI_H_
Comment 7 Jonathan Wakely 2011-01-12 23:47:53 UTC
Created attachment 22953 [details]
fix bootstrap on NetBSD by checking for _X86_64_ANSI_H
Comment 8 Jonathan Wakely 2011-01-13 00:26:15 UTC
the include guard changed here:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/amd64/include/ansi.h.diff?r1=1.6&r2=1.7&only_with_tag=MAIN

by this commit:
http://mail-index.netbsd.org/source-changes/2008/10/26/msg211757.html

Looking at src/sys/arch/i386/include/ansi.h it seems that <machine/ansi.h> has a different include guard for every arch, which is a lot of arch's for NetBSD

e.g. _I386_ANSI_H_ for x86

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/i386/include/ansi.h.diff?r1=1.21&r2=1.22&only_with_tag=MAIN
Comment 9 Jonathan Wakely 2011-01-13 00:28:20 UTC
actually it's not every arch - most still use _ANSI_H_ it's just x86 and x86-64 that are different
Comment 10 Jonathan Wakely 2011-01-13 00:34:37 UTC
Created attachment 22954 [details]
handle _I386_ANSI_H as well as _X86_64_ANSI_H
Comment 11 js-gcc 2011-01-13 13:28:27 UTC
Sorry for the late reply.

Your patch worked fine.
Comment 12 Jonathan Wakely 2011-01-28 09:29:54 UTC
patch posted for review:
http://gcc.gnu.org/ml/gcc-patches/2011-01/msg00881.html
Comment 13 Jonathan Wakely 2011-01-29 22:15:55 UTC
Author: redi
Date: Sat Jan 29 22:15:52 2011
New Revision: 169395

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169395
Log:
2011-01-29  Jonathan Wakely  <jwakely.gcc@gmail.com>

	PR bootstrap/47147
	* ginclude/stddef.h: Check for _X86_64_ANSI_H_ and _I386_ANSI_H_ as
	used by NetBSD.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ginclude/stddef.h
Comment 14 Jonathan Wakely 2011-01-29 22:22:46 UTC
Fixed for 4.6.0, although as noted at http://gcc.gnu.org/ml/gcc/2011-01/msg00433.html there are other architectures (landisk, hpcsh, dreamcast and evbsh3) which don't use _ANSI_H_
Comment 15 Diego Novillo 2011-02-02 18:03:11 UTC
Author: dnovillo
Date: Wed Feb  2 18:03:04 2011
New Revision: 169690

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169690
Log:
2011-01-29  Jonathan Wakely  <jwakely.gcc@gmail.com>

	PR bootstrap/47147
	* ginclude/stddef.h: Check for _X86_64_ANSI_H_ and _I386_ANSI_H_ as
	used by NetBSD.

Modified:
    branches/google/integration/gcc/ChangeLog
    branches/google/integration/gcc/ginclude/stddef.h