-
Notifications
You must be signed in to change notification settings - Fork 8
WASI support #64
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
WASI support #64
Conversation
Fix import object
(even if the code failed during execution)
Your site is deployed at https://lfortran.github.io/pull_request_preview |
cdda16c
to
e44c831
Compare
Your site is deployed at https://lfortran.github.io/pull_request_preview |
I tested the Libasr sync version of |
Please note that the deployment link in #64 (comment) currently shows deployment for the PR #65 (since it was submitted/modified later than this PR). |
Just to be on the safe side, after the PRs are reviewed and approved, shall we merge them into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are good. Yes, let's merge this after the Fortran committee meeting, to ensure nothing breaks. The meeting will be over on Friday, so on Saturday we can merge this. Until then we can just get everything working on a branch.
This uses the latest lfortran where the wasm backend supports/utilizes wasi functions
Your site is deployed at https://lfortran.github.io/pull_request_preview |
This is ready. We can see the preview at https://lfortran.github.io/pull_request_preview.
Sure, got it. I am temporarily marking this as draft. |
@certik please, could you share if the Fortran Committee meet is complete and if we could merge this PR? |
Yes, let's merge this! Go ahead and do it. Then check that everything works afterwards, otherwise you'll need to fix things. |
Yes, checked. The site seems to work. We are facing this issue lfortran/lfortran#658 for the Steps to reproduce:
Output: RuntimeError: memory access out of bounds
ERROR: WAT could not be generated from the code Temporary Workaround:
Output(module (type (;0;) (func (param i32) (result))) (type (;1;) (func (param i32 i32 i32 i32) (result i32))) (type (;2;) (func (param i64) (result))) (type (;3;) (func (param f64) (result))) (type (;4;) (func (param f32 f32) (result f32))) (type (;5;) (func (param f32 f32) (result f32))) (type (;6;) (func (param f32 f32 f32 f32) (result f32))) (type (;7;) (func (param f32 f32 f32 f32) (result f32))) (type (;8;) (func (param f32 f32 f32 f32) (result f32))) (type (;9;) (func (param) (result))) (type (;10;) (func (param) (result))) (import "wasi_snapshot_preview1" "proc_exit" (func (;0;) (type 0))) (import "wasi_snapshot_preview1" "fd_write" (func (;1;) (type 1))) (global $0 i32 (i32.const 0)) (func $2 (type 2) (param i64) (result) (local i64 i64 i64 i64) local.get 0 i64.const 0 i64.eq if i32.const 1 i32.const 52 i32.const 1 i32.const 0 call 1 drop return else end local.get 0 i64.const 0 i64.lt_s if i32.const 1 i32.const 28 i32.const 1 i32.const 0 call 1 drop local.get 0 i64.const -1 i64.mul local.set 0 else end local.get 0 local.set 4 i64.const 0 local.set 1 loop local.get 0 i64.const 0 i64.gt_s if local.get 1 i64.const 1 i64.add local.set 1 local.get 0 i64.const 10 i64.div_s local.set 0 br 1 else end end loop local.get 1 i64.const 0 i64.gt_s if local.get 1 i64.const 1 i64.sub local.set 1 i64.const 1 local.set 2 i64.const 0 local.set 3 loop local.get 3 local.get 1 i64.lt_s if local.get 3 i64.const 1 i64.add local.set 3 local.get 2 i64.const 10 i64.mul local.set 2 br 1 else end end local.get 4 local.get 2 i64.div_s i64.const 10 i64.rem_s i64.const 12 i64.mul i64.const 52 i64.add local.set 0 i32.const 1 local.get 0 i32.wrap_i64 i32.const 1 i32.const 0 call 1 drop br 1 else end end return ) (func $3 (type 3) (param f64) (result) (local i64 i64 i64) local.get 0 f64.const 0.000000 f64.lt if i32.const 1 i32.const 28 i32.const 1 i32.const 0 call 1 drop local.get 0 f64.const -1.000000 f64.mul local.set 0 else end local.get 0 i64.trunc_f64_s call 2 i32.const 1 i32.const 40 i32.const 1 i32.const 0 call 1 drop local.get 0 local.get 0 i64.trunc_f64_s f64.convert_i64_s f64.sub f64.const 100000000.000000 f64.mul i64.trunc_f64_s local.set 2 local.get 2 local.set 3 i64.const 0 local.set 1 loop local.get 2 i64.const 0 i64.gt_s if local.get 1 i64.const 1 i64.add local.set 1 local.get 2 f64.convert_i64_s i64.const 10 f64.convert_i64_s f64.div i64.trunc_f64_s local.set 2 br 1 else end end loop local.get 1 i64.const 8 i64.lt_s if local.get 1 i64.const 1 i64.add local.set 1 i32.const 1 i32.const 52 i32.const 1 i32.const 0 call 1 drop br 1 else end end local.get 3 call 2 return ) (func $4 (type 4) (param f32 f32) (result f32) (local f32) local.get 0 local.get 1 f32.add local.set 2 local.get 2 return ) (func $5 (type 5) (param f32 f32) (result f32) (local f32) local.get 0 local.get 1 f32.div local.set 2 local.get 2 return ) (func $6 (type 6) (param f32 f32 f32 f32) (result f32) (local f32) local.get 0 local.get 2 call 4 local.get 1 local.get 3 call 4 call 5 local.set 4 local.get 4 return ) (func $7 (type 7) (param f32 f32 f32 f32) (result f32) (local f32) local.get 0 local.get 0 local.get 1 call 5 local.get 2 local.get 2 local.get 3 call 5 call 6 local.set 4 local.get 4 return ) (func $8 (type 8) (param f32 f32 f32 f32) (result f32) (local f32) local.get 0 local.get 2 call 4 local.get 1 local.get 3 call 4 call 5 local.set 4 local.get 4 return ) (func $9 (type 9) (param) (result) (local f32 f32) f32.const 1.000000 f32.const 3.000000 f32.const 1.500000 f32.const 4.000000 call 8 local.set 0 f32.const 1.100000 f32.const 0.500000 f32.const 2.000000 f32.const 0.750000 call 7 local.set 1 i32.const 1 i32.const 172 i32.const 1 i32.const 0 call 1 drop i32.const 1 i32.const 4 i32.const 1 i32.const 0 call 1 drop local.get 0 f64.promote_f32 call 3 i32.const 1 i32.const 16 i32.const 1 i32.const 0 call 1 drop i32.const 1 i32.const 184 i32.const 1 i32.const 0 call 1 drop i32.const 1 i32.const 4 i32.const 1 i32.const 0 call 1 drop local.get 1 f64.promote_f32 call 3 i32.const 1 i32.const 16 i32.const 1 i32.const 0 call 1 drop return ) (func $10 (type 10) (param) (result) (local) call 9 i32.const 0 call 0 return ) (memory (;0;) 100 100) (export "memory" (memory 0)) (export "print_i64" (func 2)) (export "print_f64" (func 3)) (export "add_real" (func 4)) (export "slash_real" (func 5)) (export "__asr_generic_avg_s_from_t" (func 6)) (export "avg_real_s_from_s" (func 7)) (export "avg_real_s_from_t" (func 8)) (export "test_template" (func 9)) (export "_start" (func 10)) (data (;0;) (i32.const 4) "\0c\00\00\00\01\00\00\00") (data (;1;) (i32.const 12) " ") (data (;2;) (i32.const 16) "\18\00\00\00\01\00\00\00") (data (;3;) (i32.const 24) "\0a ") (data (;4;) (i32.const 28) "\24\00\00\00\01\00\00\00") (data (;5;) (i32.const 36) "- ") (data (;6;) (i32.const 40) "\30\00\00\00\01\00\00\00") (data (;7;) (i32.const 48) ". ") (data (;8;) (i32.const 52) "\3c\00\00\00\01\00\00\00") (data (;9;) (i32.const 60) "0 ") (data (;10;) (i32.const 64) "\48\00\00\00\01\00\00\00") (data (;11;) (i32.const 72) "1 ") (data (;12;) (i32.const 76) "\54\00\00\00\01\00\00\00") (data (;13;) (i32.const 84) "2 ") (data (;14;) (i32.const 88) "\60\00\00\00\01\00\00\00") (data (;15;) (i32.const 96) "3 ") (data (;16;) (i32.const 100) "\6c\00\00\00\01\00\00\00") (data (;17;) (i32.const 108) "4 ") (data (;18;) (i32.const 112) "\78\00\00\00\01\00\00\00") (data (;19;) (i32.const 120) "5 ") (data (;20;) (i32.const 124) "\84\00\00\00\01\00\00\00") (data (;21;) (i32.const 132) "6 ") (data (;22;) (i32.const 136) "\90\00\00\00\01\00\00\00") (data (;23;) (i32.const 144) "7 ") (data (;24;) (i32.const 148) "\9c\00\00\00\01\00\00\00") (data (;25;) (i32.const 156) "8 ") (data (;26;) (i32.const 160) "\a8\00\00\00\01\00\00\00") (data (;27;) (i32.const 168) "9 ") (data (;28;) (i32.const 172) "\b4\00\00\00\03\00\00\00") (data (;29;) (i32.const 180) "s1= ") (data (;30;) (i32.const 184) "\c0\00\00\00\03\00\00\00") (data (;31;) (i32.const 192) "s2= ") ) |
Please open up an issue for this, so that we don't forget. After doing Command+Shift+R in Firefox, I can now reproduce the issue and workaround. |
No description provided.