Just a demo required for WASM poc
Lyff has been copied and ported to pascal from https://codelabs.developers.google.com/codelabs/web-assembly-intro/index.html
The purpose is a requirement of FPC support for wasm
Just a demo required for WASM poc
Just a demo required for WASM poc
Lyff has been copied and ported to pascal from https://codelabs.developers.google.com/codelabs/web-assembly-intro/index.html
The purpose is a requirement of FPC support for wasm
Hey there! I was checking this out today, and I got the following error:
> ..\fpc-wasm\compiler\ppwasm.exe -a .\lyff\lyff.pas
system.wat:8:13: error: undefined global variable "$__stack_top"
get_global $__stack_top
^^^^^^^^^^^^
system.wat:11:13: error: undefined global variable "$__stack_top"
set_global $__stack_top
^^^^^^^^^^^^
system.pas(19,1) Error: Error while assembling exitcode 1
system.pas(19,1) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
I'm new to Free Pascal, and in fact, just installed it to give this a try. Is there anything I'm doing wrong? I was following https://wiki.freepascal.org/WebAssembly/Compiler. Thanks!
Hi I'm very interested in the potential of this fpc-wasm project and would like to try it.
Would you please help me?
I'm attempting to compile the sample demo but I'm having trouble. Am I doing something wrong?
C:\wasm-demo>ppwasm -Us -a system.pas
C:\wasm-demo>cd lyff
C:\wasm-demo\lyff>ppwasm -a lyff.pas -Fu..\
wasm-ld C:\wasm-demo\system.o lyff.o -o lyff --export-dynamic --no-entry --allow-undefined
wasm-ld: error: lyff.o: Duplicate symbol name
lyff.pas(168,1) Error: Error while linking
lyff.pas(168,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
I have tried extending system.pas
with the beginnings of an AllocMem
function:
unit system;
interface
type
integer = longint;
hresult = integer;
ttypekind = integer;
filerec = integer;
textrec = integer;
pbyte = ^byte;
PtrUInt = QWord;
procedure fpc_lib_exit; compilerproc;
function AllocMem(Size:ptruint):pointer;
implementation
procedure fpc_lib_exit; compilerproc;
begin
end;
function AllocMem(Size:ptruint):pointer;
begin
AllocMem := nil;
end;
end.
This results in the following compilation error:
Free Pascal Compiler version 3.3.1 [2020/01/12] for wasm
Copyright (c) 1993-2019 by Florian Klaempfl and others
Target OS: WebAssembly
Compiling lyff/lyff.pas
Compiling system.pas
Assembling system
system.wat:31:2: error: unexpected token <none>, expected ).
<none>
^^^^^^
system.pas(32,1) Error: Error while assembling exitcode 1
system.pas(32,1) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
The system.wat
output file is:
(module
(import "env" "memory" (memory 0)) ;;
(global $__stack_top (mut i32) (i32.const 262144))
;; constant
;; constant
(func $fpc_lib_exit
(local $fp i32)
(local $bp i32)
get_global $__stack_top
set_local $bp
get_local $bp
set_global $__stack_top
return
)
(func $SYSTEM_$$_ALLOCMEM$QWORD$$POINTER
(param i64)
(result i32)
(local i32)
(local i32)
(local $fp i32)
(local $bp i32)
get_global $__stack_top
set_local $bp
get_local $bp
i32.const 4
i32.sub
set_local $fp
get_local $fp
set_global $__stack_top
<none>
set_local 2
get_local 2
set_local 1
get_local 1
get_local $bp
set_global $__stack_top
return
)
(table 0 funcref) (elem 0 (i32.const 0)
$fpc_lib_exit
$SYSTEM_$$_ALLOCMEM$QWORD$$POINTER
)
)
Can a cpu.opcode
of 0
be skipped or does that indicate that something else has gone wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.