poorna2152 / nballerina

WebAssembly Backend for the nBallerina compiler
https://ballerina.io/
Apache License 2.0
4 stars 0 forks source link

Implement Floats #40

Closed poorna2152 closed 2 years ago

poorna2152 commented 2 years ago
(module 
 (import "console" "log" (func $println (param f64)))  
 (export "main" (func $main)) 
  (func $main 
    (local $0 f64) 
    (local.set $0 
      (f64.const 0.1)) 
    (call $println 
      (local.get $0))))

When compiling this using the Binaryen Windows release the output is 0.1. But when Binaryen Linux release is used in WSL for compiling this the output is 0.09999999999999432. But the same Binaryen Linux release on Ubuntu gives 0.1.

poorna2152 commented 2 years ago

As a solution I'm proposing to run use the windows release when using WSL. Using the following script to check if in WSL. If so append .exe to the Binaryen file. source: https://stackoverflow.com/questions/60922620/shell-script-to-check-if-running-in-windows-when-using-wsl

if [ $(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ];
then
    echo `find $HOME -name "wasm-opt.exe" | grep -m 1 .*/binaryen.*/bin/wasm-opt`
else
    echo `find $HOME -name "wasm-opt" | grep -m 1 .*/binaryen.*/bin/wasm-opt`
fi