Skip to content
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

rpython main.py throw #1

Open
kernel1983 opened this issue Nov 5, 2021 · 7 comments
Open

rpython main.py throw #1

kernel1983 opened this issue Nov 5, 2021 · 7 comments

Comments

@kernel1983
Copy link

Hi, I was excited to find this project. I can't wait to give a try. And I meet the following error

emcc: warning: linker setting ignored during compilation: 'WASM' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'ALLOW_MEMORY_GROWTH' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXPORTED_FUNCTIONS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXTRA_EXPORTED_RUNTIME_METHODS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'WASM' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'ALLOW_MEMORY_GROWTH' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXPORTED_FUNCTIONS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXTRA_EXPORTED_RUNTIME_METHODS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'WASM' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'ALLOW_MEMORY_GROWTH' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXPORTED_FUNCTIONS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXTRA_EXPORTED_RUNTIME_METHODS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'WASM' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'ALLOW_MEMORY_GROWTH' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXPORTED_FUNCTIONS' [-Wunused-command-line-argument]
emcc: warning: linker setting ignored during compilation: 'EXTRA_EXPORTED_RUNTIME_METHODS' [-Wunused-command-line-argument]
emcc -s WASM=0 -s ALLOW_MEMORY_GROWTH=1 -s 'EXPORTED_FUNCTIONS=["_main", "_malloc", "_onresolve", "_onfunctioncall"]' -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall"]'   -o main.js testing_1.o data_rpython_flowspace.o data_rpython_memory_gctransform.o data_rpython_rlib.o data_rpython_rtyper_lltypesystem.o data_rpython_translator_c.o nonfuncnodes.o implement.o rpython_flowspace.o rpython_memory_gctransform.o rpython_rlib.o rpython_rtyper.o rpython_rtyper_lltypesystem.o rpython_translator.o rpython_translator_c.o thread.o entrypoint.o mem.o exception.o rtyper.o support.o profiling.o debug_print.o debug_traceback.o asm.o instrument.o int.o stack.o threadlocal.o ../module_cache/module_0.o  -lrt  -Wl,--export-dynamic
emcc: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
emcc: error: undefined exported symbol: "_onfunctioncall" [-Wundefined] [-Werror]
make: *** [Makefile:104: main.js] Error 1
child_process.js:655
    throw err;
    ^

Error: Command failed: make -j 4
    at checkExecSyncError (child_process.js:616:11)
    at Object.execSync (child_process.js:652:15)
    at Object.<anonymous> (/home/ubuntu/rpython/bin/compile.js:108:17)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  status: 2,
  signal: null,
  output: [ null, null, null ],
  pid: 1042169,
  stdout: null,
  stderr: null
}

Any idea?

@rafi16jan
Copy link
Collaborator

rafi16jan commented Nov 5, 2021

Hmm I know what this is.. This usually happens when your main.py doesn't call to any javascript APIs (import javascript). Try to import javascript and call javascript.Object('console')['log'].call('hello world') on your main function, and please attach or paste your main.py file so I can reproduce the error that occurs

@rafi16jan
Copy link
Collaborator

And I think, I need to update my example main.py from the README. Either that or I need to fix it to enable programs that don't interface to javascript (which doesn't serve a purpose but at least it will clear the confusion)

@kernel1983
Copy link
Author

I solved this by removing "_onresolve", "_onfunctioncall" from

EXPORTED_FUNCTIONS=["_main", "_malloc", "_onresolve", "_onfunctioncall"]

@rafi16jan
Copy link
Collaborator

I solved this by removing "_onresolve", "_onfunctioncall" from

EXPORTED_FUNCTIONS=["_main", "_malloc", "_onresolve", "_onfunctioncall"]

That was a pretty bad idea... onfunctioncall is for @function decorator and onresolve is for @asynchronous decorator, without it you can't interface to javascript API except with writing your own exported functions...

@kernel1983
Copy link
Author

Sure, just wait for the correct solution here.

@kernel1983
Copy link
Author

Is it possible to generate a standalone wasm file that can be loaded by something like pywasm?

@rafi16jan
Copy link
Collaborator

rafi16jan commented Nov 6, 2021

Is it possible to generate a standalone wasm file that can be loaded by something like pywasm?

It is not possible, currently what this fork does is replacing gcc with emcc on RPython's program C source compiling phase. So it generally depends on all the emscripten glue code, hence I name the implementation emscripten.py on the javascript directory. Maybe in the future when there's another alternative that replace cc like emcc does, that uses WASI (so it will run on any webassembly runtime, not just browsers and node.js) I will add that to this fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants