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
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
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
.