[cfe-dev] clang++ compilation error on adding debug flag

Shehbaz Jaffer via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 31 09:57:43 PDT 2016


Hi,

Short version --> adding debug flags leads to clang++ error (shown
below). without adding debug flags, compilation is successful.

Longer version-->

I am doing the follwing things in my project in order to debug it:

1. Compiling an llvm code pass.cpp with clang++ -ggdb that consists of
some optimization passes on my test.c file - I create an so file from
this - called pass.so.

2. I create a .bc file of the optimization pass - using clang++
-emit-llvm. lets call it pass.bc.

3. Compiling and creating an executable of my my test.c file, with -g
flag - lets call it test

4. Creating a .bc of my test.c file - lets call it test.bc

5. running some optimization passes on my test.bc file, with the
test.so file created in step 1. let us call the output file
test.inst.bc

6. linking the optimized test.inst.bc file in step 4 with the llvm .bc
file generated in step 1. Let us call it  test.inst2.bc

7. finally compiling the linked file using clang++ -c test.inst2.bc.

I get the following error :

clang-3.6: /home/shehbaz/courses/ece1781/project/fslice/llvm/lib/CodeGen/LexicalScopes.cpp:179:
llvm::LexicalScope*
llvm::LexicalScopes::getOrCreateRegularScope(llvm::MDNode*): Assertion
`DISubprogram(Scope).describes(MF->getFunction())' failed.
0  clang-3.6       0x00000000024cb8c4 llvm::sys::PrintStackTrace(_IO_FILE*) + 53
1  clang-3.6       0x00000000024cbb6e
2  clang-3.6       0x00000000024ca661
3  libpthread.so.0 0x00007fa7bd39ad10
4  libc.so.6       0x00007fa7bc5ad267 gsignal + 55
5  libc.so.6       0x00007fa7bc5aeeca abort + 362
6  libc.so.6       0x00007fa7bc5a603d
7  libc.so.6       0x00007fa7bc5a60f2
8  clang-3.6       0x0000000001f89b97
llvm::LexicalScopes::getOrCreateRegularScope(llvm::MDNode*) + 703
9  clang-3.6       0x0000000001f890e9
llvm::LexicalScopes::getOrCreateLexicalScope(llvm::DebugLoc) + 191
10 clang-3.6       0x0000000001f88adf
llvm::LexicalScopes::extractLexicalScopes(llvm::SmallVectorImpl<std::pair<llvm::MachineInstr
const*, llvm::MachineInstr const*> >&,
llvm::DenseMap<llvm::MachineInstr const*, llvm::LexicalScope*,
llvm::DenseMapInfo<llvm::MachineInstr const*>,
llvm::detail::DenseMapPair<llvm::MachineInstr const*,
llvm::LexicalScope*> >&) + 459
11 clang-3.6       0x0000000001f88899
llvm::LexicalScopes::initialize(llvm::MachineFunction const&) + 127
12 clang-3.6       0x000000000282c753
llvm::DwarfDebug::beginFunction(llvm::MachineFunction const*) + 257
13 clang-3.6       0x0000000002812cf3
llvm::AsmPrinter::EmitFunctionHeader() + 1099
14 clang-3.6       0x00000000019b5123
15 clang-3.6       0x0000000001dd0473
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95
16 clang-3.6       0x00000000020e0def
llvm::FPPassManager::runOnFunction(llvm::Function&) + 305
17 clang-3.6       0x00000000020e0f81
llvm::FPPassManager::runOnModule(llvm::Module&) + 99
18 clang-3.6       0x00000000020e12c3
19 clang-3.6       0x00000000020e1986
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 250
20 clang-3.6       0x00000000020e1ba7
llvm::legacy::PassManager::run(llvm::Module&) + 39
21 clang-3.6       0x0000000002a6da1c
22 clang-3.6       0x0000000002a6db2d
clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&,
clang::LangOptions const&, llvm::StringRef, llvm::Module*,
clang::BackendAction, llvm::raw_ostream*) + 173
23 clang-3.6       0x0000000002a541a4
clang::CodeGenAction::ExecuteAction() + 1408
24 clang-3.6       0x00000000026e4be4 clang::FrontendAction::Execute() + 154
25 clang-3.6       0x00000000026ab864
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 788
26 clang-3.6       0x000000000280a257
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1072
27 clang-3.6       0x000000000125833e cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 776
28 clang-3.6       0x000000000125022f
29 clang-3.6       0x0000000001250852 main + 1082
30 libc.so.6       0x00007fa7bc598a40 __libc_start_main + 240
31 clang-3.6       0x000000000124cec9 _start + 41
Stack dump:
0. Program arguments:
/home/shehbaz/courses/ece1781/project/fslice/llvm/build/bin/clang-3.6
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all
-disable-free -main-file-name testfs.opt.bc -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 -coverage-file
/home/shehbaz/courses/ece1781/project/fslice/./testfs/testfs.opt.o
-resource-dir /home/shehbaz/courses/ece1781/project/fslice/llvm/build/bin/../lib/clang/3.6.2
-fdebug-compilation-dir /home/shehbaz/courses/ece1781/project/fslice
-ferror-limit 19 -fmessage-length 181 -mstackrealign
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o
./testfs/testfs.opt.o -x ir ./testfs/testfs.opt.bc
1. Code generation
2. Running pass 'Function Pass Manager' on module './testfs/testfs.opt.bc'.
3. Running pass 'X86 Assembly / Object Emitter' on function '@main'
clang-3.6: error: unable to execute command: Aborted (core dumped)
clang-3.6: error: clang frontend command failed due to signal (use -v
to see invocation)
clang version 3.6.2 (tags/RELEASE_362/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang-3.6: 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.6: note: diagnostic msg: Error generating preprocessed
source(s) - no preprocessable inputs.


Note that the program runs perfectly fine, if I do not add the debug symbols in

step 1 (-ggdb)
step 3 ( -g) <--- having this or running program without it does not
cause issues
step 7 (-ggdb)

Please let me know if there is another way to debug the code. I wish
to use gdb, not lldb, hence the -ggdb flag. If I use -g flag, that
also reports the same error while compiling the code. I looked up the
error message and it seems there is some other cause for the same
error trace:

https://llvm.org/bugs/show_bug.cgi?id=22051

Thank you,
Shehbaz



More information about the cfe-dev mailing list