[llvm-bugs] [Bug 40170] New: dwarf5 embed-source does not work with latest clang (8.0.0 trunk)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 27 23:30:12 PST 2018


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

            Bug ID: 40170
           Summary: dwarf5 embed-source does not work with latest clang
                    (8.0.0 trunk)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ys114321 at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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
https://bugs.llvm.org/ 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
https://reviews.llvm.org/D53329, 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181228/a9826150/attachment.html>


More information about the llvm-bugs mailing list