Giter Club home page Giter Club logo

wasm-demo's Introduction

wasm-demo's People

Contributors

skalogryz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wasm-demo's Issues

error: undefined global variable "$__stack_top"

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!

wasm-ld: error: lyff.o: Duplicate symbol name

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

error: unexpected token <none>, expected )

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?

https://github.com/skalogryz/freepascal/blob/5e9a77b04b54e059375fedcb75b8eb3e34aba695/compiler/wasm/agwat.pas#L245

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.