Issue |
134809
|
Summary |
[wasm-ld] Inconsistency: combineOutputSegments() merges InputChunks with differing COMDATs, but writeBody() asserts
|
Labels |
new issue
|
Assignees |
|
Reporter |
anutosh491
|
**Context**
This is a part of the effort on running clang-repl in the browser. Check [xeus-cpp-lite](https://compiler-research.org/xeus-cpp/lab/index.html)
In a cell block, I am trying to process multiple c++ definitions
```
const int var0 = 0; // generates .rodata._ZL4var0
const C cvar0{0}; // generates .rodata._ZL5cvar0, in a different COMDAT
```
As a final part we have a [linking step](https://github.com/llvm/llvm-project/blob/main/clang/lib/Interpreter/Wasm.cpp#L114) that produces the side module (incr_module_xx.wasm for each cell that is processed)
**Problem :**
Basically I end up with a situation where we're using wasm-ld to execute a linking process (with `--emit-relocs` being provided as a flag)
Now what I see is when `createOutputSegments` is run we end up with inputchunks with 3 different comdats (`_ZL4var0`, `_ZL5cvar0` or `empty`)
And when we run CombineOutputSegments, I see segments having inputchunks with different comdats being combined without any assert or error raised
I am guessing this is justified because
https://github.com/llvm/llvm-project/blob/e7365d3143d762c290c426b172f588756b6f1ef8/lld/wasm/Writer.cpp#L1075-L1080
But then as we are using --emit-relocs, we end up calling `LinkingSection::writeBody()` after `finalizeSections`
And here we have the following
https://github.com/llvm/llvm-project/blob/f0bdeb4b6aa1ee0653aed8323a5a7485fb930a05/lld/wasm/SyntheticSections.cpp#L738-L741
Hence I end up with this error
```
Aborted(Assertion failed: isec->getComdatName() == comdat, at: /Users/anutosh491/work/llvm-project/lld/wasm/SyntheticSections.cpp,747,writeBody)
```
while trying to run expressions with `const` in xeus-cpp-lite
**Disclaimer**
i) I see this happens only when we have `#ifndef NDEBUG` and I'm building llvm with `MinSizeRel`. Probably I wouldn't have encountered this with `Release`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs