<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61719>61719</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[WebAssembly] Debug info is not supported for TLS+PIC+split DWARF
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:WebAssembly,
debuginfo
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
aheejin
</td>
</tr>
</table>
<pre>
https://github.com/llvm/llvm-project/commit/e1f830bde8bad22d375bc92f2084e9055059cc77 Fixes debug info for TLS and dynamic linking, but currently the support in split DWARF is limited.
Split DWARF files cannot have relocations, so we cannot encode symbol relocations in there. The spec does not guarantee any specific index for any globals, but in practice, we create them in a fixed order: https://github.com/llvm/llvm-project/blob/19afbfe33156d211fa959dadeea46cd17b9c723c/lld/wasm/Driver.cpp#L786-L823
So for split DWARF, we hardcode indices for these globals. In our current implementation,
- `__stack_pointer` has always index 0.
- `__memory_base` has, if present (i.e., in PIC mode), index 1.
- `__tls_base` is, if present (i.e. in shared memory mode), in non-PIC mode, index 1. In PIC mode, `__tls_base` comes after other imported globals, so its index can be any number.
Currently TLS variables' debug info is not supported when compiled with PIC relocation model and split DWARF In `llc`, the option would be `-mattr=+bulk-memory,atomics -relocation-model=pic -split-dwarf-file=[....dwo] -split-dwarf-output=[....dwo]`
We currently hardcode `__tls_base` to be 1 in split DWARF, making at least work for non-PIC code: https://github.com/llvm/llvm-project/blob/6cef325481a8efc039ae9df5630609fd3a84560c/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L282-L287
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVc1u2zoTfRp6M7AgUdbfwgvHhj8EyKL42osugyE5sthQpEBScf32F5TjxGlxL1DcTX5GwzlnzswhMQR9skRbVj2w6rDCOQ7Ob3Eg-qHtSjh12Q4xToGVO8aPjB9POg6zyKQbGT8a83r7tZ68-0EyMn6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