Building 176.gcc

Hi folks,

I have been stumped on a compilation problem when I tried to build 176.gcc of SPEC CPU2000 with clang v 2.8 (trunk 427) on Linux and intel. First, I tried to compile with 'clang -std=c89 *.c -o gcc.clang' since the default C standard of Clang is c99 while that of gcc is c89. It reported this error:
./c-gperf.h:14:1: error: unknown type name 'inline'
inline
^
./c-gperf.h:16:1: error: expected identifier or '('
static unsigned int
...

This is the part of the source code:
#ifdef __GNUC__
inline
#endif
static unsigned int
hash (str, len)
...
Definitely, the error existed because clang has different support for inline. Then I tried to compile with 'clang *.c -std=c99 -o gcc.clang' because c99 supports inline. It reported this error:
/tmp/cc-tJBugS.o: In function `stat':
toplev.c:(.text+0x0): multiple definition of `stat'
/tmp/cc-aQKHyN.o:getpwd.c:(.text+0x0): first defined here
/tmp/cc-tJBugS.o: In function `fstat':
toplev.c:(.text+0x30): multiple definition of `fstat'
/tmp/cc-aQKHyN.o:getpwd.c:(.text+0x30): first defined here
/tmp/cc-GZ5yz3.o: In function `init_lex':
c-lex.c:(.text+0x417): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x463): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x4a1): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x4df): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x51d): undefined reference to `is_reserved_word'

function stat and fstat are included from header files <sys/stat.h>. I suppose this has something to do with the c89 C preprocessor standard.

Also, I looked at the configuration files of SPEC CPU2000. There is no special command line options for building 176.gcc. The base tune command line is this: 'gcc -c -O3 -fomit-frame-pointer *.c'. Is there any way to walk around this without changing the source code of 176.gcc? I do not intend to do change it since it is standard benchmark program. Definitely, someone has built SPEC CPU2000 with clang successfully before. Does anyone have any suggestion?

Thanks a lot!
Bin

Hi folks,

I have been stumped on a compilation problem when I tried to build
176.gcc of SPEC CPU2000 with clang v 2.8 (trunk 427) on Linux and intel.
First, I tried to compile with 'clang -std=c89 *.c -o gcc.clang' since
the default C standard of Clang is c99 while that of gcc is c89. It
reported this error:
./c-gperf.h:14:1: error: unknown type name 'inline'
inline
^
./c-gperf.h:16:1: error: expected identifier or '('
static unsigned int
...

This is the part of the source code:
#ifdef __GNUC__
inline
#endif
static unsigned int
hash (str, len)
...
Definitely, the error existed because clang has different support for
inline. Then I tried to compile with 'clang *.c -std=c99 -o gcc.clang'
because c99 supports inline. It reported this error:
/tmp/cc-tJBugS.o: In function `stat':
toplev.c:(.text+0x0): multiple definition of `stat'
/tmp/cc-aQKHyN.o:getpwd.c:(.text+0x0): first defined here
/tmp/cc-tJBugS.o: In function `fstat':
toplev.c:(.text+0x30): multiple definition of `fstat'
/tmp/cc-aQKHyN.o:getpwd.c:(.text+0x30): first defined here
/tmp/cc-GZ5yz3.o: In function `init_lex':
c-lex.c:(.text+0x417): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x463): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x4a1): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x4df): undefined reference to `is_reserved_word'
c-lex.c:(.text+0x51d): undefined reference to `is_reserved_word'

Try -std=gnu89 instead of -std=c89. "inline" in C89 is a GNU extension, and -std=c89 runs with gnu extensions disabled but __GNUC__ is still defined.

Nick

SPECCPU2000 include a lot of GCC specific & non-standard code, fortunately
it is easy to
specify CPORTABILITY flags for individual tests in a config file.

For latest clang I had to use:

252.eon: -fpermissive
300.twolf: -std=gnu89 -Wreturn-type

Evzen