-
Couldn't load subscription status.
- Fork 15k
Description
Context
This is a part of the effort on running clang-repl in the browser. Check xeus-cpp-lite
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 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
llvm-project/lld/wasm/Writer.cpp
Lines 1075 to 1080 in e7365d3
| void Writer::combineOutputSegments() { | |
| // With PIC code we currently only support a single active data segment since | |
| // we only have a single __memory_base to use as our base address. This pass | |
| // combines all data segments into a single .data segment. | |
| // This restriction does not apply when the extended const extension is | |
| // available: https://github.com/WebAssembly/extended-const |
But then as we are using --emit-relocs, we end up calling LinkingSection::writeBody() after finalizeSections
And here we have the following
llvm-project/lld/wasm/SyntheticSections.cpp
Lines 738 to 741 in f0bdeb4
| #ifndef NDEBUG | |
| for (const InputChunk *isec : inputSegments) | |
| assert(isec->getComdatName() == comdat); | |
| #endif |
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.