Hi,
I have a C++ library that
compiles some code on the fly using an ORC JIT and it all works fine when my library is built for
X86 or
AArch64, but not when it is built for
wasm32Ā (usingĀ
wasm32-unknown-unknown-elf as the target triple). ForĀ
wasm32, it looks like the code gets compiled but I can't
look up its symbolsĀ and therefore can't run that code.
In my browserās console, I am getting:
libopencor.js:8 >>> Compiler::function("initialiseVariables")
libopencor.js:8 Ā Ā Ā - Looking up 'initialiseVariables'...
libopencor.js:8 LLVM ERROR: section already has a defining function: .text.initialiseVariables
put_char @ libopencor.js:8
libopencor.js:8 Aborted()
abort @ libopencor.js:8
libopencor.js:8 Uncaught (in promise) RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
Ā Ā at abort (libopencor.js:8:6013)
Ā Ā at _abort (libopencor.js:8:133020)
Ā Ā at libopencor.wasm:0x16693f
Ā Ā at libopencor.wasm:0x2589f4e
Ā Ā at libopencor.wasm:0xd66725
Ā Ā at libopencor.wasm:0x25782f9
Ā Ā at libopencor.wasm:0x1c426bf
Ā Ā at libopencor.wasm:0x25c0cce
Ā Ā at libopencor.wasm:0x296f2b6
Ā Ā at libopencor.wasm:0x9d071b
I imagine that I must be doing something wrong (when compiling to wasm32), but I canāt tell what it is. I tried to google for some sample code that does what I am after, but to no avail.
FWIW, the
wasm32 version of my library is built using Emscripten to
generate an ES6 module (using
EXPORT_ES6), making it possible to use my library from both Node.js and from a Web browser. It all works fine, except for the fact that I cannot look up symbols and therefore run code that was compiled on the fly.
So, would anyone have any idea of what I might be doing wrong? The fact that I am able to do what I want when targetingĀ X86Ā orĀ AArch64Ā tells me that I should be able to do the same when targeting wasm32...?
Cheers, Alan.