Skip to content

compile result is always a wrong file ? #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
QiangYuzhou opened this issue Jul 17, 2019 · 3 comments
Closed

compile result is always a wrong file ? #717

QiangYuzhou opened this issue Jul 17, 2019 · 3 comments

Comments

@QiangYuzhou
Copy link

QiangYuzhou commented Jul 17, 2019

My step:

  1. git clone, nom install, npn link, nom clean.

  2. try to create a new file, which is :

export function add(a: u64, b: u64): u64{
  return a + b;
}
  1. run the command: ./bin/asc ./example/helloworld/helloworld.ts -t outputFile.wat -b outputFile.wasm

  2. The result output.wat is a confusing file with size 55KB:

(module
 (type FUNCSIGiii (func (param i32 i32) (result i32)))
 (type FUNCSIGv (func))
 (type FUNCSIGiiii (func (param i32 i32 i32) (result i32)))
 (type FUNCSIGviiii (func (param i32 i32 i32 i32)))
 (type FUNCSIGvii (func (param i32 i32)))
 (type FUNCSIGii (func (param i32) (result i32)))
 (type FUNCSIGviii (func (param i32 i32 i32)))
 (type FUNCSIGvi (func (param i32)))
 (type FUNCSIGjjj (func (param i64 i64) (result i64)))
 (import "env" "abort" (func ~lib/builtins/abort (param i32 i32 i32 i32)))
 (memory 0 1)
 (data (i32.const 8) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s\00")
 (data (i32.const 56) "(\00\00\00\01\00\00\00\01\00\00\00(\00\00\00a\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e\00")
 (data (i32.const 112) "\1e\00\00\00\01\00\00\00\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00p\00u\00r\00e\00.\00t\00s\00")
 (data (i32.const 160) "\00\00\00\01\00\00\00\01\00\00\00\00\00\00I\00n\00d\00e\00x\00 \00o\00u\00t\00 \00o\00f\00 \00r\00a\00n\00g\00e\00")
 (data (i32.const 216) "\14\00\00\00\01\00\00\00\01\00\00\00\14\00\00\00~\00l\00i\00b\00/\00r\00t\00.\00t\00s\00")
 (data (i32.const 256) "\03\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00")
 (table 0 1 funcref)
 (elem (i32.const 0) null)
...........

3368 lines totally.
There is nothing related to my entry file. And Many things are included such as $~lib/rt/pure/__visit ​$~lib/memory/mempry.copy...

So I try another way:

  1. npx init.

  2. npm run asbuild.
    The entry file is below:

// The entry file of your WebAssembly module.

export function add(a: i32, b: i32): i32 {
  return a + b;
}

And the result is that, the same file created.

I don't know why, and I really appreciate if you could help me!

@dcodeIO
Copy link
Member

dcodeIO commented Jul 17, 2019

Most of the code you are seeing there comes from the inclusion of the AssemblyScript runtime for memory management and GC. Your add function should be somewhere in there as well. If you do not need the runtime, try specifying --runtime none on the command line, which will yield a much smaller module.

@QiangYuzhou
Copy link
Author

Thanks! It really works!

@stale
Copy link

stale bot commented Aug 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 16, 2019
@stale stale bot closed this as completed Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants