Created attachment 567970 [details] Preprocessed source Description of problem: When trying to rebuild some Fedora packages using LLVM/clang instead of GCC, clang segfaults. With LLVM 2.9 several packages could be rebuilt, now I did not find a single one that would pass. Version-Release number of selected component (if applicable): llvm-3.0-8.fc18 How reproducible: Always Steps to Reproduce: 1. Download the preprocessed source from attachment 2. run "/usr/bin/clang -cc1 -triple x86_64-redhat-linux-gnu -emit-llvm-bc -disable-free -disable-llvm-verifier -main-file-name printf-args.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22.52.0.1 -momit-leaf-frame-pointer -v -g -coverage-file printf-args.o -resource-dir /usr/bin/../lib/clang/3.0 -D HAVE_CONFIG_H -D HAVE_LSTAT -I . -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem /usr/include -O0 -Wall -ferror-limit 19 -fmessage-length 0 -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fexceptions -fdiagnostics-show-option -o printf-args.o -x c printf-args.pp.c" Actual results: clang -cc1 version 3.0 based upon llvm 3.0 hosted on x86_64-redhat-linux-gnu #include "..." search starts here: #include <...> search starts here: . /usr/local/include /usr/bin/../lib/clang/3.0/include /usr/include End of search list. 0 libLLVM-3.0.so 0x00007f1f25e1a0bf 1 libLLVM-3.0.so 0x00007f1f25e1a529 2 libpthread.so.0 0x00007f1f2565efb0 3 clang 0x0000000000c5db02 4 clang 0x0000000000c5e4f2 5 clang 0x0000000000c5ecf7 6 clang 0x0000000000c6037d clang::runUninitializedVariablesAnalysis(clang::DeclContext const&, clang::CFG const&, clang::AnalysisContext&, clang::UninitVariablesHandler&, clang::UninitVariablesAnalysisStats&) + 1597 7 clang 0x0000000000af075a clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy, clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::BlockExpr const*) + 970 8 clang 0x00000000008a338c clang::Sema::PopFunctionOrBlockScope(clang::sema::AnalysisBasedWarnings::Policy const*, clang::Decl const*, clang::BlockExpr const*) + 172 9 clang 0x00000000009209ee clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) + 334 10 clang 0x00000000008481e0 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 192 11 clang 0x0000000000859564 clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&) + 964 12 clang 0x000000000086e7d7 clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 807 13 clang 0x00000000008532e5 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&, clang::AccessSpecifier) + 149 14 clang 0x0000000000853765 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::AccessSpecifier) + 565 15 clang 0x000000000085718d clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::Parser::ParsingDeclSpec*) + 2157 16 clang 0x00000000008574c0 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 144 17 clang 0x0000000000830c0d clang::ParseAST(clang::Sema&, bool) + 269 18 clang 0x00000000007196f3 clang::CodeGenAction::ExecuteAction() + 51 19 clang 0x000000000060f5b3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 307 20 clang 0x00000000005f9524 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 980 21 clang 0x00000000005f1204 cc1_main(char const**, char const**, char const*, void*) + 740 22 clang 0x00000000005f00b8 main + 7096 23 libc.so.6 0x00007f1f24689735 __libc_start_main + 245 24 clang 0x00000000005f0d61 Stack dump: 0. Program arguments: /usr/bin/clang -cc1 -triple x86_64-redhat-linux-gnu -emit-llvm-bc -disable-free -disable-llvm-verifier -main-file-name printf-args.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22.52.0.1 -momit-leaf-frame-pointer -v -g -coverage-file printf-args.o -resource-dir /usr/bin/../lib/clang/3.0 -D HAVE_CONFIG_H -D HAVE_LSTAT -I . -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem /usr/include -O0 -Wall -ferror-limit 19 -fmessage-length 0 -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fexceptions -fdiagnostics-show-option -o printf-args.o -x c printf-args.pp.c 1. <eof> parser at end of file 2. printf-args.c:40:1: parsing function body 'printf_fetchargs' Segmentation fault Expected results: The source compiles with no error. Additional info: Source comes from gzip-1.4-6.fc17. The error originates in running from rpmbuild (which appends the flags). A simple LLVM/clang build simulation can be done: 1) download the SRPM (http://kojipkgs.fedoraproject.org/packages/gzip/1.4/6.fc17/src/gzip-1.4-6.fc17.src.rpm) 2) rpm -ivh gzip-1.4-6.fc17.src.rpm 3) add the "export CC=clang" and LDFLAGS="-Wl,--plugin,/usr/lib64/llvm/LLVMgold.so -Wl,--plugin-opt,also-emit-llvm" lines to the beginning of %build section of the specfile 4) switch the linker to ld.gold 5) rpmbuild -bb ~/rpmbuild/SPECS/gzip.spec Same trick works and produces the error on different simple packages (eg. ncurses, libselinux, btparser), you just eventually need to add "export CXX=clang".
It might be linked to the following upstream bug: http://llvm.org/bugs/show_bug.cgi?id=9071 Corresponding two line bugfix can be found in a SVN commit: http://llvm.org/viewvc/llvm-project?view=rev&revision=124394
Ah, too fast, sorry. This fix is already included in LLVM 3.0
After further investigating I found that removing -Wall from flags helps in some (not all) cases.
llvm-3.0-10.fc17 has been submitted as an update for Fedora 17. https://admin.fedoraproject.org/updates/llvm-3.0-10.fc17
Package llvm-3.0-10.fc17: * should fix your issue, * was pushed to the Fedora 17 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing llvm-3.0-10.fc17' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2012-4812/llvm-3.0-10.fc17 then log in and leave karma (feedback).
llvm-3.0-10.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.