使用clang 3.7与libc ++和c ++ 11/14 / 1z进行内部编译器错误

时间:2016-01-12 10:42:21

标签: c++ clang libc++

//hello.cpp
#include <iostream>
int main(){

}

如果我尝试使用

编译hello.cpp

clang++ -std=c++14 -stdlib=libc++ hello.cpp -o hello

我将收到内部编译器错误。我正在使用clang 3.7和来自arch

的libc ++

根据libc++支持c ++ 1z。

  

libc ++也是一个100%完整的C ++ 14实现。可以在此处找到C ++ 14的新功能和更改列表。

     

可以在此处找到下一个C ++标准的功能和更改列表,这里称为“C ++ 1z”(可能是C ++ 17)。

$ clang++ -std=c++14 -stdlib=libc++ hello.cpp -o hello
#0 0x7f3ae197f6b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/bin/../lib/libLLVM.so.3.7+0x5686b0)
#1 0x7f3ae197e491 (/usr/bin/../lib/libLLVM.so.3.7+0x567491)
#2 0x7f3ae120ad60 __restore_rt (/usr/bin/../lib/libpthread.so.0+0x10d60)
#3 0x13c09ad (/usr/bin/clang-3.7+0x13c09ad)
#4 0x13ca17d (/usr/bin/clang-3.7+0x13ca17d)
#5 0x13ca57e (/usr/bin/clang-3.7+0x13ca57e)
#6 0x13c8ee3 (/usr/bin/clang-3.7+0x13c8ee3)
#7 0x13c7dd5 (/usr/bin/clang-3.7+0x13c7dd5)
#8 0x13c836e (/usr/bin/clang-3.7+0x13c836e)
#9 0x13c8967 (/usr/bin/clang-3.7+0x13c8967)
#10 0x13c837f (/usr/bin/clang-3.7+0x13c837f)
#11 0x13c8967 (/usr/bin/clang-3.7+0x13c8967)
#12 0x13c837f (/usr/bin/clang-3.7+0x13c837f)
#13 0x13c9a4b (/usr/bin/clang-3.7+0x13c9a4b)
#14 0x13c9da8 (/usr/bin/clang-3.7+0x13c9da8)
#15 0x13cce69 (/usr/bin/clang-3.7+0x13cce69)
#16 0x13c4386 (/usr/bin/clang-3.7+0x13c4386)
#17 0x13c64d1 (/usr/bin/clang-3.7+0x13c64d1)
#18 0x13c42a1 (/usr/bin/clang-3.7+0x13c42a1)
#19 0x13c593f (/usr/bin/clang-3.7+0x13c593f)
#20 0x13c7269 (/usr/bin/clang-3.7+0x13c7269)
#21 0x13c7155 (/usr/bin/clang-3.7+0x13c7155)
#22 0x13c7490 (/usr/bin/clang-3.7+0x13c7490)
#23 0x13cc760 (/usr/bin/clang-3.7+0x13cc760)
#24 0x69c712 clang::CodeGen::CodeGenModule::getMangledName(clang::GlobalDecl) (/usr/bin/clang-3.7+0x69c712)
#25 0x6a8813 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/bin/clang-3.7+0x6a8813)
#26 0x6dd2d9 (/usr/bin/clang-3.7+0x6dd2d9)
#27 0x6a94b8 (/usr/bin/clang-3.7+0x6a94b8)
#28 0x9915d3 (/usr/bin/clang-3.7+0x9915d3)
#29 0x98c50c (/usr/bin/clang-3.7+0x98c50c)
#30 0xfc5035 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool) (/usr/bin/clang-3.7+0xfc5035)
#31 0xdc2323 clang::Sema::MarkFunctionReferenced(clang::SourceLocation, clang::FunctionDecl*, bool) (/usr/bin/clang-3.7+0xdc2323)
#32 0xd33aa1 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, bool, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, unsigned int, clang::SourceRange) (/usr/bin/clang-3.7+0xd33aa1)
#33 0xd33ba9 clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType, clang::CXXConstructorDecl*, llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, unsigned int, clang::SourceRange) (/usr/bin/clang-3.7+0xd33ba9)
#34 0xe5726c clang::InitializationSequence::Perform(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, clang::QualType*) (/usr/bin/clang-3.7+0xe5726c)
#35 0xe10277 (/usr/bin/clang-3.7+0xe10277)
#36 0xe106d9 clang::Sema::BuildTypeTrait(clang::TypeTrait, clang::SourceLocation, llvm::ArrayRef<clang::TypeSourceInfo*>, clang::SourceLocation) (/usr/bin/clang-3.7+0xe106d9)
#37 0xf9b94b (/usr/bin/clang-3.7+0xf9b94b)
#38 0xf9ef4e (/usr/bin/clang-3.7+0xf9ef4e)
#39 0xfa1529 (/usr/bin/clang-3.7+0xfa1529)
#40 0xf9eed4 (/usr/bin/clang-3.7+0xf9eed4)
#41 0xfa789e (/usr/bin/clang-3.7+0xfa789e)
#42 0xfaafe7 (/usr/bin/clang-3.7+0xfaafe7)
#43 0xf99028 (/usr/bin/clang-3.7+0xf99028)
#44 0xf99e81 (/usr/bin/clang-3.7+0xf99e81)
#45 0xf99fe3 clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/bin/clang-3.7+0xf99fe3)
#46 0xfb675d clang::Sema::SubstBaseSpecifiers(clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&) (/usr/bin/clang-3.7+0xfb675d)
#47 0xfb74dd clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) (/usr/bin/clang-3.7+0xfb74dd)
#48 0xfb85ce clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) (/usr/bin/clang-3.7+0xfb85ce)
#49 0xfe3b25 clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) (/usr/bin/clang-3.7+0xfe3b25)
#50 0xfe3d8f clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::TypeDiagnoser&) (/usr/bin/clang-3.7+0xfe3d8f)
#51 0xc61190 clang::Sema::RequireCompleteDeclContext(clang::CXXScopeSpec&, clang::DeclContext*) (/usr/bin/clang-3.7+0xc61190)
#52 0xdc8c75 clang::Sema::BuildQualifiedDeclarationNameExpr(clang::CXXScopeSpec&, clang::DeclarationNameInfo const&, bool, clang::TypeSourceInfo**) (/usr/bin/clang-3.7+0xdc8c75)
#53 0xfad9cd (/usr/bin/clang-3.7+0xfad9cd)
#54 0xfadb0d (/usr/bin/clang-3.7+0xfadb0d)
#55 0xf9ec9e (/usr/bin/clang-3.7+0xf9ec9e)
#56 0xfa789e (/usr/bin/clang-3.7+0xfa789e)
#57 0xfaafe7 (/usr/bin/clang-3.7+0xfaafe7)
#58 0xfabc2e (/usr/bin/clang-3.7+0xfabc2e)
#59 0xfac335 (/usr/bin/clang-3.7+0xfac335)
#60 0xf99586 (/usr/bin/clang-3.7+0xf99586)
#61 0xf99673 (/usr/bin/clang-3.7+0xf99673)
#62 0xf99e81 (/usr/bin/clang-3.7+0xf99e81)
#63 0xf99fe3 clang::Sema::SubstType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName) (/usr/bin/clang-3.7+0xf99fe3)
#64 0xf966e1 clang::Sema::SubstParmVarDecl(clang::ParmVarDecl*, clang::MultiLevelTemplateArgumentList const&, int, llvm::Optional<unsigned int>, bool) (/usr/bin/clang-3.7+0xf966e1)
#65 0xf97533 (/usr/bin/clang-3.7+0xf97533)
#66 0xf9d061 clang::Sema::SubstFunctionDeclType(clang::TypeSourceInfo*, clang::MultiLevelTemplateArgumentList const&, clang::SourceLocation, clang::DeclarationName, clang::CXXRecordDecl*, unsigned int) (/usr/bin/clang-3.7+0xf9d061)
#67 0xfbb111 clang::TemplateDeclInstantiator::VisitDecl(clang::Decl*) (/usr/bin/clang-3.7+0xfbb111)
#68 0xfca77a clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*, clang::TemplateParameterList*, bool) (/usr/bin/clang-3.7+0xfca77a)
#69 0xfc1735 clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/usr/bin/clang-3.7+0xfc1735)
#70 0xf87a58 clang::Sema::FinishTemplateArgumentDeduction(clang::FunctionTemplateDecl*, llvm::SmallVectorImpl<clang::DeducedTemplateArgument>&, unsigned int, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, llvm::SmallVectorImpl<clang::Sema::OriginalCallArg> const*, bool) (/usr/bin/clang-3.7+0xf87a58)
#71 0xf91672 clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::FunctionDecl*&, clang::sema::TemplateDeductionInfo&, bool) (/usr/bin/clang-3.7+0xf91672)
#72 0xee2c0f clang::Sema::AddTemplateOverloadCandidate(clang::FunctionTemplateDecl*, clang::DeclAccessPair, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool) (/usr/bin/clang-3.7+0xee2c0f)
#73 0x60fc73 _init (/usr/bin/clang-3.7+0x60fc73)
#74 0xe5ed47 clang::InitializationSequence::InitializeFrom(clang::Sema&, clang::InitializedEntity const&, clang::InitializationKind const&, llvm::MutableArrayRef<clang::Expr*>, bool) (/usr/bin/clang-3.7+0xe5ed47)
#75 0xcf509f clang::Sema::AddInitializerToDecl(clang::Decl*, clang::Expr*, bool, bool) (/usr/bin/clang-3.7+0xcf509f)
#76 0xad5e5f clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/usr/bin/clang-3.7+0xad5e5f)
#77 0xae31f2 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/usr/bin/clang-3.7+0xae31f2)
#78 0xae6101 clang::Parser::ParseSimpleDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit*) (/usr/bin/clang-3.7+0xae6101)
#79 0xae63b6 clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) (/usr/bin/clang-3.7+0xae63b6)
#80 0xb3beef clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, bool, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/usr/bin/clang-3.7+0xb3beef)
#81 0xb3c11b clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, bool, clang::SourceLocation*) (/usr/bin/clang-3.7+0xb3c11b)
#82 0xb40c3e clang::Parser::ParseCompoundStatementBody(bool) (/usr/bin/clang-3.7+0xb40c3e)
#83 0xb433c6 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/usr/bin/clang-3.7+0xb433c6)
#84 0xaca232 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/usr/bin/clang-3.7+0xaca232)
#85 0xb4e420 clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) (/usr/bin/clang-3.7+0xb4e420)
#86 0xb4f13d clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) (/usr/bin/clang-3.7+0xb4f13d)
#87 0xb4f42f clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) (/usr/bin/clang-3.7+0xb4f42f)
#88 0xae6527 clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) (/usr/bin/clang-3.7+0xae6527)
#89 0xacd401 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/bin/clang-3.7+0xacd401)
#90 0xaf2a45 clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation, std::allocator<clang::SourceLocation> >&, std::vector<clang::IdentifierInfo*, std::allocator<clang::IdentifierInfo*> >&, std::vector<clang::SourceLocation, std::allocator<clang::SourceLocation> >&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/usr/bin/clang-3.7+0xaf2a45)
#91 0xaf351c clang::Parser::ParseNamespace(unsigned int, clang::SourceLocation&, clang::SourceLocation) (/usr/bin/clang-3.7+0xaf351c)
#92 0xae657d clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) (/usr/bin/clang-3.7+0xae657d)
#93 0xacd401 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/bin/clang-3.7+0xacd401)
#94 0xaf2a45 clang::Parser::ParseInnerNamespace(std::vector<clang::SourceLocation, std::allocator<clang::SourceLocation> >&, std::vector<clang::IdentifierInfo*, std::allocator<clang::IdentifierInfo*> >&, std::vector<clang::SourceLocation, std::allocator<clang::SourceLocation> >&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/usr/bin/clang-3.7+0xaf2a45)
#95 0xaf351c clang::Parser::ParseNamespace(unsigned int, clang::SourceLocation&, clang::SourceLocation) (/usr/bin/clang-3.7+0xaf351c)
#96 0xae657d clang::Parser::ParseDeclaration(unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) (/usr/bin/clang-3.7+0xae657d)
#97 0xacd401 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/usr/bin/clang-3.7+0xacd401)
#98 0xacddb9 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/usr/bin/clang-3.7+0xacddb9)
#99 0xac1ea3 clang::ParseAST(clang::Sema&, bool, bool) (/usr/bin/clang-3.7+0xac1ea3)
#100 0x915fa6 clang::FrontendAction::Execute() (/usr/bin/clang-3.7+0x915fa6)
#101 0x8ec629 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/bin/clang-3.7+0x8ec629)
#102 0x98bab3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/bin/clang-3.7+0x98bab3)
#103 0x657208 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-3.7+0x657208)
#104 0x65265e main (/usr/bin/clang-3.7+0x65265e)
#105 0x7f3ae08de610 __libc_start_main (/usr/bin/../lib/libc.so.6+0x20610)
#106 0x655279 _start (/usr/bin/clang-3.7+0x655279)
Stack dump:
0.      Program arguments: /usr/bin/clang-3.7 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name hello.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -resource-dir /usr/bin/../lib/clang/3.7.0 -internal-isystem /usr/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.7.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/maik/projects/breeze/examples -ferror-limit 19 -fmessage-length 145 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/hello-1d050e.o -x c++ hello.cpp 
1.      /usr/bin/../include/c++/v1/__mutex_base:381:38: current parser token ';'
2.      /usr/bin/../include/c++/v1/__mutex_base:23:1 <Spelling=/usr/bin/../include/c++/v1/__config:386:37>: parsing namespace 'std'
3.      /usr/bin/../include/c++/v1/__mutex_base:23:1 <Spelling=/usr/bin/../include/c++/v1/__config:386:59>: parsing namespace '__1'
4.      /usr/bin/../include/c++/v1/__mutex_base:375:1: parsing function body 'wait_for'
5.      /usr/bin/../include/c++/v1/__mutex_base:375:1: in compound statement ('{}')
6.      /usr/bin/../include/c++/v1/chrono:471:9: LLVM IR generation of declaration 'std::__1::chrono::duration<long double, std::__1::ratio<1, 1000000000> >::duration'
clang-3.7: error: unable to execute command: Segmentation fault (core dumped)
clang-3.7: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang-3.7: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang-3.7: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.7: note: diagnostic msg: /tmp/hello-7a3ad0.cpp
clang-3.7: note: diagnostic msg: /tmp/hello-7a3ad0.sh
clang-3.7: note: diagnostic msg: 

2 个答案:

答案 0 :(得分:2)

来自manual

  

在程序中使用libc ++

     

的Linux

     

您需要在构建计算机上保留libc ++ abi的源代码树,并且必须将libc ++ abi共享库的副本放在链接器将找到它的位置。

     

不幸的是,你不能简单地用&#34; -stdlib = libc ++&#34;在这一点上,因为clang被设置为链接libc ++链接到libsupc ++。为了解决这个问题,您必须自己设置链接器(或修补程序铿锵声)。例如:

     

clang++ -stdlib=libc++ helloworld.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc

     

或者,您可以将libc ++ abi添加到库列表中,这在大多数情况下会产生相同的结果:

     

clang++ -stdlib=libc++ helloworld.cpp -lc++abi

答案 1 :(得分:0)

这似乎是关于arch linux上的clang3.7的问题

https://bugs.archlinux.org/task/47329

切换回clang 3.5.2修复了问题。

相关问题