Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Script to transform C++ code to webassembly is not terminating #8

Open
VerifierIntegerAssignment opened this issue Jul 6, 2020 · 0 comments

Comments

@VerifierIntegerAssignment

I want to compile a CPP file to web assembly. I am using scripts in the following link

https://github.com/wasdk/wasmexplorer-service/tree/master/scripts

I am using the following command in my Linux OS

../scripts/compile2.sh ../test.cpp "-fno-verbose-asm -03 -std=c++98" 2>&1

The command never terminates. I have tried all combinations of options. Can anyone guide me in this regard? Or any other way to transform C++ code to respective web assembly code (help me design a stand-alone application ).

Content of the file is as follows:

double fact(int i) {
long long n = 1;
for (;i > 0; i--) {
n *= i;
}
return (double)n;
}

My expected output is as following (is from https://mbebenita.github.io/WasmExplorer/)

(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "_Z4facti" (func $_Z4facti))
(func $_Z4facti (; 0 ;) (param $0 i32) (result f64)
(local $1 i64)
(local $2 i64)
(block $label$0
(br_if $label$0
(i32.lt_s
(get_local $0)
(i32.const 1)
)
)
(set_local $1
(i64.add
(i64.extend_s/i32
(get_local $0)
)
(i64.const 1)
)
)
(set_local $2
(i64.const 1)
)
(loop $label$1
(set_local $2
(i64.mul
(get_local $2)
(tee_local $1
(i64.add
(get_local $1)
(i64.const -1)
)
)
)
)
(br_if $label$1
(i64.gt_s
(get_local $1)
(i64.const 1)
)
)
)
(return
(f64.convert_s/i64
(get_local $2)
)
)
)
(f64.const 1)
)
)

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

No branches or pull requests

1 participant