clang unable to build example C file

Hi,

I tried to compile a simple program with clang, but it failed.
I am using clang r42834, and llvm r42834.
I also tried clang r42834 with llvm 2.1 but build failed because of
some prototype mismatch.

Which version of clang should I usem and what version of llvm does it
compile with?

$ cat t.c
int main() { return 0; }

$ clang t.c

<predefines>:1:2: error: invalid preprocessing directive
#define __STDC__ 1
^
<predefines>:2:2: error: invalid preprocessing directive
#define __STDC_VERSION__ 199901L
^
<predefines>:3:2: error: invalid preprocessing directive
#define __STDC_HOSTED__ 1
......
<predefines>:86:2: error: invalid preprocessing directive
#define __PIC__ 1
^
85 diagnostics generated.

Also the preprocessor acts strange (it gives same errors as above)
$ clang t.c -E 2>/dev/null
# 1 "t.c" 1
# 0 "t.c"
# 1 "<predefines>" 1

def iltin_va_list;
# 1 "t.c" 2
() { rn 0; }

Is that text truncation due to the errors above, or signs of miscompilation?

Some more info:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr
--disable-werror --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.1 (Debian 4.2.1-5)

$ /lib/libc.so.6
GNU C Library stable release version 2.6.1, by Roland McGrath et al.
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.2.1 (Debian 4.2.1-5).
Compiled on a Linux >>2.6.17-2-vserver-amd64<< system on 2007-09-17.
Available extensions:
        crypt add-on version 2.1 by Michael Glad and others
        GNU Libidn by Simon Josefsson
        Native POSIX Threads Library by Ulrich Drepper et al
        BIND-8.2.3-T5B
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html&gt;\.

$ ld -v
GNU ld (GNU Binutils for Debian) 2.18

Thanks,
Edwin

I can’t repro this on my machine (running TOT).

snaroff

Hi,

I tried to compile a simple program with clang, but it failed.
I am using clang r42834, and llvm r42834.
I also tried clang r42834 with llvm 2.1 but build failed because of
some prototype mismatch.

Which version of clang should I usem and what version of llvm does it
compile with?

This certainly should work, and does for me :). I bet that if you revert clang back to r42817 that it will work for you.

Do you have valgrind available on your machine? If so, I'd be curious to find out if it reports any problems. The other possibility is that it may be a miscompilation by gcc 4.2.1. Can you please run 'make check' in the main llvm/test directory and see if you have problems there?

-Chris

This certainly should work, and does for me :).

Did I say that I have x86-64 arch? Is clang supported on it?
Or should I retry in a 32-bit chroot?
[that is going to take a while, so I'll only be able to report on this
tomorrow.]

I bet that if you
revert clang back to r42817 that it will work for you.

Trying...
No, that doesn't work either. Same valgrind warnings too.
Should I revert llvm to r42817 too?

Do you have valgrind available on your machine?

Sure thing, I use it for code I develop all the time. Lets see:
ERROR SUMMARY: 595 errors from 14 contexts (suppressed: 8 from 2)

==21571== Memcheck, a memory error detector.
==21571== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==21571== Using LibVEX rev 1732, a library for dynamic binary translation.
==21571== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==21571== Using valgrind-3.2.3-Debian, a dynamic binary
instrumentation framework.
==21571== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==21571== For more details, rerun with: -v
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AEE5: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4E44A7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==21571== by 0x49F8E7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AEEB: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4E44A7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==21571== by 0x49F8E7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AF65: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4E44A7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==21571== by 0x49F8E7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AF6B: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4E44A7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==21571== by 0x49F8E7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51B025: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4E44A7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==21571== by 0x49F8E7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51B02B: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4E44A7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==21571== by 0x49F8E7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51B086: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4E44A7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==21571== by 0x49F8E7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
<predefines>:1:2: error: invalid preprocessing directive
#define __STDC__ 1
^
<predefines>:2:2: error: invalid preprocessing directive
#define __STDC_VERSION__ 199901L
^
<predefines>:3:2: error: invalid preprocessing directive
#define __STDC_HOSTED__ 1
^
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AEE5: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4EA23D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==21571== by 0x4ED3B8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==21571== by 0x4E7A3E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==21571== by 0x4E7D2C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==21571== by 0x49F940: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AEEB: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4EA23D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==21571== by 0x4ED3B8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==21571== by 0x4E7A3E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==21571== by 0x4E7D2C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==21571== by 0x49F940: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AF65: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4EA23D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==21571== by 0x4ED3B8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==21571== by 0x4E7A3E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==21571== by 0x4E7D2C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==21571== by 0x49F940: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51AF6B: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4EA23D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==21571== by 0x4ED3B8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==21571== by 0x4E7A3E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==21571== by 0x4E7D2C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==21571== by 0x49F940: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51B025: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4EA23D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==21571== by 0x4ED3B8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==21571== by 0x4E7A3E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==21571== by 0x4E7D2C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==21571== by 0x49F940: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51B02B: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4EA23D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==21571== by 0x4ED3B8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==21571== by 0x4E7A3E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==21571== by 0x4E7D2C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==21571== by 0x49F940: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
==21571==
==21571== Conditional jump or move depends on uninitialised value(s)
==21571== at 0x51B086: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==21571== by 0x5149E4:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x5038FD:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==21571== by 0x4EA23D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==21571== by 0x4ED3B8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==21571== by 0x4E7A3E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==21571== by 0x4E7D2C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==21571== by 0x49F940: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==21571== by 0x47A5A3: main (in /usr/local/bin/clang)
<predefines>:5:2: error: invalid preprocessing directive
#define __APPLE__ 1
^
<predefines>:6:2: error: invalid preprocessing directive
#define __MACH__ 1
^
<predefines>:7:2: error: invalid preprocessing directive
#define __weak
^
<predefines>:8:2: error: invalid preprocessing directive
#define __strong
^
<predefines>:9:2: error: invalid preprocessing directive
#define __CONSTANT_CFSTRINGS__ 1
^
<predefines>:10:2: error: invalid preprocessing directive
#define __i386__ 1
^
<predefines>:11:2: error: invalid preprocessing directive
#define __i386 1
^
<predefines>:12:2: error: invalid preprocessing directive
#define i386 1
^
<predefines>:13:2: error: invalid preprocessing directive
#define __LITTLE_ENDIAN__ 1
^
<predefines>:14:2: error: invalid preprocessing directive
#define __INTMAX_MAX__ 9223372036854775807LL
^
<predefines>:15:2: error: invalid preprocessing directive
#define __INTMAX_TYPE__ long long int
^
<predefines>:16:2: error: invalid preprocessing directive
#define __LONG_MAX__ 2147483647L
^
<predefines>:17:2: error: invalid preprocessing directive
#define __PTRDIFF_TYPE__ int
^
<predefines>:18:2: error: invalid preprocessing directive
#define __UINTMAX_TYPE__ long long unsigned int
^
<predefines>:19:2: error: invalid preprocessing directive
#define __CHAR_BIT__ 8
^
<predefines>:20:2: error: invalid preprocessing directive
#define __INT_MAX__ 2147483647
^
<predefines>:21:2: error: invalid preprocessing directive
#define __LONG_LONG_MAX__ 9223372036854775807LL
^
<predefines>:22:2: error: invalid preprocessing directive
#define __SCHAR_MAX__ 127
^
<predefines>:23:2: error: invalid preprocessing directive
#define __SHRT_MAX__ 32767
^
<predefines>:24:2: error: invalid preprocessing directive
#define __SIZE_TYPE__ long unsigned int
^
<predefines>:25:2: error: invalid preprocessing directive
#define __nocona 1
^
<predefines>:26:2: error: invalid preprocessing directive
#define __nocona__ 1
^
<predefines>:27:2: error: invalid preprocessing directive
#define __tune_nocona__ 1
^
<predefines>:28:2: error: invalid preprocessing directive
#define __SSE2_MATH__ 1
^
<predefines>:29:2: error: invalid preprocessing directive
#define __SSE2__ 1
^
<predefines>:30:2: error: invalid preprocessing directive
#define __SSE_MATH__ 1
^
<predefines>:31:2: error: invalid preprocessing directive
#define __SSE__ 1
^
<predefines>:32:2: error: invalid preprocessing directive
#define __MMX__ 1
^
<predefines>:33:2: error: invalid preprocessing directive
#define __REGISTER_PREFIX__
^
<predefines>:34:2: error: invalid preprocessing directive
#define __WCHAR_MAX__ 2147483647
^
<predefines>:35:2: error: invalid preprocessing directive
#define __WCHAR_TYPE__ int
^
<predefines>:36:2: error: invalid preprocessing directive
#define __WINT_TYPE__ int
^
<predefines>:37:2: error: invalid preprocessing directive
#define __FLT_DENORM_MIN__ 1.40129846e-45F
^
<predefines>:38:2: error: invalid preprocessing directive
#define __FLT_DIG__ 6
^
<predefines>:39:2: error: invalid preprocessing directive
#define __FLT_EPSILON__ 1.19209290e-7F
^
<predefines>:40:2: error: invalid preprocessing directive
#define __FLT_EVAL_METHOD__ 0
^
<predefines>:41:2: error: invalid preprocessing directive
#define __FLT_HAS_INFINITY__ 1
^
<predefines>:42:2: error: invalid preprocessing directive
#define __FLT_HAS_QUIET_NAN__ 1
^
<predefines>:43:2: error: invalid preprocessing directive
#define __FLT_MANT_DIG__ 24
^
<predefines>:44:2: error: invalid preprocessing directive
#define __FLT_MAX_10_EXP__ 38
^
<predefines>:45:2: error: invalid preprocessing directive
#define __FLT_MAX_EXP__ 128
^
<predefines>:46:2: error: invalid preprocessing directive
#define __FLT_MAX__ 3.40282347e+38F
^
<predefines>:47:2: error: invalid preprocessing directive
#define __FLT_MIN_10_EXP__ (-37)
^
<predefines>:48:2: error: invalid preprocessing directive
#define __FLT_MIN_EXP__ (-125)
^
<predefines>:49:2: error: invalid preprocessing directive
#define __FLT_MIN__ 1.17549435e-38F
^
<predefines>:50:2: error: invalid preprocessing directive
#define __FLT_RADIX__ 2
^
<predefines>:51:2: error: invalid preprocessing directive
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
^
<predefines>:52:2: error: invalid preprocessing directive
#define __DBL_DIG__ 15
^
<predefines>:53:2: error: invalid preprocessing directive
#define __DBL_EPSILON__ 2.2204460492503131e-16
^
<predefines>:54:2: error: invalid preprocessing directive
#define __DBL_HAS_INFINITY__ 1
^
<predefines>:55:2: error: invalid preprocessing directive
#define __DBL_HAS_QUIET_NAN__ 1
^
<predefines>:56:2: error: invalid preprocessing directive
#define __DBL_MANT_DIG__ 53
^
<predefines>:57:2: error: invalid preprocessing directive
#define __DBL_MAX_10_EXP__ 308
^
<predefines>:58:2: error: invalid preprocessing directive
#define __DBL_MAX_EXP__ 1024
^
<predefines>:59:2: error: invalid preprocessing directive
#define __DBL_MAX__ 1.7976931348623157e+308
^
<predefines>:60:2: error: invalid preprocessing directive
#define __DBL_MIN_10_EXP__ (-307)
^
<predefines>:61:2: error: invalid preprocessing directive
#define __DBL_MIN_EXP__ (-1021)
^
<predefines>:62:2: error: invalid preprocessing directive
#define __DBL_MIN__ 2.2250738585072014e-308
^
<predefines>:63:2: error: invalid preprocessing directive
#define __DECIMAL_DIG__ 21
^
<predefines>:64:2: error: invalid preprocessing directive
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
^
<predefines>:65:2: error: invalid preprocessing directive
#define __LDBL_DIG__ 18
^
<predefines>:66:2: error: invalid preprocessing directive
#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
^
<predefines>:67:2: error: invalid preprocessing directive
#define __LDBL_HAS_INFINITY__ 1
^
<predefines>:68:2: error: invalid preprocessing directive
#define __LDBL_HAS_QUIET_NAN__ 1
^
<predefines>:69:2: error: invalid preprocessing directive
#define __LDBL_MANT_DIG__ 64
^
<predefines>:70:2: error: invalid preprocessing directive
#define __LDBL_MAX_10_EXP__ 4932
^
<predefines>:71:2: error: invalid preprocessing directive
#define __LDBL_MAX_EXP__ 16384
^
<predefines>:72:2: error: invalid preprocessing directive
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
^
<predefines>:73:2: error: invalid preprocessing directive
#define __LDBL_MIN_10_EXP__ (-4931)
^
<predefines>:74:2: error: invalid preprocessing directive
#define __LDBL_MIN_EXP__ (-16381)
^
<predefines>:75:2: error: invalid preprocessing directive
#define __LDBL_MIN__ 3.36210314311209350626e-4932L
^
<predefines>:76:2: error: invalid preprocessing directive
#define __APPLE_CC__ 5250
^
<predefines>:77:2: error: invalid preprocessing directive
#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 1030
^
<predefines>:78:2: error: invalid preprocessing directive
#define __GNUC_MINOR__ 0
^
<predefines>:79:2: error: invalid preprocessing directive
#define __GNUC_PATCHLEVEL__ 1
^
<predefines>:80:2: error: invalid preprocessing directive
#define __GNUC__ 4
^
<predefines>:81:2: error: invalid preprocessing directive
#define __GXX_ABI_VERSION 1002
^
<predefines>:82:2: error: invalid preprocessing directive
#define __VERSION__ "4.0.1 (Apple Computer, Inc. build 5250)"
^
<predefines>:83:2: error: invalid preprocessing directive
#define __DYNAMIC__ 1
^
<predefines>:84:2: error: invalid preprocessing directive
#define __FINITE_MATH_ONLY__ 0
^
<predefines>:85:2: error: invalid preprocessing directive
#define __NO_INLINE__ 1
^
<predefines>:86:2: error: invalid preprocessing directive
#define __PIC__ 1
^
85 diagnostics generated.
==21571==
==21571== ERROR SUMMARY: 595 errors from 14 contexts (suppressed: 8 from 2)
==21571== malloc/free: in use at exit: 1,616 bytes in 27 blocks.
==21571== malloc/free: 727 allocs, 700 frees, 217,954 bytes allocated.
==21571== For counts of detected errors, rerun with: -v
==21571== searching for pointers to 27 not-freed blocks.
==21571== checked 229,152 bytes.
==21571==
==21571== LEAK SUMMARY:
==21571== definitely lost: 480 bytes in 7 blocks.
==21571== possibly lost: 0 bytes in 0 blocks.
==21571== still reachable: 1,136 bytes in 20 blocks.
==21571== suppressed: 0 bytes in 0 blocks.
==21571== Rerun with --leak-check=full to see details of leaked memory.

If so, I'd be
curious to find out if it reports any problems.

See above.

The other
possibility is that it may be a miscompilation by gcc 4.2.1. Can you
please run 'make check' in the main llvm/test directory and see if
you have problems there?

Yes.
FAIL: /home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/analysis.ml
Failed with exit(2) at line 1
while running: /usr/bin/ocamlc -cc g++ -I
/home/edwin/llvm-svn/llvm/Release/lib/ocaml llvm.cma llvm_analysis.cma
/home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/analysis.ml -o
analysis.ml.tmp
File "/home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/analysis.ml", line
39, characters 12-54:
Warning X: this statement never returns (or has an unsound type.)
/tmp/camlprim81a59e.c:839: warning: deprecated conversion from string
constant to 'char*'
<... repeated lots of times, till I run out of space on /tmp ... >

Does that work for you?

--Edwin

This certainly should work, and does for me :).

Did I say that I have x86-64 arch? Is clang supported on it?
Or should I retry in a 32-bit chroot?
[that is going to take a while, so I'll only be able to report on this
tomorrow.]

llvm fully supports x86-64 and clang should to.

I bet that if you
revert clang back to r42817 that it will work for you.

Trying...
No, that doesn't work either. Same valgrind warnings too.
Should I revert llvm to r42817 too?

I just committed a patch that should fix the valgrind errors below, please try it out. If there are still valgrind warnings, please let me know, thanks!

-Chris

The other
possibility is that it may be a miscompilation by gcc 4.2.1. Can you
please run 'make check' in the main llvm/test directory and see if
you have problems there?

Yes.
FAIL: /home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/analysis.ml
Failed with exit(2) at line 1
while running: /usr/bin/ocamlc -cc g++ -I
/home/edwin/llvm-svn/llvm/Release/lib/ocaml llvm.cma llvm_analysis.cma
/home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/analysis.ml -o
analysis.ml.tmp
File "/home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/analysis.ml", line
39, characters 12-54:
Warning X: this statement never returns (or has an unsound type.)
/tmp/camlprim81a59e.c:839: warning: deprecated conversion from string
constant to 'char*'
<... repeated lots of times, till I run out of space on /tmp ... >

Does that work for you?

I don't have ocaml installed, please notify llvmdev mailing list,

Thanks for the help!

-Chris

llvm fully supports x86-64 and clang should to.

Ok.

>> I bet that if you
>> revert clang back to r42817 that it will work for you.
>
> Trying...
> No, that doesn't work either. Same valgrind warnings too.
> Should I revert llvm to r42817 too?

I just committed a patch that should fix the valgrind errors below,
please try it out. If there are still valgrind warnings, please let
me know, thanks!

It still does:

==16236== Memcheck, a memory error detector.
==16236== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==16236== Using LibVEX rev 1732, a library for dynamic binary translation.
==16236== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==16236== Using valgrind-3.2.3-Debian, a dynamic binary
instrumentation framework.
==16236== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==16236== For more details, rerun with: -v
==16236==
==16236== Conditional jump or move depends on uninitialised value(s)
==16236== at 0x51B006: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==16236== by 0x514B24:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==16236== by 0x503A2D:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==16236== by 0x4E45E7: clang::Parser::Initialize() (in /usr/local/bin/clang)
==16236== by 0x49F9D7: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==16236== by 0x47A693: main (in /usr/local/bin/clang)
<predefines>:1:2: error: invalid preprocessing directive
#define __STDC__ 1
^
<predefines>:2:2: error: invalid preprocessing directive
#define __STDC_VERSION__ 199901L
^
<predefines>:3:2: error: invalid preprocessing directive
#define __STDC_HOSTED__ 1
^
==16236==
==16236== Conditional jump or move depends on uninitialised value(s)
==16236== at 0x51B006: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==16236== by 0x514B24:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==16236== by 0x503A2D:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)
==16236== by 0x4EA37D:
clang::Parser::ParseInitDeclaratorListAfterFirstDeclarator(clang::Declarator&)
(in /usr/local/bin/clang)
==16236== by 0x4ED4F8:
clang::Parser::ParseSimpleDeclaration(unsigned) (in
/usr/local/bin/clang)
==16236== by 0x4E7B7E: clang::Parser::ParseExternalDeclaration()
(in /usr/local/bin/clang)
==16236== by 0x4E7E6C: clang::Parser::ParseTopLevelDecl(void*&) (in
/usr/local/bin/clang)
==16236== by 0x49FA30: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (in /usr/local/bin/clang)
==16236== by 0x47A693: main (in /usr/local/bin/clang)
<predefines>:5:2: error: invalid preprocessing directive
#define __APPLE__ 1
^
<predefines>:6:2: error: invalid preprocessing directive
#define __MACH__ 1
^
<predefines>:7:2: error: invalid preprocessing directive
#define __weak
^
<predefines>:8:2: error: invalid preprocessing directive
#define __strong
^
<predefines>:9:2: error: invalid preprocessing directive
#define __CONSTANT_CFSTRINGS__ 1
^
<predefines>:10:2: error: invalid preprocessing directive
#define __i386__ 1
^
<predefines>:11:2: error: invalid preprocessing directive
#define __i386 1
^
<predefines>:12:2: error: invalid preprocessing directive
#define i386 1
^
<predefines>:13:2: error: invalid preprocessing directive
#define __LITTLE_ENDIAN__ 1
^
<predefines>:14:2: error: invalid preprocessing directive
#define __INTMAX_MAX__ 9223372036854775807LL
^
<predefines>:15:2: error: invalid preprocessing directive
#define __INTMAX_TYPE__ long long int
^
<predefines>:16:2: error: invalid preprocessing directive
#define __LONG_MAX__ 2147483647L
^
<predefines>:17:2: error: invalid preprocessing directive
#define __PTRDIFF_TYPE__ int
^
<predefines>:18:2: error: invalid preprocessing directive
#define __UINTMAX_TYPE__ long long unsigned int
^
<predefines>:19:2: error: invalid preprocessing directive
#define __CHAR_BIT__ 8
^
<predefines>:20:2: error: invalid preprocessing directive
#define __INT_MAX__ 2147483647
^
<predefines>:21:2: error: invalid preprocessing directive
#define __LONG_LONG_MAX__ 9223372036854775807LL
^
<predefines>:22:2: error: invalid preprocessing directive
#define __SCHAR_MAX__ 127
^
<predefines>:23:2: error: invalid preprocessing directive
#define __SHRT_MAX__ 32767
^
<predefines>:24:2: error: invalid preprocessing directive
#define __SIZE_TYPE__ long unsigned int
^
<predefines>:25:2: error: invalid preprocessing directive
#define __nocona 1
^
<predefines>:26:2: error: invalid preprocessing directive
#define __nocona__ 1
^
<predefines>:27:2: error: invalid preprocessing directive
#define __tune_nocona__ 1
^
<predefines>:28:2: error: invalid preprocessing directive
#define __SSE2_MATH__ 1
^
<predefines>:29:2: error: invalid preprocessing directive
#define __SSE2__ 1
^
<predefines>:30:2: error: invalid preprocessing directive
#define __SSE_MATH__ 1
^
<predefines>:31:2: error: invalid preprocessing directive
#define __SSE__ 1
^
<predefines>:32:2: error: invalid preprocessing directive
#define __MMX__ 1
^
<predefines>:33:2: error: invalid preprocessing directive
#define __REGISTER_PREFIX__
^
<predefines>:34:2: error: invalid preprocessing directive
#define __WCHAR_MAX__ 2147483647
^
<predefines>:35:2: error: invalid preprocessing directive
#define __WCHAR_TYPE__ int
^
<predefines>:36:2: error: invalid preprocessing directive
#define __WINT_TYPE__ int
^
<predefines>:37:2: error: invalid preprocessing directive
#define __FLT_DENORM_MIN__ 1.40129846e-45F
^
<predefines>:38:2: error: invalid preprocessing directive
#define __FLT_DIG__ 6
^
<predefines>:39:2: error: invalid preprocessing directive
#define __FLT_EPSILON__ 1.19209290e-7F
^
<predefines>:40:2: error: invalid preprocessing directive
#define __FLT_EVAL_METHOD__ 0
^
<predefines>:41:2: error: invalid preprocessing directive
#define __FLT_HAS_INFINITY__ 1
^
<predefines>:42:2: error: invalid preprocessing directive
#define __FLT_HAS_QUIET_NAN__ 1
^
<predefines>:43:2: error: invalid preprocessing directive
#define __FLT_MANT_DIG__ 24
^
<predefines>:44:2: error: invalid preprocessing directive
#define __FLT_MAX_10_EXP__ 38
^
<predefines>:45:2: error: invalid preprocessing directive
#define __FLT_MAX_EXP__ 128
^
<predefines>:46:2: error: invalid preprocessing directive
#define __FLT_MAX__ 3.40282347e+38F
^
<predefines>:47:2: error: invalid preprocessing directive
#define __FLT_MIN_10_EXP__ (-37)
^
<predefines>:48:2: error: invalid preprocessing directive
#define __FLT_MIN_EXP__ (-125)
^
<predefines>:49:2: error: invalid preprocessing directive
#define __FLT_MIN__ 1.17549435e-38F
^
<predefines>:50:2: error: invalid preprocessing directive
#define __FLT_RADIX__ 2
^
<predefines>:51:2: error: invalid preprocessing directive
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
^
<predefines>:52:2: error: invalid preprocessing directive
#define __DBL_DIG__ 15
^
<predefines>:53:2: error: invalid preprocessing directive
#define __DBL_EPSILON__ 2.2204460492503131e-16
^
<predefines>:54:2: error: invalid preprocessing directive
#define __DBL_HAS_INFINITY__ 1
^
<predefines>:55:2: error: invalid preprocessing directive
#define __DBL_HAS_QUIET_NAN__ 1
^
<predefines>:56:2: error: invalid preprocessing directive
#define __DBL_MANT_DIG__ 53
^
<predefines>:57:2: error: invalid preprocessing directive
#define __DBL_MAX_10_EXP__ 308
^
<predefines>:58:2: error: invalid preprocessing directive
#define __DBL_MAX_EXP__ 1024
^
<predefines>:59:2: error: invalid preprocessing directive
#define __DBL_MAX__ 1.7976931348623157e+308
^
<predefines>:60:2: error: invalid preprocessing directive
#define __DBL_MIN_10_EXP__ (-307)
^
<predefines>:61:2: error: invalid preprocessing directive
#define __DBL_MIN_EXP__ (-1021)
^
<predefines>:62:2: error: invalid preprocessing directive
#define __DBL_MIN__ 2.2250738585072014e-308
^
<predefines>:63:2: error: invalid preprocessing directive
#define __DECIMAL_DIG__ 21
^
<predefines>:64:2: error: invalid preprocessing directive
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
^
<predefines>:65:2: error: invalid preprocessing directive
#define __LDBL_DIG__ 18
^
<predefines>:66:2: error: invalid preprocessing directive
#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
^
<predefines>:67:2: error: invalid preprocessing directive
#define __LDBL_HAS_INFINITY__ 1
^
<predefines>:68:2: error: invalid preprocessing directive
#define __LDBL_HAS_QUIET_NAN__ 1
^
<predefines>:69:2: error: invalid preprocessing directive
#define __LDBL_MANT_DIG__ 64
^
<predefines>:70:2: error: invalid preprocessing directive
#define __LDBL_MAX_10_EXP__ 4932
^
<predefines>:71:2: error: invalid preprocessing directive
#define __LDBL_MAX_EXP__ 16384
^
<predefines>:72:2: error: invalid preprocessing directive
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
^
<predefines>:73:2: error: invalid preprocessing directive
#define __LDBL_MIN_10_EXP__ (-4931)
^
<predefines>:74:2: error: invalid preprocessing directive
#define __LDBL_MIN_EXP__ (-16381)
^
<predefines>:75:2: error: invalid preprocessing directive
#define __LDBL_MIN__ 3.36210314311209350626e-4932L
^
<predefines>:76:2: error: invalid preprocessing directive
#define __APPLE_CC__ 5250
^
<predefines>:77:2: error: invalid preprocessing directive
#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 1030
^
<predefines>:78:2: error: invalid preprocessing directive
#define __GNUC_MINOR__ 0
^
<predefines>:79:2: error: invalid preprocessing directive
#define __GNUC_PATCHLEVEL__ 1
^
<predefines>:80:2: error: invalid preprocessing directive
#define __GNUC__ 4
^
<predefines>:81:2: error: invalid preprocessing directive
#define __GXX_ABI_VERSION 1002
^
<predefines>:82:2: error: invalid preprocessing directive
#define __VERSION__ "4.0.1 (Apple Computer, Inc. build 5250)"
^
<predefines>:83:2: error: invalid preprocessing directive
#define __DYNAMIC__ 1
^
<predefines>:84:2: error: invalid preprocessing directive
#define __FINITE_MATH_ONLY__ 0
^
<predefines>:85:2: error: invalid preprocessing directive
#define __NO_INLINE__ 1
^
<predefines>:86:2: error: invalid preprocessing directive
#define __PIC__ 1
^
85 diagnostics generated.
==16236==
==16236== ERROR SUMMARY: 85 errors from 2 contexts (suppressed: 8 from 2)
==16236== malloc/free: in use at exit: 1,616 bytes in 27 blocks.
==16236== malloc/free: 727 allocs, 700 frees, 217,955 bytes allocated.
==16236== For counts of detected errors, rerun with: -v
==16236== searching for pointers to 27 not-freed blocks.
==16236== checked 229,168 bytes.
==16236==
==16236== LEAK SUMMARY:
==16236== definitely lost: 480 bytes in 7 blocks.
==16236== possibly lost: 0 bytes in 0 blocks.
==16236== still reachable: 1,136 bytes in 20 blocks.
==16236== suppressed: 0 bytes in 0 blocks.
==16236== Rerun with --leak-check=full to see details of leaked memory.

I don't have ocaml installed, please notify llvmdev mailing list,

Will do.

Thanks for the help!

Thanks,
Edwin

Török,

It still does:

Strange. TOT is valgrind clean for me (x86-32/linux, all compiled with
gcc 3.4.6)

==16236== Conditional jump or move depends on uninitialised value(s)
==16236== at 0x51B006: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)

Could you please rebuild in 'Debug' mode?

Török,

> It still does:
Strange. TOT

Please #define TOT

is valgrind clean for me (x86-32/linux, all compiled with
gcc 3.4.6)

gcc 4.2.1 here.

> ==16236== Conditional jump or move depends on uninitialised value(s)
> ==16236== at 0x51B006: clang::IdentifierInfo::getPPKeywordID()
> const (in /usr/local/bin/clang)
Could you please rebuild in 'Debug' mode?

I'll do tomorrow.

--Edwin

Please #define TOT

Ah, sorry. TOT = Top Of Tree.

Trying...
No, that doesn't work either. Same valgrind warnings too.
Should I revert llvm to r42817 too?

I just committed a patch that should fix the valgrind errors below,
please try it out. If there are still valgrind warnings, please let
me know, thanks!

It still does:

==16236== Memcheck, a memory error detector.
==16236== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==16236== Using LibVEX rev 1732, a library for dynamic binary translation.
==16236== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==16236== Using valgrind-3.2.3-Debian, a dynamic binary
instrumentation framework.
==16236== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==16236== For more details, rerun with: -v
==16236==
==16236== Conditional jump or move depends on uninitialised value(s)
==16236== at 0x51B006: clang::IdentifierInfo::getPPKeywordID()
const (in /usr/local/bin/clang)
==16236== by 0x514B24:
clang::Preprocessor::HandleDirective(clang::Token&) (in
/usr/local/bin/clang)
==16236== by 0x503A2D:
clang::Lexer::LexTokenInternal(clang::Token&) (in
/usr/local/bin/clang)

Ok, very strange. As Anton mentioned, please try with a debug build. This should give us line numbers which will make it easier to identify the problem.

-Chris

Hi,

Thank for the quick patch yesterday.

See the results of running valgrind on a debug build of llvm r42868 at
the end of this mail.

==25125== Conditional jump or move depends on uninitialised value(s)
==25125== at 0x687876: clang::IdentifierInfo::getPPKeywordID()
const (IdentifierTable.cpp:160)

I added a printf("%lu\n",Len); before "if (Len < 2) return
tok::pp_not_keyword;"

$ clang t.c 2>/dev/null| sort |uniq -c
     85 0

I get all zeros, which is not what I expected.
Where is Len set? I could try to add some printfs there...

My test/site.exp has this:
set ocamlc "/usr/bin/ocamlc -cc g++ -I /home/edwin/llvm-svn/llvm/Debug/lib/ocaml
"
## All variables above are generated by configure. Do Not Edit #

$ valgrind clang t.c

==25125== Memcheck, a memory error detector.
==25125== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==25125== Using LibVEX rev 1732, a library for dynamic binary translation.
==25125== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==25125== Using valgrind-3.2.3-Debian, a dynamic binary
instrumentation framework.
==25125== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==25125== For more details, rerun with: -v
==25125==
==25125== Conditional jump or move depends on uninitialised value(s)
==25125== at 0x687876: clang::IdentifierInfo::getPPKeywordID()
const (IdentifierTable.cpp:160)
==25125== by 0x67E0F4:
clang::Preprocessor::HandleDirective(clang::Token&)
(Preprocessor.cpp:1624)
==25125== by 0x66D952:
clang::Lexer::LexTokenInternal(clang::Token&) (Lexer.cpp:1528)
==25125== by 0x5BAD65: clang::Lexer::Lex(clang::Token&) (Lexer.h:131)
==25125== by 0x5BAD9B: clang::Preprocessor::Lex(clang::Token&)
(Preprocessor.h:245)
==25125== by 0x653DD3: clang::Parser::ConsumeToken() (Parser.h:118)
==25125== by 0x65272B: clang::Parser::Initialize() (Parser.cpp:226)
==25125== by 0x600F98: (anonymous
namespace)::ASTStreamer::ASTStreamer(clang::Preprocessor&,
clang::ASTContext&, unsigned) (ASTStreamer.cpp:34)
==25125== by 0x6011C9: clang::ParseAST(clang::Preprocessor&,
unsigned, clang::ASTConsumer&, bool) (ASTStreamer.cpp:103)
==25125== by 0x5C879D: ProcessInputFile(clang::Preprocessor&,
unsigned, std::string const&, clang::SourceManager&,
clang::TextDiagnostics&, clang::HeaderSearch&, clang::LangOptions
const&) (clang.cpp:812)
==25125== by 0x5CA190: main (clang.cpp:908)
<predefines>:1:2: error: invalid preprocessing directive
#define __STDC__ 1
^
<predefines>:2:2: error: invalid preprocessing directive
#define __STDC_VERSION__ 199901L
^
<predefines>:3:2: error: invalid preprocessing directive
#define __STDC_HOSTED__ 1
^
<predefines>:5:2: error: invalid preprocessing directive
#define __APPLE__ 1
^
<predefines>:6:2: error: invalid preprocessing directive
#define __MACH__ 1
^
<predefines>:7:2: error: invalid preprocessing directive
#define __weak
^
<predefines>:8:2: error: invalid preprocessing directive
#define __strong
^
<predefines>:9:2: error: invalid preprocessing directive
#define __CONSTANT_CFSTRINGS__ 1
^
<predefines>:10:2: error: invalid preprocessing directive
#define __i386__ 1
^
<predefines>:11:2: error: invalid preprocessing directive
#define __i386 1
^
<predefines>:12:2: error: invalid preprocessing directive
#define i386 1
^
<predefines>:13:2: error: invalid preprocessing directive
#define __LITTLE_ENDIAN__ 1
^
<predefines>:14:2: error: invalid preprocessing directive
#define __INTMAX_MAX__ 9223372036854775807LL
^
<predefines>:15:2: error: invalid preprocessing directive
#define __INTMAX_TYPE__ long long int
^
<predefines>:16:2: error: invalid preprocessing directive
#define __LONG_MAX__ 2147483647L
^
<predefines>:17:2: error: invalid preprocessing directive
#define __PTRDIFF_TYPE__ int
^
<predefines>:18:2: error: invalid preprocessing directive
#define __UINTMAX_TYPE__ long long unsigned int
^
<predefines>:19:2: error: invalid preprocessing directive
#define __CHAR_BIT__ 8
^
<predefines>:20:2: error: invalid preprocessing directive
#define __INT_MAX__ 2147483647
^
<predefines>:21:2: error: invalid preprocessing directive
#define __LONG_LONG_MAX__ 9223372036854775807LL
^
<predefines>:22:2: error: invalid preprocessing directive
#define __SCHAR_MAX__ 127
^
<predefines>:23:2: error: invalid preprocessing directive
#define __SHRT_MAX__ 32767
^
<predefines>:24:2: error: invalid preprocessing directive
#define __SIZE_TYPE__ long unsigned int
^
<predefines>:25:2: error: invalid preprocessing directive
#define __nocona 1
^
<predefines>:26:2: error: invalid preprocessing directive
#define __nocona__ 1
^
<predefines>:27:2: error: invalid preprocessing directive
#define __tune_nocona__ 1
^
<predefines>:28:2: error: invalid preprocessing directive
#define __SSE2_MATH__ 1
^
<predefines>:29:2: error: invalid preprocessing directive
#define __SSE2__ 1
^
<predefines>:30:2: error: invalid preprocessing directive
#define __SSE_MATH__ 1
^
<predefines>:31:2: error: invalid preprocessing directive
#define __SSE__ 1
^
<predefines>:32:2: error: invalid preprocessing directive
#define __MMX__ 1
^
<predefines>:33:2: error: invalid preprocessing directive
#define __REGISTER_PREFIX__
^
<predefines>:34:2: error: invalid preprocessing directive
#define __WCHAR_MAX__ 2147483647
^
<predefines>:35:2: error: invalid preprocessing directive
#define __WCHAR_TYPE__ int
^
<predefines>:36:2: error: invalid preprocessing directive
#define __WINT_TYPE__ int
^
<predefines>:37:2: error: invalid preprocessing directive
#define __FLT_DENORM_MIN__ 1.40129846e-45F
^
<predefines>:38:2: error: invalid preprocessing directive
#define __FLT_DIG__ 6
^
<predefines>:39:2: error: invalid preprocessing directive
#define __FLT_EPSILON__ 1.19209290e-7F
^
<predefines>:40:2: error: invalid preprocessing directive
#define __FLT_EVAL_METHOD__ 0
^
<predefines>:41:2: error: invalid preprocessing directive
#define __FLT_HAS_INFINITY__ 1
^
<predefines>:42:2: error: invalid preprocessing directive
#define __FLT_HAS_QUIET_NAN__ 1
^
<predefines>:43:2: error: invalid preprocessing directive
#define __FLT_MANT_DIG__ 24
^
<predefines>:44:2: error: invalid preprocessing directive
#define __FLT_MAX_10_EXP__ 38
^
<predefines>:45:2: error: invalid preprocessing directive
#define __FLT_MAX_EXP__ 128
^
<predefines>:46:2: error: invalid preprocessing directive
#define __FLT_MAX__ 3.40282347e+38F
^
<predefines>:47:2: error: invalid preprocessing directive
#define __FLT_MIN_10_EXP__ (-37)
^
<predefines>:48:2: error: invalid preprocessing directive
#define __FLT_MIN_EXP__ (-125)
^
<predefines>:49:2: error: invalid preprocessing directive
#define __FLT_MIN__ 1.17549435e-38F
^
<predefines>:50:2: error: invalid preprocessing directive
#define __FLT_RADIX__ 2
^
<predefines>:51:2: error: invalid preprocessing directive
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
^
<predefines>:52:2: error: invalid preprocessing directive
#define __DBL_DIG__ 15
^
<predefines>:53:2: error: invalid preprocessing directive
#define __DBL_EPSILON__ 2.2204460492503131e-16
^
<predefines>:54:2: error: invalid preprocessing directive
#define __DBL_HAS_INFINITY__ 1
^
<predefines>:55:2: error: invalid preprocessing directive
#define __DBL_HAS_QUIET_NAN__ 1
^
<predefines>:56:2: error: invalid preprocessing directive
#define __DBL_MANT_DIG__ 53
^
<predefines>:57:2: error: invalid preprocessing directive
#define __DBL_MAX_10_EXP__ 308
^
<predefines>:58:2: error: invalid preprocessing directive
#define __DBL_MAX_EXP__ 1024
^
<predefines>:59:2: error: invalid preprocessing directive
#define __DBL_MAX__ 1.7976931348623157e+308
^
<predefines>:60:2: error: invalid preprocessing directive
#define __DBL_MIN_10_EXP__ (-307)
^
<predefines>:61:2: error: invalid preprocessing directive
#define __DBL_MIN_EXP__ (-1021)
^
<predefines>:62:2: error: invalid preprocessing directive
#define __DBL_MIN__ 2.2250738585072014e-308
^
<predefines>:63:2: error: invalid preprocessing directive
#define __DECIMAL_DIG__ 21
^
<predefines>:64:2: error: invalid preprocessing directive
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
^
<predefines>:65:2: error: invalid preprocessing directive
#define __LDBL_DIG__ 18
^
<predefines>:66:2: error: invalid preprocessing directive
#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
^
<predefines>:67:2: error: invalid preprocessing directive
#define __LDBL_HAS_INFINITY__ 1
^
<predefines>:68:2: error: invalid preprocessing directive
#define __LDBL_HAS_QUIET_NAN__ 1
^
<predefines>:69:2: error: invalid preprocessing directive
#define __LDBL_MANT_DIG__ 64
^
<predefines>:70:2: error: invalid preprocessing directive
#define __LDBL_MAX_10_EXP__ 4932
^
<predefines>:71:2: error: invalid preprocessing directive
#define __LDBL_MAX_EXP__ 16384
^
<predefines>:72:2: error: invalid preprocessing directive
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
^
<predefines>:73:2: error: invalid preprocessing directive
#define __LDBL_MIN_10_EXP__ (-4931)
^
<predefines>:74:2: error: invalid preprocessing directive
#define __LDBL_MIN_EXP__ (-16381)
^
<predefines>:75:2: error: invalid preprocessing directive
#define __LDBL_MIN__ 3.36210314311209350626e-4932L
^
<predefines>:76:2: error: invalid preprocessing directive
#define __APPLE_CC__ 5250
^
<predefines>:77:2: error: invalid preprocessing directive
#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 1030
^
<predefines>:78:2: error: invalid preprocessing directive
#define __GNUC_MINOR__ 0
^
<predefines>:79:2: error: invalid preprocessing directive
#define __GNUC_PATCHLEVEL__ 1
^
<predefines>:80:2: error: invalid preprocessing directive
#define __GNUC__ 4
^
<predefines>:81:2: error: invalid preprocessing directive
#define __GXX_ABI_VERSION 1002
^
<predefines>:82:2: error: invalid preprocessing directive
#define __VERSION__ "4.0.1 (Apple Computer, Inc. build 5250)"
^
<predefines>:83:2: error: invalid preprocessing directive
#define __DYNAMIC__ 1
^
<predefines>:84:2: error: invalid preprocessing directive
#define __FINITE_MATH_ONLY__ 0
^
<predefines>:85:2: error: invalid preprocessing directive
#define __NO_INLINE__ 1
^
<predefines>:86:2: error: invalid preprocessing directive
#define __PIC__ 1
^
85 diagnostics generated.
==25125==
==25125== ERROR SUMMARY: 85 errors from 1 contexts (suppressed: 8 from 2)
==25125== malloc/free: in use at exit: 1,616 bytes in 27 blocks.
==25125== malloc/free: 728 allocs, 701 frees, 218,446 bytes allocated.
==25125== For counts of detected errors, rerun with: -v
==25125== searching for pointers to 27 not-freed blocks.
==25125== checked 228,896 bytes.
==25125==
==25125== LEAK SUMMARY:
==25125== definitely lost: 480 bytes in 7 blocks.
==25125== possibly lost: 0 bytes in 0 blocks.
==25125== still reachable: 1,136 bytes in 20 blocks.
==25125== suppressed: 0 bytes in 0 blocks.
==25125== Rerun with --leak-check=full to see details of leaked memory

I also tried a short gdb debug session, and it looks like it doesn't
recognize define as a keyword.
That shouldn't happen, right? Is there some utility method to dump the
identifier table?

Please tell me if I can do anything further to help.

#4 0x000000000066c66b in clang::Lexer::LexIdentifier (this=0xaa3030,
Result=@0x7fff49d128a8, CurPtr=0xaa2547 " __STDC__ 1\n#define
__STDC_VERSION_
_ 199901L\n#define __STDC_HOSTED__ 1\ntypedef int
__builtin_va_list;\n#define __APPLE__ 1\n#define __MACH__ 1\n#define
__weak \n#define __strong \n
#define __CONSTANT_CFSTRI"...) at Lexer.cpp:449
(gdb) print Result
$22 = (clang::Token &) @0x7fff49d128a8: {Loc = {ID = 262145}, Length =
6, IdentInfo = 0x0, Kind = clang::tok::identifier, Flags = 0}
(gdb) down
...
#0 llvm::StringMap<clang::IdentifierInfo,
llvm::BumpPtrAllocator>::GetOrCreateValue (this=0x7fff49d12ea0,
KeyStart=0xaa2541 "define __STDC__ 1\n#d
efine __STDC_VERSION__ 199901L\n#define __STDC_HOSTED__ 1\ntypedef int
__builtin_va_list;\n#define __APPLE__ 1\n#define __MACH__ 1\n#define
__weak
\n#define __strong \n#define __CONSTANT_"..., KeyEnd=0xaa2547 "
__STDC__ 1\n#define __STDC_VERSION__ 199901L\n#define __STDC_HOSTED__
1\ntypedef in
t __builtin_va_list;\n#define __APPLE__ 1\n#define __MACH__ 1\n#define
__weak \n#define __strong \n#define __CONSTANT_CFSTRI"...) at
/home/edwin/ll
vm-svn/llvm/include/llvm/ADT/StringMap.h:273

(gdb) print *Result.IdentInfo
$24 = {TokenID = clang::tok::identifier, BuiltinID = 0, ObjCID =
clang::tok::objc_not_keyword, HasMacro = false, IsExtension = false,
IsPoisoned =
false, IsOtherTargetMacro = false, IsCPPOperatorKeyword = false,
IsNonPortableBuiltin = false, FETokenInfo = 0x0}

--Edwin

It is somewhat convoluted, but len is set when the identifier is lexed. The codepath is through the StringMap<IdentifierInfo>::GetOrCreateValue method, which calls StringMapEntry<IdentifierInfo>::Create, which sets the size on line 155 of llvm/include/llvm/ADT/StringMap.h.

I don't see how there could be a problem here, everything looks reasonable.

-Chris

Ok, it is something wrong with StringMap.h, but the testcases don't catch it.
See patch at end of this mail.

Look:
StringMapEntry on creation is:
(llvm::StringMapEntry<clang::IdentifierInfo> *) 0xaf5490

and IdentifierInfo is at 8 bytes distance:
print &II
$29 = (clang::IdentifierInfo *) 0xaf5498

but sizeof(StringMapEntryBase) is 4.

However offsetof(StringMapEntry, Val) == 8.

See below for a patch that changes -sizeof(StringMapEntryBase) to
offsetof(..), which should be safer, should such a change occur again
in the future, and also offsetof better expresses what the code does
IMHO.
Make check gives same results as before (3 ocaml bindings failure, 1
CodeGen failure).

When I apply this patch clang can successfully compile t.c!!

The CodeGen failure (both w/, and w/o my patch) is this one:
FAIL: /home/edwin/llvm-svn/llvm/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll
Failed with exit(1) at line 1
while running: llvm-as <
/home/edwin/llvm-svn/llvm/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll |
llc -march=x86 -enable-eh | grep {isNullOrNil].eh"} | wc -l | grep 2
child process exited abnormally

Maybe a testsuite for StringMap would be useful?

--Edwin

Index: include/llvm/ADT/StringMap.h

No, others fail too, including one CodeGen test

$ grep FAIL log
FAIL: /home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/analysis.ml
FAIL: /home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/bitwriter.ml
FAIL: /home/edwin/llvm-svn/llvm/test/Bindings/Ocaml/vmcore.ml
FAIL: /home/edwin/llvm-svn/llvm/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll

--Edwin

It is somewhat convoluted, but len is set when the identifier is
lexed. The codepath is through the
StringMap<IdentifierInfo>::GetOrCreateValue method, which calls
StringMapEntry<IdentifierInfo>::Create, which sets the size on line
155 of llvm/include/llvm/ADT/StringMap.h.

I don't see how there could be a problem here, everything looks
reasonable.

Ok, it is something wrong with StringMap.h, but the testcases don't catch it.
See patch at end of this mail.

Ahhh, I see.

When I apply this patch clang can successfully compile t.c!!

Nice! I applied this patch, please verify it also fixes it for you:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071008/054469.html

The CodeGen failure (both w/, and w/o my patch) is this one:
FAIL: /home/edwin/llvm-svn/llvm/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll
Failed with exit(1) at line 1
while running: llvm-as <
/home/edwin/llvm-svn/llvm/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll |
llc -march=x86 -enable-eh | grep {isNullOrNil].eh"} | wc -l | grep 2
child process exited abnormally

This was failing for other people as well, I think the testcase should be fixed on mainline now.

Thanks for the help!

-Chris

Nice! I applied this patch, please verify it also fixes it for you:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-
Mon-20071008/054469.html

Heh, you don't like offsetof, do you?

I got a compile failure with latest SVN (r42920):

In file included from StringMap.cpp:15:
/home/edwin/llvm-svn/llvm/include/llvm/ADT/StringMap.h: In static
member function 'static llvm::StringMapEntry<ValueTy>&
llvm::StringMapEntry<ValueTy>::GetStringMapEntryFromValue(ValueTy&)':
/home/edwin/llvm-svn/llvm/include/llvm/ADT/StringMap.h:175: error:
'intptr_t' was not declared in this scope
make[1]: *** [/home/edwin/llvm-svn/llvm/lib/Support/Debug/StringMap.o] Error 1

> The CodeGen failure (both w/, and w/o my patch) is this one:
> FAIL: /home/edwin/llvm-svn/llvm/test/CodeGen/X86/2007-09-17-
> ObjcFrameEH.ll
> Failed with exit(1) at line 1
> while running: llvm-as <
> /home/edwin/llvm-svn/llvm/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll |
> llc -march=x86 -enable-eh | grep {isNullOrNil].eh"} | wc -l | grep 2
> child process exited abnormally

This was failing for other people as well, I think the testcase
should be fixed on mainline now.

I'll try after I compile llvm.

P.S.: Is the ML the preferred way of reporting issues? Or should I use
bugzilla?
[this was supposed to be a clang issue, which has no bugzilla, so I used the ML]

--Edwin

Nice! I applied this patch, please verify it also fixes it for you:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-
Mon-20071008/054469.html

Heh, you don't like offsetof, do you?

I do, but GCC doesn't. Some versions reject offsetof in a non-pod class. :frowning:

I got a compile failure with latest SVN (r42920):

In file included from StringMap.cpp:15:
/home/edwin/llvm-svn/llvm/include/llvm/ADT/StringMap.h: In static
member function 'static llvm::StringMapEntry<ValueTy>&
llvm::StringMapEntry<ValueTy>::GetStringMapEntryFromValue(ValueTy&)':
/home/edwin/llvm-svn/llvm/include/llvm/ADT/StringMap.h:175: error:
'intptr_t' was not declared in this scope
make[1]: *** [/home/edwin/llvm-svn/llvm/lib/Support/Debug/StringMap.o] Error 1

Ok, try now :slight_smile:

This was failing for other people as well, I think the testcase
should be fixed on mainline now.

I'll try after I compile llvm.

P.S.: Is the ML the preferred way of reporting issues? Or should I use
bugzilla?
[this was supposed to be a clang issue, which has no bugzilla, so I used the ML]

For clang at this point, yes the mainling list is probably best. Thanks! The llvm bugzilla does have clang-related components, but simple bugs like this are best addressed on the list.

-Chris

> Heh, you don't like offsetof, do you?

I do, but GCC doesn't. Some versions reject offsetof in a non-pod
class. :frowning:

I didn't know that, thanks!

> I got a compile failure with latest SVN (r42920):

Ok, try now :slight_smile:

Compiling (looks like it is rebuilding most of llvm, going to take a while).
I'll try make check and then make test in tools/clang when it is finished.

For clang at this point, yes the mainling list is probably best.
Thanks! The llvm bugzilla does have clang-related components, but
simple bugs like this are best addressed on the list.

Ok, I'll keep posting issues to the ML.

Thanks for the help,
--Edwin

clang t.c works.
make check works except for 3 ocaml link failures, the CodeGen failure is gone.
make test in clang fails:

Looks like it can't find stddef.h. It is in
/usr/lib/gcc/x86_64-linux-gnu/4.2.1/include/stddef.h, not
/usr/include. Same for stdarg.h.

Should I give more details on these failures?

$ grep FAIL log
******************** TEST 'CodeGen/mandel.c' FAILED! ********************
******************** TEST 'CodeGen/mandel.c' FAILED! ********************
******************** TEST 'Preprocessor/includeexpand2.c' FAILED!