godot-mono-builds icon indicating copy to clipboard operation
godot-mono-builds copied to clipboard

.wasm script fails to build with readme versions of Emscripten and Mono

Open matts-dev opened this issue 2 years ago • 0 comments

OS/device including version: debian-11 x64 nvidia 2080 intel i9-139000k

Issue description: The README.md specifies these versions:

Mono: 6.12.0.182.
Emscripten: 1.39.9.

My system matches these requirements: my system:

dev_user:~/Desktop/git_repos/third_party/mono$ git branch
* (HEAD detached at mono-6.12.0.182)
dev_user:~/Desktop/git_repos/owned/local_code_tests/test_c$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.9

Running these commands work until I end up attempting to use the make command:

./patch_mono.py --mono-sources $HOME/Desktop/git_repos/third_party/mono
./patch_emscripten.py --mono-sources $HOME/Desktop/git_repos/third_party/mono
./wasm.py configure --target=runtime --mono-sources $HOME/Desktop/git_repos/third_party/mono
./wasm.py make --target=runtime --mono-sources $HOME/Desktop/git_repos/third_party/mono

error during compiling mono with emscripten

/home/dev_user/Desktop/git_repos/third_party/mono/mono/utils/mono-rand.c:39:10: fatal error: 'sys/random.h' file not found
#include <sys/random.h>
         ^~~~~~~~~~~~~~
1 error generated.

I sandboxed this and it appears the emscripten compiler specified does not have the sys/random headers that were added to glibc (libc6 debian). I believe it is a newer feature of C because of the answer on this question: https://stackoverflow.com/questions/30800331/getrandom-syscall-in-c-not-found Sandboxing this away from godot, I have same issue with versions of mono/emscripten:

#include <stdio.h>
#include "sys/random.h"

int main()
{
    printf("Hello World");

    getentropy(NULL, 0); //from sys/random.h
    return 0;
}

debian's gcc:

dev_user@dbn139i9:~/Desktop/git_repos/owned/local_code_tests/test_c$ gcc hello_world.c 
dev_user@dbn139i9:~/Desktop/git_repos/owned/local_code_tests/test_c$ ls
a.out  hello_world.c*

emscripten:

dev_user@dbn139i9:~/Desktop/git_repos/owned/local_code_tests/test_c$ emcc hello_world.c 
cache:INFO: generating system asset: is_vanilla.txt... (this will be cached in "/home/dev_user/.emsdk/upstream/emscripten/cache/is_vanilla.txt" for subsequent builds)
cache:INFO:  - ok
hello_world.c:2:10: fatal error: 'sys/random.h' file not found
#include "sys/random.h"
         ^~~~~~~~~~~~~~

So, it seems this newer feature of C is not in the emscripten compiler listed.

So, this communicates to me that the version of emscripten in the readme is incompatible with the version of mono specified. I have different compile issues using latest emscripten.

I believe the README.md is specifying either the wrong version of mono, or the wrong version of emscripten. I imagine it is the wrong veresion of emscripten, since this file does not seem to have changed in a while in the mono code base (at a quick glance).

Can the README.md to specify the correct versions to use to compile mono for webassembly?

Thanks.

Expected: be able to compile mono for webassmbly Result: compile errors with versions listed.

My attempts to fix: modify mono/utils/mono-rand.c to not use #include "sys/random.h", but using

#include <sys/syscall.h>

did not work

 error: implicit declaration of function 'getentropy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                gint const err = getentropy (buffer, len);

(#include <linux/random.h> fails to find file)

edit: perhaps there is a way to see the versions produced by the official build machines for the mono binaries? I'm not familiar with where to look for that.

matts-dev avatar Dec 23 '22 15:12 matts-dev