Giter VIP home page Giter VIP logo

mono-wasm's Introduction

mono-wasm

This project is a proof-of-concept aiming at building C# applications into WebAssembly, by using Mono and compiling/linking everything statically into one .wasm file that can be easily delivered to browsers.

The process does not use Emscripten (or Binaryen) but instead uses the experimental WebAssembly backend of LLVM with clang and lld to generate the final .wasm code. The goal is to use as few dependencies as possible. At the moment the only dependencies are LLVM, clang and lld trunk.

mono-wasm supports 2 build modes: one that links all the LLVM bitcode into one module then performs a WebAssembly codegen on it, and one that compiles project dependencies into WebAssembly incrementally (the runtime and the mscorlib assembly) then uses lld to link into a final .wasm file. The later is experimental but will become the default as it allows build times lesser than a second.

The .wasm file is loaded from JavaScript (see index.js), which also exposes proper callbacks for system calls that the C library will be calling into. These syscalls are responsible for heap management, I/O, etc.

This project is a work in progress. Feel free to ping me if you have questions or feedback: [email protected]

Related repositories

  • mono-wasm-mono: a fork of Mono with changes for a wasm32 target, used to build the runtime and compiler.
  • mono-wasm-libc: a fork of the WebAssembly/musl C library with tweaks for our version of Mono and our JS glue.

Current status

This is a work in progress, but you can see sample/hello/hello.cs running here: www.hipbyte.com/~lrz/mono-wasm-hello

Binary releases

Binary releases are avalable here (for testing only): https://github.com/lrz/mono-wasm/releases

How does it work?

An ASCII graph is worth a thousand words:

+----------------+-------------+  +---------------------+
|  Mono runtime  |  C library  |  |    C# assemblies    | <-------+
+----------------+-------------+  +----------+----------+         |
           clang |                           | mono               |
  -target=wasm32 |                           | -aot=llvmonly      |
                 v                           v                    |
+-------------------------------------------------------+         | load
|                       LLVM bitcode                    |         | metadata
+----------------------------+--------------------------+         | (runtime)
                             | mono-wasm                          |
                             | (bitcode -> wasm)                  | 
                             v                                    | 
+-------------------------------------------------------+         |
|                        index.wasm                     |---------+
+----------------------------------------+--------------+               
                 ^                       | libc                         
   load, compile |                       | syscalls                     
    + run main() |                       v                             
+----------------+--------------------------------------+         +-----------+ 
|                         index.js                      | <-----> |  Browser  |
+-------------------------------------------------------+         +-----------+

Build instructions

We will assume that you want to build everything in the ~/src/mono-wasm directory.

$ mkdir ~/src/mono-wasm
$ cd ~/src/mono-wasm
$ git clone [email protected]:lrz/mono-wasm.git build

LLVM+clang+lld with WebAssembly target

We need a copy of the LLVM tooling (clang and lld included) with the experimental WebAssembly target enabled. Make sure to build a Release build (as indicated below) otherwise the WASM codegen will be significantly slower.

$ cd ~/src/mono-wasm
$ svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
$ cd llvm/tools
$ svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
$ svn co http://llvm.org/svn/llvm-project/lld/trunk lld
$ cd ../..
$ mkdir llvm-build
$ cd llvm-build
$ cmake -G "Unix Makefiles" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../llvm
$ make

After you did this you should have the LLVM static libraries for the WebAssembly target:

$ ls ~/src/mono-wasm/llvm-build/lib | grep WebAssembly
libLLVMWebAssemblyAsmPrinter.a
libLLVMWebAssemblyCodeGen.a
libLLVMWebAssemblyDesc.a
libLLVMWebAssemblyDisassembler.a
libLLVMWebAssemblyInfo.a

You should also have the ~/src/mono-wasm/llvm-build/bin/clang program built with the wasm32 target:

$ ~/src/mono-wasm/llvm-build/bin/clang --version
clang version 5.0.0 (trunk 306818)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Users/lrz/src/mono-wasm/llvm-build/bin

  Registered Targets:
[...]
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit

You should also have the wasm lld (linker) library:

$ ls ~/src/mono-wasm/llvm-build/lib/liblldWasm.a
/Users/lrz/src/mono-wasm/llvm-build/lib/liblldWasm.a

Mono compiler

We need a build a copy of the Mono compiler that we will use to generate LLVM bitcode from assemblies. We are building this for 32-bit Intel (i386) because the Mono compiler assumes way too many things from the host environment when generating the bitcode, so we want to match the target architecture (which is also 32-bit).

First, you need to build a copy of the Mono fork of LLVM. We are building it for both 32-bit and 64-bit Intel so that we can easily switch the Mono compiler back to 64-bit later, and we manually have to copy the headers to the build directory as the Mono build system doesn't support external LLVM builds.

$ cd ~/src/mono-wasm
$ git clone [email protected]:mono/llvm.git llvm-mono
$ mkdir llvm-mono-build
$ cd llvm-mono-build
$ cmake -G "Unix Makefiles" -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" ../llvm-mono
$ ditto ../llvm-mono/include include
$ make

Now, we can now build the Mono compiler itself.

$ cd ~/src/mono-wasm
$ git clone [email protected]:lrz/mono-wasm-mono.git mono-compiler
$ cd mono-compiler
$ ./autogen.sh --host=i386-darwin --with-cross-offsets=offsets-wasm32.h CFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" CXXFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" --disable-boehm --with-sigaltstack=no --enable-llvm --enable-llvm-runtime --with-llvm=../llvm-mono-build --disable-btls --with-runtime_preset=testing_aot_full
$ cd eglib
$ make
$ cd ../mono
$ make

At the end of this process you should have a mono executable installed as ~/src/mono-wasm/mono-compiler/mono/mini/mono built for the i386 architecture.

$ file ~/src/mono-wasm/mono-compiler/mono/mini/mono
mono/mini/mono: Mach-O executable i386

Now let's build the mscorlib.dll assembly for the WebAssembly profile. We can't use the mono runtime we just built as it's full AOT, so we use assume you have a normal mono runtime in your PATH that we can use. Clearly a hack, but in the meantime it works.

$ cd ~/src/mono-wasm/mono-compiler/mcs/class/corlib
$ make V=1 PROFILE=wasm RUNTIME=mono STRING_REPLACER=true SN=true

After this you should have the assembly file created in the proper location:

$ file ~/src/mono-wasm/mono-compiler/mcs/class/lib/wasm/mscorlib.dll 
/Users/lrz/src/mono-wasm/mono-compiler/mcs/class/lib/wasm/mscorlib.dll: PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS Windows

Mono runtime

Now we can prepare the Mono runtime. We have to clone a new copy of the source code. We are not building the runtime code using the Mono autotools system, so we have to copy header files that are normally generated.

$ cd ~/src/mono-wasm
$ git clone [email protected]:lrz/mono-wasm-mono.git mono-runtime
$ cd mono-runtime
$ cp config-wasm32.h config.h
$ cp eglib/src/eglib-config-wasm32.h eglib/src/eglib-config.h

C library

Similarly as above, we clone a copy of the C library that we will be using.

$ cd ~/src/mono-wasm
$ git clone [email protected]:lrz/mono-wasm-libc.git libc

OK ready!

We are ready to build our Hello World.

First, we need to build everything into the dist directory:

$ cd ~/src/mono-wasm/build
$ vi Makefile               # make sure the *_PATH variables point to proper locations, should be the case if you followed these instructions
$ make

This will build the mono runtime and the libc as LLVM bitcode using our version of clang, then link everything into a runtime.bc file. This will also build the mono-wasm tool which links against the LLVM and lld libraries. Finally, we will copy the Mono compiler and its mscorlib.dll file.

$ find dist -type f
dist/bin/monoc
dist/bin/mono-wasm
dist/lib/runtime.bc
dist/lib/index.js
dist/lib/mscorlib.dll
dist/lib/mscorlib.xml

Once done, you can build the Hello World sample:

$ cd sample/hello
$ make

TODO

TODO (now):

  • fix garbage collection (need to figure out how to scan the stack)
  • ship a first 'alpha' release

TODO (later):

  • put mscorlib on a diet (currently 'hello world' is 10MB) by removing more functionality within the wasm.make profile and doing more aggressive IL linking
  • work on patches for mono based on the changes made in the fork
  • merge the WebAssembly LLVM code into the mono/llvm fork so that the Mono compiler can target wasm32 directly, and that we can merge the code into mono-wasm (we won't have to ship the Mono compiler separately as monoc)
  • improve the C# -> JS interop by doing a full C# API replication in JS like embeddinator 4000
  • investigate: threads, sockets, debugger, stack unwinding, simd and atomic operations, etc.

License

This work is distributed under the terms of the MIT license. See the LICENSE.txt file for more information.

mono-wasm's People

Contributors

lrz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mono-wasm's Issues

Can't resolve lib

I tried compiling exe file with latest release but couldn't get anywhere.

$ mono-wasm -i Program.exe -o output
can't resolve 'lib' directory

Error compiling Mono compiler by following instructions

Hi there!

This looks very promising :-)

I am on macOS with (hopefully) all tools installed.
When following the instructions I get an error for 'Now, we can now build the Mono compiler itself':

$ cd ~/src/mono-wasm
$ git clone [email protected]:lrz/mono-wasm-mono.git mono-compiler
$ cd mono-compiler
$ ./autogen.sh --host=i386-darwin --with-cross-offsets=offsets-wasm32.h CFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" CXXFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" --disable-boehm --with-sigaltstack=no --enable-llvm --enable-llvm-runtime --with-llvm=../llvm-mono-build --disable-btls --with-runtime_preset=testing_aot_full
$ cd eglib
$ make
$ cd ../mono
$ make

The last make produces this error:

  mono git:(master) make
Making all in arch
make[2]: Nothing to be done for `all-am'.
Making all in utils
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
make[2]: Nothing to be done for `all-am'.
Making all in cil
make[1]: Nothing to be done for `all'.
Making all in metadata
make[1]: Nothing to be done for `all'.
Making all in sgen
make[1]: Nothing to be done for `all'.
Making all in mini
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
  CCLD     mono-sgen
Undefined symbols for architecture i386:
  "_futimens", referenced from:
      llvm::sys::fs::setLastModificationAndAccessTime(int, llvm::sys::TimeValue) in libLLVMSupport.a(Path.cpp.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [mono-sgen] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

Is there anything I am missing?
Thanks!

RuntimeError: function signature mismatch when invoking a generic delegate

Given the following extension:

public static class FuncMemoizeExtensions
{
    public static Func<TParam, TResult> Test<TParam, TResult>(this Func<TParam, TResult> func)
    {
       return v => default(TResult);
    }
}

and the following code :

Func<int, int> a = i => i;
var a2 = a.Test();

a(1);
a2(1);

a(1) is executed properly, where a2(1) fails in chrome with the following error:

wasm-02396cee-9252:212 Uncaught (in promise) RuntimeError: function signature mismatch
    at hello_wrapper_delegate_invoke_System_Func_2_int_int_invoke_TResult_T_int (wasm-function[9252]:488)
    at hello_Hello_Main_string__ (wasm-function[9235]:1459)
    at mscorlib_wrapper_unknown_object_gsharedvt_out_sig_intptr_object__intptr_2 (wasm-function[18376]:40)
    at mscorlib_wrapper_runtime_invoke_object_runtime_invoke_sig_void_intptr_intptr_intptr_object_intptr_intptr_intptr (wasm-function[18034]:164)
    at mono_llvmonly_runtime_invoke (wasm-function[6921]:1024)
    at mono_jit_runtime_invoke (wasm-function[6678]:1025)
    at do_runtime_invoke (wasm-function[2044]:213)
    at mono_runtime_try_invoke (wasm-function[2158]:196)
    at do_try_exec_main (wasm-function[6592]:257)
    at mono_runtime_try_exec_main (wasm-function[6589]:78)
    at mono_runtime_try_run_main (wasm-function[6586]:154)
    at mono_jit_exec (wasm-function[6585]:300)
    at mono_wasm_main (wasm-function[9226]:424)

Can't access DateTime.Now

I'm not sure if this project is still in development, but never the less, the following very basic program crashes while executing:

public static int Main(string[] args)
{
    Console.WriteLine("Start");

    var start = DateTime.Now;

    Console.WriteLine(start.ToString());

    return 0;
}

Output

mono-wasm: booting main()
index.js:28:39
mono-wasm: initializing mono runtime
index.js:28:39
mono-wasm: opening main assembly `hello.exe'
index.js:28:39
* Assertion at ../mono-runtime/mono/mini/aot-runtime.c:2629, condition `*code_end > *code_start' not met
index.js:28:39
index.js:28:39
!! received SIGABRT: error@http://localhost:8000/output/index.js:30:40
SYS_tkill@http://localhost:8000/output/index.js:170:81
route_syscall@http://localhost:8000/output/index.js:209:8
raise@http://localhost:8000/output/index.js:98485:1
abort@http://localhost:8000/output/index.js:91230:1
mono_log_write_logfile@http://localhost:8000/output/index.js:624556:1
structured_log_adapter@http://localhost:8000/output/index.js:625593:1
monoeg_g_logv@http://localhost:8000/output/index.js:412431:1
monoeg_assertion_message@http://localhost:8000/output/index.js:408898:1
compute_llvm_code_range@http://localhost:8000/output/index.js:1160127:1
load_aot_module@http://localhost:8000/output/index.js:1155896:1
mono_assembly_invoke_load_hook@http://localhost:8000/output/index.js:1019815:1
mono_assembly_load_from_predicate@http://localhost:8000/output/index.js:1020996:1
mono_assembly_open_predicate@http://localhost:8000/output/index.js:1010922:1
mono_assembly_open@http://localhost:8000/output/index.js:2712319:1
mono_wasm_main@http://localhost:8000/output/index.js:3002454:1
run_wasm_code@http://localhost:8000/output/index.js:214:9
@http://localhost:8000/output/index.js:216:239

Makefile appears to be outdated

I ran into a few issues when trying to run the make step at the very end of the directions. Not sure if I followed the directions incorrectly or if something else is wrong.

  1. According to the README, the makefile should be in the build directory. However, there is none, and trying to build with the makefile in the root crashes because the relative paths are incorrect. I missed the step where this repo was checked out to the build directory at the very beginning.
  2. After correcting the paths, I get the error make: *** No rule to make target 'wasm-linker.o', needed by 'mono-wasm'. Stop.. I can't find wasm-linker anywhere, what is step is supposed to produce that file?

Error Compiling mono-compiler --host=x86_64-pc-linux-gnu

I trying Window 10 Pro_x64 + WSL + Ubuntu 16.04

$ cd /mnt/d/Dev/mono-wasm/
$ git clone [email protected]:lrz/mono-wasm-mono.git mono-compiler
$ cd mono-compiler
$ ./autogen.sh --host=x86_64-pc-linux-gnu
--with-cross-offsets=offsets-wasm32.h
CFLAGS="-DCOMPILE_WASM32
-DMONO_CROSS_COMPILE"
CXXFLAGS="-DCOMPILE_WASM32
-DMONO_CROSS_COMPILE"
--disable-boehm
--with-sigaltstack=no
--enable-llvm
--enable-llvm-runtime
--with-llvm=../llvm-mono-build
--disable-btls
--with-runtime_preset=testing_aot_full
$ cd eglib
$ make
$ cd ../mono
$ make

mini-amd64.c: In function 'mono_arch_emit_epilog':
mini-amd64.c:7080:54: warning: ISO C forbids passing argument 2 of 'mono_arch_instrument_epilog' between function pointer and 'void *' [-Wpedantic]
code = (guint8 *)mono_arch_instrument_epilog (cfg, mono_trace_leave_method, code, TRUE);
^
In file included from mini-amd64.c:19:0:
mini.h:2714:11: note: expected 'void ' but argument is of type 'void ()(MonoMethod ) {aka void ()(struct MonoMethod *)}'
void *mono_arch_instrument_epilog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments);
^
In file included from ../../mono/arch/amd64/amd64-codegen.h:137:0,
from ../../mono/utils/mono-context.h:210,
from ../../mono/utils/mono-stack-unwinding.h:12,
from ../../mono/utils/mono-threads.h:15,
from ../../mono/metadata/handle.h:23,
from ../../mono/metadata/threads-types.h:19,
from ../../mono/metadata/object-internals.h:13,
from mini.h:28,
from mini-amd64.c:19:
../../mono/metadata/abi-details.h:55:42: error: 'MONO_OFFSET_MonoLMF_rbp' undeclared (first use in this function)
#define MONO_STRUCT_OFFSET(struct,field) MONO_OFFSET
## struct ## _ ## field
^
../../mono/arch/amd64/../x86/x86-codegen.h:274:38: note: in definition of macro 'x86_imm_emit32'
x86_imm_buf imb; imb.val = (int) (imm);
^
../../mono/arch/amd64/amd64-codegen.h:339:3: note: in expansion of macro 'amd64_membase_emit'
amd64_membase_emit ((inst), (reg), (basereg), (disp));
^
../../mono/arch/amd64/amd64-codegen.h:352:3: note: in expansion of macro 'amd64_mov_reg_membase_body'
amd64_mov_reg_membase_body((inst), (reg), (basereg), (disp), (size));
^
mini-amd64.c:7103:4: note: in expansion of macro 'amd64_mov_reg_membase'
amd64_mov_reg_membase (code, AMD64_RBP, cfg->frame_reg, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, rbp), 8);
^
mini-amd64.c:7103:73: note: in expansion of macro 'MONO_STRUCT_OFFSET'
amd64_mov_reg_membase (code, AMD64_RBP, cfg->frame_reg, lmf_offset + MONO_STRUCT_OFFSET (MonoLMF, rbp), 8);
^
mini-amd64.c: In function 'get_delegate_invoke_impl':
mini-amd64.c:7643:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < param_count; ++i) {
^
Makefile:2679: recipe for target 'libmini_la-mini-amd64.lo' failed
make[2]: *** [libmini_la-mini-amd64.lo] Error 1
make[2]: Leaving directory '/mnt/d/Dev/mono-wasm/mono-compiler/mono/mini'
Makefile:1344: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/mnt/d/Dev/mono-wasm/mono-compiler/mono/mini'
Makefile:455: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

mono-wasm/mono-compiler/mono/metadata/abi-details.h

#ifdef USED_CROSS_COMPILER_OFFSETS
#define MONO_STRUCT_OFFSET(struct,field) MONO_OFFSET_ ## struct ## _ ## field
#else
#if defined(HAS_CROSS_COMPILER_OFFSETS) || defined(MONO_CROSS_COMPILE)
#define MONO_STRUCT_OFFSET(struct,field) (MONO_OFFSET_ ## struct ## _ ## field == -1, G_STRUCT_OFFSET (struct,field))
#else
#define MONO_STRUCT_OFFSET(struct,field) G_STRUCT_OFFSET (struct,field)
#endif
#endif

Unable to build hello world: mono-wasm.cpp

Hello. I managed to build the compiler, up to the step where we compile hello world app from this repo. Running this step:

$ cd ~/src/mono-wasm/build
$ vi Makefile               # make sure the *_PATH variables point to proper locations, should be the case if you followed these instructions
$ make

i get some warnings and an error that makes me unable to build:

mono-wasm.cpp:173:52: warning: cast from 'const char *' to 'char *' drops const qualifier
      [-Wcast-qual]
    char *first_assembly = strdup(basename((char *)assembly_paths[0].c_str()));
                                                   ^
mono-wasm.cpp:358:53: error: too few arguments to function call, expected at least 4, have 3
                llvm::TargetMachine::CGFT_ObjectFile)) {
                                                    ^
/Users/jedrzejg/Work/mono-wasm/llvm/include/llvm/Target/TargetMachine.h:254:3: note:
      'addPassesToEmitFile' declared here
  virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &,
  ^
mono-wasm.cpp:405:22: warning: cast from 'const char *' to 'char *' drops const qualifier
      [-Wcast-qual]
        free((char *)args[i + 1]);

I suppose this is caused by some sort of wrong version. Could you point me in the right direction?

I also noticed makefile uses clang we just built, except two cases for clang and clang++. However, when i replaced those with clang we just built, i am getting

mono-wasm.cpp:5:10: fatal error: 'mach/mach_time.h' file not found

One more thing, running $ ~/src/mono-wasm/llvm-build/bin/clang --version shows clang version 7 instead of 5 and no registered targets:

(~/Work/mono-wasm/build)
$ ../llvm-build/bin/clang --version
clang version 7.0.0 (trunk 335475) (llvm/trunk 335466)
Target: x86_64-apple-darwin17.6.0
Thread model: posix
InstalledDir: (...)/mono-wasm/build/../llvm-build/bin

Should i now target any specific branch for llvm svn repos?

$ svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
$ svn co http://llvm.org/svn/llvm-project/lld/trunk lld

Thanks in advance for any help.

Bad scammer to my Ubuntu 18.04!!!!

Why do you hurt my Ubuntu 18.04?

I have tried but I give up Mono-Wasm than it happens error because your llvm installation saves in /usr/local

I am mad now because I want use only /usr not /usr/local. I have removed /usr/local

and can't remove saved paths from include and library
See mono/mono#10583

PLEASE REMOVE UNUSABLE PATH from INCULDUE and LIBRARY

Build fail on debian(jessie)

Seem the build instructions's params is specificed for OSX.
I have not mac, but i still try following instructions to build on debian(jessie) and fail.
Maybe some params differ between OSX and debian.
Please give some help! Thanks!

I am a dotnet developper, Very enjoying to using CSharp to develope software.
Now tasteing CSharp to wasm.

Thanks again!

Referencing an assembly with a "." (dot) in the name fails

Using the latest bits of all the dependencies as of this post's date, referencing an assembly which contains a "." (dot) in its name fails with the following message in Chrome (and fails silently in Edge):

Uncaught (in promise) LinkError: WebAssembly Instantiation: Import #197 module="env" function="mono_aot_module_test.test_info" error: global import must be a number
    at <anonymous>
Promise.then (async)
(anonymous) @ index.js:215

See this branch for reference: jeromelaban@a5c4175

An assembly name without a dot works properly.

F# Support

Just a question, once you get C# supported is there any downstream plans to add F# support. Would it be hard or trivial to make that jump?

Is this project still actively pursued or a 'dead end'?

Hi,

I wonder if I'm missing something, but appears there hasn't been any commit since end of Jan 2018. Which strikes me odd since webassembly is such a hot topic in the industry (and even Blazor is based on it, no?)

Is this project dead? Am I missing something?

Thanks in advance for shedding some light

Error following build instructions

First, this looks amazing, and I'm looking forwards to being able to have a go with it!

I tried to follow the build instructions in README.md. First I tried on Ubuntu but hit various issues which are probably to do with needing different flags to indicate the build platform. Then, since it looks like the instructions are designed for macOS, I tried it on a Mac, and all went well until trying to build the Mono compiler.

After running these lines:

$ ./autogen.sh --host=i386-darwin --with-cross-offsets=offsets-wasm32.h CFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" CXXFLAGS="-DCOMPILE_WASM32 -DMONO_CROSS_COMPILE" --disable-boehm --with-sigaltstack=no --enable-llvm --enable-llvm-runtime --with-llvm=../llvm-mono-build --disable-btls --with-runtime_preset=testing_aot_full
$ make

... I'm getting this error (after a lot of other build output):

...
cd /Users/myusername/Desktop/mono-wasm/mono-compiler/mcs && /Applications/Xcode.app/Contents/Developer/usr/bin/make --no-print-directory -s NO_DIR_CHECK=1 PROFILES='binary_reference_assemblies net_4_x xbuild_12 xbuild_14         ' CC='gcc' all-profiles

Unhandled Exception:
System.MissingMethodException: Method 'AppContext.get_BaseDirectory' not found.
  at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore (System.String[] args) <0x10f271ff0 + 0x000b3> in <filename unknown>:0 
  at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main (System.String[] args) <0x10f271da0 + 0x00023> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method 'AppContext.get_BaseDirectory' not found.
  at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore (System.String[] args) <0x10f271ff0 + 0x000b3> in <filename unknown>:0 
  at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main (System.String[] args) <0x10f271da0 + 0x00023> in <filename unknown>:0 
make[6]: *** [build/deps/basic-profile-check.exe] Error 1
*** The runtime 'mono' doesn't appear to be usable.
*** Trying the 'monolite-darwin/1050500002' directory.
This mono runtime is compiled for cross-compiling. Only the --aot option is supported.
make[8]: *** [build/deps/basic-profile-check.exe] Error 1
*** The contents of your 'monolite-darwin/1050500002' directory may be out-of-date
*** You may want to try 'make get-monolite-latest'
make[8]: *** [do-profile-check-monolite] Error 1
make[7]: *** [do-profile-check] Error 2
make[6]: *** [do-profile-check-monolite] Error 2
make[5]: *** [do-profile-check] Error 2
make[4]: *** [profile-do--basic--all] Error 2
make[3]: *** [profiles-do--all] Error 2
make[2]: *** [all-local] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Was this not something that happened when you ran it? Do you know of any workaround for this?

PS there were also a load of warnings further up, such as the following, though I don't know if this is normal or expected:

In file included from ../../mono/utils/mono-threads.h:14:
../../mono/utils/mono-os-semaphore.h:114:20: warning: comparison of integers of different signs: 'clock_res_t'
      (aka 'int') and 'unsigned long long' [-Wsign-compare]
        while (ts.tv_nsec >= NSEC_PER_SEC) {

Generating Code using C# Compiler or Reflection.Emit

What are the plans for generating code for serializers, CodeDom (using C# compiler or Reflection.Emit) etc?

From my naive standpoint a Reflection.Emit Implementation shouldn't be toooooo complicated I guess, since you only would have to send it through the Compiler Pipeline (which already exists if you compile the DLL to wasm on the client side)?

Or will there be no generation support (like I think it is in MonoTouch) and generating will only be possible if you use AoT (Ahead of Time)-Compiliation? My goal is mostly for generating Implementations for Interfaces/Abstract classes, less for performance optimizations (but since the code should be used both on server and (javascript) client side it would be nice).

One alternative option I thought of is sending the instructions for generating the code to the server, which compiles a DLL (using for example the C# Compiler), which is then again downloaded by the mono-wasm. Is this maybe already possible?

Make it clear mono-wasm is developed in another repo

The existence of this repository may be a bit misleading (it was to me) as I have noticed that compiling C# to wasm using mono is developed in the main mono repository, not here.

In order to make it clear I suggest archiving this repository or adding a disclaimer in the README.

Taking such actions may save people's time.

Do not take this as an offense - I believe that the instruction notes are detailed and well written, they are just missing that vital information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.