[fpc-devel] Wasm/embedded target compilation error

Kostas Michalopoulos badsector at runtimeterror.com
Fri Jul 22 00:36:55 CEST 2022


Hi all,

I was trying to use the Wasm/embedded target to port a game i made some 
time ago[0] to WebAssembly to run inside a browser, but i am getting a 
bunch of errors that i can't figure out the issue. When compiling with 
the embedded wasm assembler i get errors like:


SndEmit.pas(171) Error: Wasm32 symbol 
RESMAN/home/badsector/.local/bin/fpcTRESOURCEMANAGER_$__$$_GETRESOURCE$ANSISTRING$$TRESOURCE 
without index value error
SndEmit.pas(171) Error: Wasm32 symbol 
SNDDRV/home/badsector/.local/bin/fpcTSOUNDDRIVER_$__$$_SETCHANNELCLIP$LONGINT$TSOUNDCLIP$BYTE 
without index value error
(more errors)


However i'm not sure if it is the internal assembler issue because 
using, e.g. llvm-mc-12 i get other errors like:


./Engine/Misc.wat:7340:3: error: symbol 
MISC$_$TSTRINGKEYVALUESET_$__$$_INDEXOFKEY$ANSISTRING$$LONGINT missing 
.functype
                 call 
MISC$_$TSTRINGKEYVALUESET_$__$$_INDEXOFKEY$ANSISTRING$$LONGINT
                 ^
./Engine/Misc.wat:7670:3: error: symbol 
MISC$_$TSTRINGKEYVALUESET_$__$$_INDEXOFKEY$ANSISTRING$$LONGINT missing 
.functype
                 call 
MISC$_$TSTRINGKEYVALUESET_$__$$_INDEXOFKEY$ANSISTRING$$LONGINT


Trying other assemblers i get other errors too, e.g. wabt/wasa displays 
a bunch of "stream read error" messages and then fails to link.

Does anyone have any idea about what is wrong?

This is running on Linux with a custom built crosscompiler from latest 
git (last commit is 6915cd9b269649ca945a4fc952ee7dedb1b38b85 - Thu Jul 
21 14:01:50).

I've stripped out the game's sources to only contain the units that i 
try to compile, you can get it and try to reproduce the issue from here 
(the archive is ~660KB):

http://runtimeterror.com/pages/badsector/nyan/gimme/papwasm.tar.xz

Just type ./makewasm.sh (the script uses -Awasm here but can be changed 
to try other assemblers). Note that obviously this wont build since it 
is missing any wasm-specific functionality since i never got to the 
point where the "cross platform" units compile properly to start writing 
the wasm-specific stuff.

Kostas

[0] https://bad-sector.itch.io/post-apocalyptic-petra


More information about the fpc-devel mailing list