<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - dwarf5 embed-source does not work with latest clang (8.0.0 trunk)"
href="https://bugs.llvm.org/show_bug.cgi?id=40170">40170</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>dwarf5 embed-source does not work with latest clang (8.0.0 trunk)
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ys114321@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The following is a simple way to reproduce the bug.
-bash-4.4$ cat ttest2.c
#include "ttest.h"
BPF_PERF_OUTPUT2(probe);
int main() { return g; }
-bash-4.4$ cat ttest.h
#define BPF_PERF_OUTPUT2(_name) \
struct _name##_table_t { \
int key; \
unsigned leaf; \
int (*perf_submit) (void *, void *, unsigned); \
int (*perf_submit_skb) (void *, unsigned, void *, unsigned); \
unsigned max_entries; \
}; \
__attribute__((section("maps/perf_output"))) \
struct _name##_table_t _name = { .max_entries = 0 }
int g;
-bash-4.4$ clang -g -O2 -gdwarf-5 -gembed-source -c ttest2.c
inconsistent use of embedded source
fatal error: error in backend: Broken module found, compilation aborted!
clang-8: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
clang version 8.0.0 (trunk 350092) (llvm/trunk 350084)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/yhs/work/llvm/build/install/bin
clang-8: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-8: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-8: note: diagnostic msg: /tmp/ttest2-6c497a.c
clang-8: note: diagnostic msg: /tmp/ttest2-6c497a.sh
clang-8: note: diagnostic msg:
********************
-bash-4.4$
Basically, a simple C file and header file. The C file contains a macro
expansion. Compiling with -g -gdwarf-5 -gembed-source will cause the
compiler complains:
fatal error: error in backend: Broken module found, compilation aborted!
When I tried to root cause the bug described in
<a href="https://reviews.llvm.org/D53329">https://reviews.llvm.org/D53329</a>, I found a simple test case like the above will
break clang.
I did some analysis. The following are rough reason.
1. Looks like for macro in the source code, the clang actually will create a
"FileID" for it. The FileID is not associated with a file. It is actually
associated with a source location range.
2. In my particular example, the macro defines a global variable and the global
variable needs a file.
3. When clang tries to find the FileID based on source location of the global
variable, it found a source expansion FileID which does not have source
associated with it.
4. So clang simply does not have a "source" attribute for the DIFile
corresponding to the global as in (3) it does not have such information.
5. Later on, IR verification complains embed-source is enabled but all not
DIFile has sources, so aborted.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>