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

Can't reproduce the builds from https://wasdk.github.io/WasmFiddle #3

Closed
fabien-h opened this issue May 31, 2017 · 4 comments
Closed

Comments

@fabien-h
Copy link

This code

int fib(int n) {
  if(n<0)
	return -1;
  else if (n==0)
	return 0;
  else if (n==1)
	return 1;
  else if (n>1)
	return fib(n-1) + fib(n-2);
	return 0;
}

In the WasmFiddle return this functioning wasm :

0061 736d 0100 0000 0186 8080 8000 0160
017f 017f 0382 8080 8000 0100 0484 8080
8000 0170 0000 0583 8080 8000 0100 0106
8180 8080 0000 0790 8080 8000 0206 6d65
6d6f 7279 0200 0366 6962 0000 0ac3 8080
8000 01bd 8080 8000 0101 7f41 0021 0102
4002 4020 0041 0048 0d00 0240 2000 450d
0041 0121 0120 0041 0147 0d02 0b20 010f
0b41 7f0f 0b20 0041 7f6a 1000 2000 417e
6a10 006a 0b

This does a perfect job.

wasdk ez hello.c -o hello.js

returns :

INFO:root:generating system asset: is_vanilla.txt... (this will be cached in "/Users/fabien/.emscripten_cache/is_vanilla.txt" for subsequent builds)
INFO:root: - ok
WARNING:root:(Emscripten: settings file has changed, clearing cache)
INFO:root:(Emscripten: Running sanity checks)
WARNING:root:Assigning a non-existent settings attribute "BINARYEN_IMPRECISE"
WARNING:root: - did you mean one of BINARYEN_PASSES, BINARYEN_METHOD, BINARYEN_MEM_MAX?
WARNING:root: - perhaps a typo in emcc's  -s X=Y  notation?
WARNING:root: - (see src/settings.js for valid values)

( I understand that it looks like the issue you closed, but I have no error, just a result that is not working properly)

And produces this code :

0061 736d 0100 0000 000c 0664 796c 696e
6b80 80c0 0200 0189 8080 8000 0260 017f
017f 6000 0002 c180 8080 0004 0365 6e76
0a6d 656d 6f72 7942 6173 6503 7f00 0365
6e76 066d 656d 6f72 7902 0080 0203 656e
7605 7461 626c 6501 7000 0003 656e 7609
7461 626c 6542 6173 6503 7f00 0384 8080
8000 0300 0101 068b 8080 8000 027f 0141
000b 7f01 4100 0b07 ab80 8080 0003 125f
5f70 6f73 745f 696e 7374 616e 7469 6174
6500 020b 7275 6e50 6f73 7453 6574 7300
0104 5f66 6962 0000 0981 8080 8000 000a
f180 8080 0003 c980 8080 0001 017f 027f
0240 2000 4100 4804 4041 7f21 0005 0240
0240 0240 2000 0e02 0001 020b 4100 2100
0c03 0b41 0121 000c 020b 2000 417f 6a10
0021 0120 0041 7e6a 1000 2001 6a0f 0b0b
2000 0b0b 8380 8080 0000 010b 9580 8080
0000 0240 2300 2402 2302 4180 80c0 026a
2403 1001 0b0b

So, I tried to write a configuration file :

{
    "compilerOptions": {
    },
    "output": "hello.wasm",
    "files": [
        "hello.c"
    ],
    "options": {
        "ALLOW_MEMORY_GROWTH": 0,
        "RELOCATABLE": 1,
        "SIDE_MODULE": 1,
        "EXPORTED_RUNTIME_METHODS": [],
        "EXPORTED_FUNCTIONS": [],
        "VERBOSE": 1
    }
}

If I understand correctly, I need "SIDE_MODULE": 1, to generate only the small module. But it is not compatible with ALLOW_MEMORY_GROWTH.

It return those warnings :

WARNING:root:Assigning a non-existent settings attribute "BINARYEN_IMPRECISE"
WARNING:root: - did you mean one of BINARYEN_PASSES, BINARYEN_METHOD, BINARYEN_MEM_MAX?
WARNING:root: - perhaps a typo in emcc's  -s X=Y  notation?
WARNING:root: - (see src/settings.js for valid values)
VERBOSE is on, this generates a lot of output and can slow down compilation

I don't understand the first one since I did set it. Doesn't it goes into the compilerOptions ? The options are the ones from https://github.com/kripken/emscripten/blob/master/src/settings.js right ?

Then I realised by reading the source https://github.com/wasdk/wasdk/blob/master/src/wasdk.ts that only a few of those elements are possible. And that "BINARYEN_IMPRECISE=1" is a default.

In short : I'm a bit lost.

I know this may seems lazy but : what's the correct command to reproduce the WasmFiddle code ? (and how to set the language target to C++14 and the optimisations to "s" ?)

That would be awesome to have a documentation about it.

@yurydelendik
Copy link
Collaborator

WasmFiddle is using https://github.com/wasdk/wasmexplorer-service/ , we did not switch to use wasdk yet.

@fabien-h
Copy link
Author

Ok. Thank you.

Do you think this compilation is doable with wasdk? If not I'll shamelessly copy the process in the current service for the fiddle.

@yurydelendik
Copy link
Collaborator

yurydelendik commented May 31, 2017

Both methods have some advantages and disadvantages. I hoped LLVM tools will reach emscripten functionally sooner, but atm plans are to use emscripten. If you like what llvm+binaryen tools produce, take existing service process.

@fabien-h
Copy link
Author

Ok, thank you for your answer.

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