Cling bugfix request

Because there is no board for Cling i decided to post here.

While installing Cling following this instructions root.cern.ch/drupal/content/clin … structions I’ve found some problems, fortunately easy to fix.

Firstly I will show the problem:

[code]x86_64-pc-linux-gnu-g++ -I/var/tmp/portage/sys-devel/clang-9999/work/llvm/include -I/var/tmp/portage/sys-devel/clang-9999/work/llvm/tools/cling/tools/driver -DNDEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O3 -fomit-frame-pointer -fno-exceptions -fPIC -Woverloaded-virtual -Wcast-qual -fno-rtti -Wl,-O1 -Wl,–as-needed -Wl,-O1 -Wl,–as-needed -Wl,-O1 -Wl,–as-needed -lcurses -Wl,-O1 -Wl,–as-needed -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -O3 -Wl,-R -Wl,‘$ORIGIN/…/lib’ -Wl,-R -Wl,/usr/lib64/llvm -Wl,-export-dynamic -L/var/tmp/portage/sys-devel/clang-9999/work/llvm/Release/lib -L/var/tmp/portage/sys-devel/clang-9999/work/llvm/Release/lib -Wl,–version-script=/var/tmp/portage/sys-devel/clang-9999/work/llvm/autoconf/ExportMap.map -o /var/tmp/portage/sys-devel/clang-9999/work/llvm/Release/bin/cling /var/tmp/portage/sys-devel/clang-9999/work/llvm/tools/cling/tools/driver/Release/cling.o -lclingUserInterface -lclingMetaProcessor -lclingInterpreter -lclingEditLine -lclangFrontend -lclangSerialization -lclangDriver -lclangCodeGen -lclangSema -lclangChecker -lclangAnalysis -lclangRewrite -lclangAST -lclangParse -lclangLex -lclangBasic \

    -lLLVMpic16passes -lLLVMMCDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreAsmPrinter -lLLVMXCoreInfo -lLLVMSystemZCodeGen -lLLVMSystemZAsmPrinter -lLLVMSystemZInfo -lLLVMSparcCodeGen -lLLVMSparcAsmPrinter -lLLVMSparcInfo -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmPrinter -lLLVMPowerPCInfo -lLLVMPTXCodeGen -lLLVMPTXAsmPrinter -lLLVMPTXInfo -lLLVMPIC16AsmPrinter -lLLVMPIC16CodeGen -lLLVMPIC16Info -lLLVMMipsAsmPrinter -lLLVMMipsCodeGen -lLLVMMipsInfo -lLLVMMSP430CodeGen -lLLVMMSP430AsmPrinter -lLLVMMSP430Info -lLLVMMBlazeAsmPrinter -lLLVMMBlazeCodeGen -lLLVMMBlazeInfo -lLLVMLinker -lLLVMipo -lLLVMInterpreter -lLLVMInstrumentation -lLLVMJIT -lLLVMExecutionEngine -lLLVMCppBackend -lLLVMCppBackendInfo -lLLVMCellSPUCodeGen -lLLVMCellSPUAsmPrinter -lLLVMCellSPUInfo -lLLVMCBackend -lLLVMCBackendInfo -lLLVMBlackfinCodeGen -lLLVMBlackfinAsmPrinter -lLLVMBlackfinInfo -lLLVMBitWriter -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMX86AsmPrinter -lLLVMX86Info -lLLVMAsmParser -lLLVMARMDisassembler -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMAsmPrinter -lLLVMARMInfo -lLLVMArchive -lLLVMBitReader -lLLVMAlphaCodeGen -lLLVMSelectionDAG -lLLVMAlphaAsmPrinter -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMAlphaInfo -lLLVMSupport -lLLVMSystem   -lpthread -ldl -lm

/var/tmp/portage/sys-devel/clang-9999/work/llvm/Release/lib/libclingEditLine.a(term.o): In function term_deletechars(EditLine_t*, int)': term.cpp:(.text+0x5fe): undefined reference to tputs’
term.cpp:(.text+0x634): undefined reference to tputs' term.cpp:(.text+0x695): undefined reference to tgoto’
/var/tmp/portage/sys-devel/clang-9999/work/llvm/Release/lib/libclingEditLine.a(term.o): In function term_echotc(EditLine_t*, int, char const**)': term.cpp:(.text+0xa1e): undefined reference to tputs’
term.cpp:(.text+0xafd): undefined reference to `tgoto’

and rest of this long log[/code]

On my Gentoo, -lcurses is enriched with --as-need, which used in wrong place cause problems (see gentoo.org/proj/en/qa/asneeded.xml#doc_chap2 listing 2.5 and its description). One solution is to switch of --as-needed (but why if it works very good), but second solution is to fix linker flags.

To solve this problem -lcurses should be moved to end of the linker parameter list. But -lcurses is included via LDFLAGS variable which is put on begin of linker parameter list and in addition enriched by --as-needed. So I prepared small patch which fix this problem. Here is content of this patch:

[code]— Makefile.config.in 2010-09-25 00:40:53.000000000 +0200
+++ Makefile.config.in 2010-09-25 13:31:41.000000000 +0200
@@ -180,7 +180,7 @@
HAVE_PERL := @HAVE_PERL@
HAVE_PTHREAD := @HAVE_PTHREAD@

-LIBS := @LIBS@
+LIBS := $(LIBS) @LIBS@

Targets that we should build

TARGETS_TO_BUILD=@TARGETS_TO_BUILD@
— tools/cling/tools/driver/Makefile 2010-09-25 01:16:09.000000000 +0200
+++ tools/cling/tools/driver/Makefile 2010-09-25 13:25:25.000000000 +0200
@@ -17,7 +17,7 @@

This tool has no plugins, optimize startup time.

TOOL_NO_EXPORTS = 1

-LDFLAGS += -lcurses
+LIBS += -lcurses

USEDLIBS = clingUserInterface.a clingMetaProcessor.a clingInterpreter.a clingEditLine.a clangFrontend.a clangSerialization.a clangDriver.a clangCodeGen.a clangSema.a clangChecker.a clangAnalysis.a clangRewrite.a clangAST.a clangParse.a clangLex.a clangBasic.a
[/code]
Patch is also attached (no, is not, i can’t attach a file).

This is my suggestion, hope developers agree with me.

Best,
Rafal

I’ve finally compiled LLVM, Clang, Cling and ROOT and here I meet new problems.

Firstly my Clang was configured without support for for system cxx headers. With this, ROOT starts with fatal errors, but command line was somehow available:

[code]$ root
Error in TSystem::ExpandFileName: input: $LLVMDIR, output: $LLVMDIR
Sysroot /
User entry /usr/root/include
EnvIncPath
CEnvIncPath
CXXEnvIncPath
ResourceDir /usr/root/lib/clang/2.9
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::compileString: Parse failed!
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::compileString: Parse failed!
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::compileString: Parse failed!
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::compileString: Parse failed!
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::compileString: Parse failed!
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::compileString: Parse failed!


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.27/05 30 June 2010 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      http://root.cern.ch            *
    
  •                                     *
    

ROOT 5.27/05 (trunk@31998, Jan 13 2010, 22:44:02 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010

cling-ified version <<<<<<<<<<
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
Error: Bad source file(unnamed macro) /home/dziadu/.root/rootlogon.C /home/dziadu/.root/rootlogon.C:1:
unnamed macro has to be executed by ‘x’ command
*** Interpreter error recovered ***
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::compileString: Parse failed!
root [0] .ls
root [1] TBrowser b;
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::createStatementList: Parse failed!
root [2] ?
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::createStatementList: Parse failed!

ROOT special commands.

         pwd          : show current directory, pad and style
         ls           : list contents of current directory
         which [file] : shows path of macro file

root [3] #include “linux/stddef”
root [4] #include “linux/stddef.h”
root [5] ?
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Interpreter::createStatementList: Parse failed!

ROOT special commands.

         pwd          : show current directory, pad and style
         ls           : list contents of current directory
         which [file] : shows path of macro file

root [6] .q[/code]
Obviously, TBrowser didn’t start. After exporting variable LLVM=llvm-config --prefix (maybe this should be written in Documentation, for now there is only info about exporting this variable for compiling) fatal error changed to this one:

[code]$ root
Sysroot /
User entry /usr/root/include
EnvIncPath
CEnvIncPath
CXXEnvIncPath
ResourceDir /usr/lib/clang/2.9
In file included from CLING:2:
In file included from /usr/root/include/TPluginManager.h:89:
In file included from /usr/root/include/TObject.h:31:
In file included from /usr/root/include/Rtypes.h:30:
/usr/root/include/Rtypeinfo.h:32:10: fatal error: ‘typeinfo’ file not found
#include
^
Interpreter::compileString: Parse failed!
In file included from CLING:2:
In file included from /usr/root/include/TPluginManager.h:89:
In file included from /usr/root/include/TObject.h:31:
In file included from /usr/root/include/Rtypes.h:30:
/usr/root/include/Rtypeinfo.h:32:10: fatal error: ‘typeinfo’ file not found
#include
^
Interpreter::compileString: Parse failed!
In file included from CLING:2:
In file included from /usr/root/include/TPluginManager.h:89:
In file included from /usr/root/include/TObject.h:31:
In file included from /usr/root/include/Rtypes.h:30:
/usr/root/include/Rtypeinfo.h:32:10: fatal error: ‘typeinfo’ file not found
#include
^
Interpreter::compileString: Parse failed!
In file included from CLING:2:
In file included from /usr/root/include/TPluginManager.h:89:
In file included from /usr/root/include/TObject.h:31:
In file included from /usr/root/include/Rtypes.h:30:
/usr/root/include/Rtypeinfo.h:32:10: fatal error: ‘typeinfo’ file not found
#include
^
Interpreter::compileString: Parse failed!
In file included from CLING:2:
In file included from /usr/root/include/TPluginManager.h:89:
In file included from /usr/root/include/TObject.h:31:
In file included from /usr/root/include/Rtypes.h:30:
/usr/root/include/Rtypeinfo.h:32:10: fatal error: ‘typeinfo’ file not found
#include
^
Interpreter::compileString: Parse failed!
In file included from CLING:2:
In file included from /usr/root/include/TPluginManager.h:89:
In file included from /usr/root/include/TObject.h:31:
In file included from /usr/root/include/Rtypes.h:30:
/usr/root/include/Rtypeinfo.h:32:10: fatal error: ‘typeinfo’ file not found
#include
^
Interpreter::compileString: Parse failed!


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.27/05 30 June 2010 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      http://root.cern.ch            *
    
  •                                     *
    

ROOT 5.27/05 (trunk@31998, Jan 13 2010, 22:44:02 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010

cling-ified version <<<<<<<<<<
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
In file included from CLING:2:
In file included from /usr/root/include/TPluginManager.h:89:
In file included from /usr/root/include/TObject.h:31:
In file included from /usr/root/include/Rtypes.h:30:
/usr/root/include/Rtypeinfo.h:32:10: fatal error: ‘typeinfo’ file not found
#include
^
Interpreter::compileString: Parse failed![/code]
So, seeing problems with I decided to recompile Clang as well as ROOT with new Ling libraries, with support for system headers. Now, result was even worst, because ROOT finish with crash caused by segmentation fault:

[code]$ root
Sysroot /
User entry /usr/root/include
EnvIncPath
CEnvIncPath
CXXEnvIncPath
ResourceDir /usr/lib/clang/2.9
Stack dump:
0. /usr/include/pthread.h:513:24: current parser token ‘;’

  1.  /usr/include/pthread.h:507:9: parsing struct/union/class body
    

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00007f688ad027ee in waitpid () from /lib/libc.so.6
#1 0x00007f688ac9dee9 in do_system () from /lib/libc.so.6
#2 0x00007f688d046107 in TUnixSystem::StackTrace() () from /usr/root/lib/libCore.so.5.27
#3 0x00007f688d0471c3 in TUnixSystem::DispatchSignals(ESignals) () from /usr/root/lib/libCore.so.5.27
#4
#5 0x00007f688d7e263b in clang::Diagnostic::ReportDelayed() () from /usr/root/lib/libCore.so.5.27
#6 0x00007f688d7e25f5 in clang::DiagnosticBuilder::Emit() () from /usr/root/lib/libCore.so.5.27
#7 0x00007f688d8ab84e in ?? () from /usr/root/lib/libCore.so.5.27
#8 0x00007f688d8adce0 in clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) () from /usr/root/lib/libCore.so.5.27
#9 0x00007f688d8483b8 in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#10 0x00007f688d84819f in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#11 0x00007f688d84878b in clang::ASTContext::getTypeSizeInChars(clang::QualType) () from /usr/root/lib/libCore.so.5.27
#12 0x00007f688d8c8bc4 in clang::ConstantArrayType::getNumAddressingBits(clang::ASTContext&, clang::QualType, llvm::APInt const&) () from /usr/root/lib/libCore.so.5.27
#13 0x00007f688d615bb7 in clang::Sema::BuildArrayType(clang::QualType, clang::ArrayType::ArraySizeModifier, clang::Expr*, unsigned int, clang::SourceRange, clang::DeclarationName) () from /usr/root/lib/libCore.so.5.27
#14 0x00007f688d61761c in clang::Sema::GetTypeForDeclarator(clang::Declarator&, clang::Scope*, clang::TagDecl**) () from /usr/root/lib/libCore.so.5.27
#15 0x00007f688d4d2160 in clang::Sema::HandleField(clang::Scope*, clang::RecordDecl*, clang::SourceLocation, clang::Declarator&, clang::Expr*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#16 0x00007f688d4e9980 in clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier, clang::Declarator&, clang::ASTMultiPtrclang::TemplateParameterList*, clang::Expr*, clang::Expr*, bool, bool) () from /usr/root/lib/libCore.so.5.27
#17 0x00007f688d697736 in clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ParsingDeclRAIIObject*) () from /usr/root/lib/libCore.so.5.27
#18 0x00007f688d69881f in clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, unsigned int, clang::Decl*) () from /usr/root/lib/libCore.so.5.27
#19 0x00007f688d699500 in clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool) () from /usr/root/lib/libCore.so.5.27
#20 0x00007f688d68ca5e in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext) () from /usr/root/lib/libCore.so.5.27
#21 0x00007f688d692bf0 in clang::Parser::ParseSimpleDeclaration(unsigned int, clang::SourceLocation&, clang::AttributeList*, bool) () from /usr/root/lib/libCore.so.5.27
#22 0x00007f688d692d75 in clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::CXX0XAttributeList) () from /usr/root/lib/libCore.so.5.27
#23 0x00007f688d685e83 in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#24 0x00007f688d69a158 in clang::Parser::ParseLinkage(clang::Parser::ParsingDeclSpec&, unsigned int) () from /usr/root/lib/libCore.so.5.27
#25 0x00007f688d6837d8 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&, clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#26 0x00007f688d683b04 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#27 0x00007f688d68617d in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#28 0x00007f688d68625c in clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) () from /usr/root/lib/libCore.so.5.27
#29 0x00007f688d66f7eb in clang::ParseAST(clang::Sema&, bool) () from /usr/root/lib/libCore.so.5.27
#30 0x00007f688d66fa71 in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, bool, clang::CodeCompleteConsumer*) () from /usr/root/lib/libCore.so.5.27
#31 0x00007f688d3c219d in cling::Interpreter::compileString(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#32 0x00007f688d3c2d6f in cling::Interpreter::compileFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#33 0x00007f688d3c3ef6 in cling::Interpreter::loadFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#34 0x00007f688d3c611b in cling::Interpreter::executeFile(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#35 0x00007f688d3cb98d in cling::MetaProcessor::ProcessMeta(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#36 0x00007f688d3cbcfd in cling::MetaProcessor::process(char const*) () from /usr/root/lib/libCore.so.5.27
#37 0x00007f688d08a75f in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/root/lib/libCore.so.5.27
#38 0x00007f688d086d53 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /usr/root/lib/libCore.so.5.27
#39 0x00007f688cf7605a in TApplication::ExecuteFile(char const*, int*, bool) () from /usr/root/lib/libCore.so.5.27
#40 0x00007f688d087352 in TCint::ExecuteMacro(char const*, TInterpreter::EErrorCode*) () from /usr/root/lib/libCore.so.5.27
#41 0x00007f688cfb9909 in TROOT::Macro(char const*, int*, bool) () from /usr/root/lib/libCore.so.5.27
#42 0x00007f688cfa729d in TPluginManager::LoadHandlerMacros(char const*) () from /usr/root/lib/libCore.so.5.27
#43 0x00007f688cfa7663 in TPluginManager::LoadHandlersFromPluginDirs(char const*) () from /usr/root/lib/libCore.so.5.27
#44 0x00007f688cfa7dea in TPluginManager::FindHandler(char const*, char const*) () from /usr/root/lib/libCore.so.5.27
#45 0x00007f688cfd309a in TSystem::FindHelper(char const*, void*) () from /usr/root/lib/libCore.so.5.27
#46 0x00007f688d041ccb in TUnixSystem::OpenDirectory(char const*) () from /usr/root/lib/libCore.so.5.27
#47 0x00007f688d08e4bd in ?? () from /usr/root/lib/libCore.so.5.27
#48 0x00007f688d08f2e1 in TCint::LoadLibraryMap(char const*) () from /usr/root/lib/libCore.so.5.27
#49 0x00007f688d0872bf in TCint::EnableAutoLoading() () from /usr/root/lib/libCore.so.5.27
#50 0x00007f688cf74b4c in TApplication::TApplication(char const*, int*, char**, void*, int) () from /usr/root/lib/libCore.so.5.27
#51 0x00007f688bba6362 in TRint::TRint(char const*, int*, char**, void*, int, bool) () from /usr/root/lib/libRint.so.5.27
#52 0x00000000004011de in main ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
Sign in to GitHub · GitHub. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#5 0x00007f688d7e263b in clang::Diagnostic::ReportDelayed() () from /usr/root/lib/libCore.so.5.27
#6 0x00007f688d7e25f5 in clang::DiagnosticBuilder::Emit() () from /usr/root/lib/libCore.so.5.27
#7 0x00007f688d8ab84e in ?? () from /usr/root/lib/libCore.so.5.27
#8 0x00007f688d8adce0 in clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) () from /usr/root/lib/libCore.so.5.27
#9 0x00007f688d8483b8 in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#10 0x00007f688d84819f in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#11 0x00007f688d84878b in clang::ASTContext::getTypeSizeInChars(clang::QualType) () from /usr/root/lib/libCore.so.5.27
#12 0x00007f688d8c8bc4 in clang::ConstantArrayType::getNumAddressingBits(clang::ASTContext&, clang::QualType, llvm::APInt const&) () from /usr/root/lib/libCore.so.5.27
#13 0x00007f688d615bb7 in clang::Sema::BuildArrayType(clang::QualType, clang::ArrayType::ArraySizeModifier, clang::Expr*, unsigned int, clang::SourceRange, clang::DeclarationName) () from /usr/root/lib/libCore.so.5.27
#14 0x00007f688d61761c in clang::Sema::GetTypeForDeclarator(clang::Declarator&, clang::Scope*, clang::TagDecl**) () from /usr/root/lib/libCore.so.5.27
#15 0x00007f688d4d2160 in clang::Sema::HandleField(clang::Scope*, clang::RecordDecl*, clang::SourceLocation, clang::Declarator&, clang::Expr*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#16 0x00007f688d4e9980 in clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier, clang::Declarator&, clang::ASTMultiPtrclang::TemplateParameterList*, clang::Expr*, clang::Expr*, bool, bool) () from /usr/root/lib/libCore.so.5.27
#17 0x00007f688d697736 in clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ParsingDeclRAIIObject*) () from /usr/root/lib/libCore.so.5.27
#18 0x00007f688d69881f in clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, unsigned int, clang::Decl*) () from /usr/root/lib/libCore.so.5.27
#19 0x00007f688d699500 in clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool) () from /usr/root/lib/libCore.so.5.27
#20 0x00007f688d68ca5e in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext) () from /usr/root/lib/libCore.so.5.27
#21 0x00007f688d692bf0 in clang::Parser::ParseSimpleDeclaration(unsigned int, clang::SourceLocation&, clang::AttributeList*, bool) () from /usr/root/lib/libCore.so.5.27
#22 0x00007f688d692d75 in clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::CXX0XAttributeList) () from /usr/root/lib/libCore.so.5.27
#23 0x00007f688d685e83 in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#24 0x00007f688d69a158 in clang::Parser::ParseLinkage(clang::Parser::ParsingDeclSpec&, unsigned int) () from /usr/root/lib/libCore.so.5.27
#25 0x00007f688d6837d8 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&, clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#26 0x00007f688d683b04 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#27 0x00007f688d68617d in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#28 0x00007f688d68625c in clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) () from /usr/root/lib/libCore.so.5.27
#29 0x00007f688d66f7eb in clang::ParseAST(clang::Sema&, bool) () from /usr/root/lib/libCore.so.5.27
#30 0x00007f688d66fa71 in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, bool, clang::CodeCompleteConsumer*) () from /usr/root/lib/libCore.so.5.27
#31 0x00007f688d3c219d in cling::Interpreter::compileString(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#32 0x00007f688d3c2d6f in cling::Interpreter::compileFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#33 0x00007f688d3c3ef6 in cling::Interpreter::loadFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#34 0x00007f688d3c611b in cling::Interpreter::executeFile(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#35 0x00007f688d3cb98d in cling::MetaProcessor::ProcessMeta(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#36 0x00007f688d3cbcfd in cling::MetaProcessor::process(char const*) () from /usr/root/lib/libCore.so.5.27
===========================================================[/code]
So to check last way, I unset LLVMDIR and run root again, with following result:

[code]$ root
Error in TSystem::ExpandFileName: input: $LLVMDIR, output: $LLVMDIR
Sysroot /
User entry /usr/root/include
EnvIncPath
CEnvIncPath
CXXEnvIncPath
ResourceDir /usr/root/lib/clang/2.9
In file included from CLING:1:
/usr/include/stdio.h:34:11: fatal error: ‘stddef.h’ file not found

include <stddef.h>

      ^

Stack dump:
0. /usr/include/pthread.h:513:24: current parser token ‘;’

  1.  /usr/include/pthread.h:507:9: parsing struct/union/class body
    

*** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:

#0 0x00007f10ed4f27ee in waitpid () from /lib/libc.so.6
#1 0x00007f10ed48dee9 in do_system () from /lib/libc.so.6
#2 0x00007f10ef836107 in TUnixSystem::StackTrace() () from /usr/root/lib/libCore.so.5.27
#3 0x00007f10ef8371c3 in TUnixSystem::DispatchSignals(ESignals) () from /usr/root/lib/libCore.so.5.27
#4
#5 0x00007f10effd263b in clang::Diagnostic::ReportDelayed() () from /usr/root/lib/libCore.so.5.27
#6 0x00007f10effd25f5 in clang::DiagnosticBuilder::Emit() () from /usr/root/lib/libCore.so.5.27
#7 0x00007f10f009b84e in ?? () from /usr/root/lib/libCore.so.5.27
#8 0x00007f10f009dce0 in clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) () from /usr/root/lib/libCore.so.5.27
#9 0x00007f10f00383b8 in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#10 0x00007f10f003819f in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#11 0x00007f10f003878b in clang::ASTContext::getTypeSizeInChars(clang::QualType) () from /usr/root/lib/libCore.so.5.27
#12 0x00007f10f00b8bc4 in clang::ConstantArrayType::getNumAddressingBits(clang::ASTContext&, clang::QualType, llvm::APInt const&) () from /usr/root/lib/libCore.so.5.27
#13 0x00007f10efe05bb7 in clang::Sema::BuildArrayType(clang::QualType, clang::ArrayType::ArraySizeModifier, clang::Expr*, unsigned int, clang::SourceRange, clang::DeclarationName) () from /usr/root/lib/libCore.so.5.27
#14 0x00007f10efe0761c in clang::Sema::GetTypeForDeclarator(clang::Declarator&, clang::Scope*, clang::TagDecl**) () from /usr/root/lib/libCore.so.5.27
#15 0x00007f10efcc2160 in clang::Sema::HandleField(clang::Scope*, clang::RecordDecl*, clang::SourceLocation, clang::Declarator&, clang::Expr*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#16 0x00007f10efcd9980 in clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier, clang::Declarator&, clang::ASTMultiPtrclang::TemplateParameterList*, clang::Expr*, clang::Expr*, bool, bool) () from /usr/root/lib/libCore.so.5.27
#17 0x00007f10efe87736 in clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ParsingDeclRAIIObject*) () from /usr/root/lib/libCore.so.5.27
#18 0x00007f10efe8881f in clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, unsigned int, clang::Decl*) () from /usr/root/lib/libCore.so.5.27
#19 0x00007f10efe89500 in clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool) () from /usr/root/lib/libCore.so.5.27
#20 0x00007f10efe7ca5e in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext) () from /usr/root/lib/libCore.so.5.27
#21 0x00007f10efe82bf0 in clang::Parser::ParseSimpleDeclaration(unsigned int, clang::SourceLocation&, clang::AttributeList*, bool) () from /usr/root/lib/libCore.so.5.27
#22 0x00007f10efe82d75 in clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::CXX0XAttributeList) () from /usr/root/lib/libCore.so.5.27
#23 0x00007f10efe75e83 in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#24 0x00007f10efe8a158 in clang::Parser::ParseLinkage(clang::Parser::ParsingDeclSpec&, unsigned int) () from /usr/root/lib/libCore.so.5.27
#25 0x00007f10efe737d8 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&, clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#26 0x00007f10efe73b04 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#27 0x00007f10efe7617d in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#28 0x00007f10efe7625c in clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) () from /usr/root/lib/libCore.so.5.27
#29 0x00007f10efe5f7eb in clang::ParseAST(clang::Sema&, bool) () from /usr/root/lib/libCore.so.5.27
#30 0x00007f10efe5fa71 in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, bool, clang::CodeCompleteConsumer*) () from /usr/root/lib/libCore.so.5.27
#31 0x00007f10efbb219d in cling::Interpreter::compileString(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#32 0x00007f10efbb2d6f in cling::Interpreter::compileFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#33 0x00007f10efbb3ef6 in cling::Interpreter::loadFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#34 0x00007f10efbb611b in cling::Interpreter::executeFile(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#35 0x00007f10efbbb98d in cling::MetaProcessor::ProcessMeta(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#36 0x00007f10efbbbcfd in cling::MetaProcessor::process(char const*) () from /usr/root/lib/libCore.so.5.27
#37 0x00007f10ef87a75f in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /usr/root/lib/libCore.so.5.27
#38 0x00007f10ef876d53 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /usr/root/lib/libCore.so.5.27
#39 0x00007f10ef76605a in TApplication::ExecuteFile(char const*, int*, bool) () from /usr/root/lib/libCore.so.5.27
#40 0x00007f10ef877352 in TCint::ExecuteMacro(char const*, TInterpreter::EErrorCode*) () from /usr/root/lib/libCore.so.5.27
#41 0x00007f10ef7a9909 in TROOT::Macro(char const*, int*, bool) () from /usr/root/lib/libCore.so.5.27
#42 0x00007f10ef79729d in TPluginManager::LoadHandlerMacros(char const*) () from /usr/root/lib/libCore.so.5.27
#43 0x00007f10ef797663 in TPluginManager::LoadHandlersFromPluginDirs(char const*) () from /usr/root/lib/libCore.so.5.27
#44 0x00007f10ef797dea in TPluginManager::FindHandler(char const*, char const*) () from /usr/root/lib/libCore.so.5.27
#45 0x00007f10ef7c309a in TSystem::FindHelper(char const*, void*) () from /usr/root/lib/libCore.so.5.27
#46 0x00007f10ef831ccb in TUnixSystem::OpenDirectory(char const*) () from /usr/root/lib/libCore.so.5.27
#47 0x00007f10ef87e4bd in ?? () from /usr/root/lib/libCore.so.5.27
#48 0x00007f10ef87f2e1 in TCint::LoadLibraryMap(char const*) () from /usr/root/lib/libCore.so.5.27
#49 0x00007f10ef8772bf in TCint::EnableAutoLoading() () from /usr/root/lib/libCore.so.5.27
#50 0x00007f10ef764b4c in TApplication::TApplication(char const*, int*, char**, void*, int) () from /usr/root/lib/libCore.so.5.27
#51 0x00007f10ee396362 in TRint::TRint(char const*, int*, char**, void*, int, bool) () from /usr/root/lib/libRint.so.5.27
#52 0x00000000004011de in main ()

The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
Sign in to GitHub · GitHub. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.

#5 0x00007f10effd263b in clang::Diagnostic::ReportDelayed() () from /usr/root/lib/libCore.so.5.27
#6 0x00007f10effd25f5 in clang::DiagnosticBuilder::Emit() () from /usr/root/lib/libCore.so.5.27
#7 0x00007f10f009b84e in ?? () from /usr/root/lib/libCore.so.5.27
#8 0x00007f10f009dce0 in clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) () from /usr/root/lib/libCore.so.5.27
#9 0x00007f10f00383b8 in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#10 0x00007f10f003819f in clang::ASTContext::getTypeInfo(clang::Type const*) () from /usr/root/lib/libCore.so.5.27
#11 0x00007f10f003878b in clang::ASTContext::getTypeSizeInChars(clang::QualType) () from /usr/root/lib/libCore.so.5.27
#12 0x00007f10f00b8bc4 in clang::ConstantArrayType::getNumAddressingBits(clang::ASTContext&, clang::QualType, llvm::APInt const&) () from /usr/root/lib/libCore.so.5.27
#13 0x00007f10efe05bb7 in clang::Sema::BuildArrayType(clang::QualType, clang::ArrayType::ArraySizeModifier, clang::Expr*, unsigned int, clang::SourceRange, clang::DeclarationName) () from /usr/root/lib/libCore.so.5.27
#14 0x00007f10efe0761c in clang::Sema::GetTypeForDeclarator(clang::Declarator&, clang::Scope*, clang::TagDecl**) () from /usr/root/lib/libCore.so.5.27
#15 0x00007f10efcc2160 in clang::Sema::HandleField(clang::Scope*, clang::RecordDecl*, clang::SourceLocation, clang::Declarator&, clang::Expr*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#16 0x00007f10efcd9980 in clang::Sema::ActOnCXXMemberDeclarator(clang::Scope*, clang::AccessSpecifier, clang::Declarator&, clang::ASTMultiPtrclang::TemplateParameterList*, clang::Expr*, clang::Expr*, bool, bool) () from /usr/root/lib/libCore.so.5.27
#17 0x00007f10efe87736 in clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ParsingDeclRAIIObject*) () from /usr/root/lib/libCore.so.5.27
#18 0x00007f10efe8881f in clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, unsigned int, clang::Decl*) () from /usr/root/lib/libCore.so.5.27
#19 0x00007f10efe89500 in clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool) () from /usr/root/lib/libCore.so.5.27
#20 0x00007f10efe7ca5e in clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext) () from /usr/root/lib/libCore.so.5.27
#21 0x00007f10efe82bf0 in clang::Parser::ParseSimpleDeclaration(unsigned int, clang::SourceLocation&, clang::AttributeList*, bool) () from /usr/root/lib/libCore.so.5.27
#22 0x00007f10efe82d75 in clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::CXX0XAttributeList) () from /usr/root/lib/libCore.so.5.27
#23 0x00007f10efe75e83 in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#24 0x00007f10efe8a158 in clang::Parser::ParseLinkage(clang::Parser::ParsingDeclSpec&, unsigned int) () from /usr/root/lib/libCore.so.5.27
#25 0x00007f10efe737d8 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&, clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#26 0x00007f10efe73b04 in clang::Parser::ParseDeclarationOrFunctionDefinition(clang::AttributeList*, clang::AccessSpecifier) () from /usr/root/lib/libCore.so.5.27
#27 0x00007f10efe7617d in clang::Parser::ParseExternalDeclaration(clang::CXX0XAttributeList, clang::Parser::ParsingDeclSpec*) () from /usr/root/lib/libCore.so.5.27
#28 0x00007f10efe7625c in clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) () from /usr/root/lib/libCore.so.5.27
#29 0x00007f10efe5f7eb in clang::ParseAST(clang::Sema&, bool) () from /usr/root/lib/libCore.so.5.27
#30 0x00007f10efe5fa71 in clang::ParseAST(clang::Preprocessor&, clang::ASTConsumer*, clang::ASTContext&, bool, bool, clang::CodeCompleteConsumer*) () from /usr/root/lib/libCore.so.5.27
#31 0x00007f10efbb219d in cling::Interpreter::compileString(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#32 0x00007f10efbb2d6f in cling::Interpreter::compileFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#33 0x00007f10efbb3ef6 in cling::Interpreter::loadFile(std::basic_string<char, std::char_traits, std::allocator > const&, std::basic_string<char, std::char_traits, std::allocator > const*) () from /usr/root/lib/libCore.so.5.27
#34 0x00007f10efbb611b in cling::Interpreter::executeFile(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#35 0x00007f10efbbb98d in cling::MetaProcessor::ProcessMeta(std::basic_string<char, std::char_traits, std::allocator > const&) () from /usr/root/lib/libCore.so.5.27
#36 0x00007f10efbbbcfd in cling::MetaProcessor::process(char const*) () from /usr/root/lib/libCore.so.5.27
===========================================================[/code]
We back to problem with stddef.h but crash still exists, so I can assume that is something connected to system headers support.

I also followed instructions on Clang website and hardcoded paths into clang/trunk/lib/Frontend/InitHeaderSearch.cpp but result is exactly the same like with clang/configure --system-cxx-headers=…

Of course, always after recompiling clang I recompiled also ROOT to do not have any library mismatch.

Any ideas what to do next to run it?

Here is short spec of my Gentoo Linux system

System uname: Linux-2.6.35-gentoo-r8-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T7500_@_2.20GHz-with-gentoo-2.0.1 Timestamp of tree: Mon, 27 Sep 2010 05:45:03 +0000 app-shells/bash: 4.1_p7 dev-java/java-config: 2.1.11 dev-lang/python: 2.6.5-r3, 3.1.2-r4 dev-util/cmake: 2.8.1-r2 sys-apps/baselayout: 2.0.1 sys-apps/openrc: 0.6.3 sys-apps/sandbox: 2.3-r1 sys-devel/autoconf: 2.13, 2.67 sys-devel/automake: 1.9.6-r3, 1.10.3, 1.11.1 sys-devel/binutils: 2.20.1-r1 sys-devel/gcc: 4.4.4-r2 sys-devel/gcc-config: 1.4.1 sys-devel/libtool: 2.2.10 sys-devel/make: 3.81-r2 virtual/os-headers: 2.6.35 (sys-kernel/linux-headers) CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=core2 -O2 -pipe" CHOST="x86_64-pc-linux-gnu" CXXFLAGS="-march=core2 -O2 -pipe" LANG="pl_PL.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" LINGUAS="pl en" MAKEOPTS="-j1 --quiet"

Hi Rafal!

Posting it here makes sense: you talk to the right people.

Thanks for testdriving the cling build! Your patch is in (thank you!) and we’ll fix the comments on the web page - actually we’ll probably simply use the output of llvm-config in the future.

Your test resulting in a segmentation violation is actually the right approach :slight_smile: I can reproduce that crash; I’ll let you know when it’s fixed (race in the static initialization phase - I hate those…). Until then you are very welcome to give feedback on standalone cling, too! :wink:

Cheers, Axel.

Hi,

I just realized how long we ignored your post - I’m terribly sorry about that!

The startup issue you see has been fixed, it should work now. I still see an issue on MacOS because of the static init, but that’s not relevant for you.

Cheers, Axel.