Build Mono WebAssembly runtime and BCLs

We force using Emscripten 1.38.47 as there is a regression in 1.38.48
and 1.39.x which makes the generation of our .wasm file fail.

Up until now we used the desktop BCL (compiled with desktop Mono)
for both desktop and Android, but that does not work for WebAssembly
(and we suspect Android issues related to it).

So we now build the Android and WebAssembly BCLs in the relevant
containers, which are later copied in the templates directory to
include on export. We already have the desktop BCL from the regular
build.
This commit is contained in:
Rémi Verschelde
2019-11-15 11:04:40 +01:00
parent 12b37c7c7e
commit 17666f07fe
4 changed files with 31 additions and 82 deletions

View File

@@ -17,14 +17,17 @@ ENV ANDROID_HOME=/root/sdk/
ENV ANDROID_NDK_ROOT=/root/sdk/ndk-bundle/
RUN git clone https://github.com/mono/mono --branch mono-${mono_version} --single-branch && \
cd mono && git submodule update --init && \
patch -p1 < /root/files/patches/fix-mono-android-tkill.diff && \
cd .. && \
cd mono && git submodule update --init && cd .. && \
export MONO_SOURCE_ROOT=/root/mono && \
git clone https://github.com/godotengine/godot-mono-builds && \
cd godot-mono-builds && \
git checkout 9efec19e6b61fdc7201067cff4dd5b741399ae31 && \
./build_mono_android.py configure --target=all --mono-sources=/root/mono && \
./build_mono_android.py make --target=all --mono-sources=/root/mono && \
git checkout bd129da22b8b9c96f3e8b07af348cc5fb61504bf && \
python3 patch_mono.py && \
python3 android.py configure --target=all-runtime && \
python3 android.py make --target=all-runtime && \
cd /root/mono && git clean -fdx && NOCONFIGURE=1 ./autogen.sh && \
cd /root/godot-mono-builds && \
python3 bcl.py make --product=android && \
cd .. && \
rm -rf /root/mono /root/godot-mono-builds

View File

@@ -1,12 +1,29 @@
FROM godot-fedora:latest
ARG mono_version
FROM godot-mono:${mono_version}
ARG mono_version
RUN dnf -y install --setopt=install_weak_deps=False \
java-openjdk yasm && \
dnf clean all && \
git clone https://github.com/emscripten-core/emsdk && \
cd emsdk && \
./emsdk install 1.39.0 && \
./emsdk activate 1.39.0 && \
./emsdk install 1.38.47-upstream && \
./emsdk activate 1.38.47-upstream && \
echo "source /root/emsdk/emsdk_env.sh" >> /root/.bashrc
RUN git clone https://github.com/mono/mono --branch mono-${mono_version} --single-branch && \
cd mono && git submodule update --init && cd .. && \
export MONO_SOURCE_ROOT=/root/mono && \
git clone https://github.com/godotengine/godot-mono-builds && \
cd godot-mono-builds && \
git checkout bd129da22b8b9c96f3e8b07af348cc5fb61504bf && \
python3 patch_emscripten.py && \
python3 wasm.py configure --target=runtime && \
python3 wasm.py make --target=runtime && \
cd /root/mono && git clean -fdx && NOCONFIGURE=1 ./autogen.sh && \
cd /root/godot-mono-builds && \
python3 bcl.py make --product wasm && \
cd .. && \
rm -rf /root/mono /root/godot-mono-builds
CMD ['/bin/bash']

View File

@@ -30,9 +30,8 @@ $podman build --build-arg mono_version=${mono_version} -t godot-mono-glue:latest
$podman build --build-arg mono_version=${mono_version} -v $(pwd)/files:/root/files -t godot-windows:latest -f Dockerfile.windows .
$podman build --build-arg mono_version=${mono_version} -t godot-ubuntu-32:latest -f Dockerfile.ubuntu-32 .
$podman build --build-arg mono_version=${mono_version} -t godot-ubuntu-64:latest -f Dockerfile.ubuntu-64 .
$podman build --build-arg mono_version=${mono_version} -v $(pwd)/files:/root/files -t godot-android:latest -f Dockerfile.android .
$podman build -t godot-javascript:latest -f Dockerfile.javascript .
$podman build --build-arg mono_version=${mono_version} -t godot-android:latest -f Dockerfile.android .
$podman build --build-arg mono_version=${mono_version} -t godot-javascript:latest -f Dockerfile.javascript .
$podman build -t godot-xcode-packer:latest -f Dockerfile.xcode -v $(pwd)/files:/root/files .

View File

@@ -1,70 +0,0 @@
diff --git a/libgc/include/private/gcconfig.h b/libgc/include/private/gcconfig.h
index e2bdf13ac3e..f962200ba4e 100644
--- a/libgc/include/private/gcconfig.h
+++ b/libgc/include/private/gcconfig.h
@@ -2255,6 +2255,14 @@
# define GETPAGESIZE() getpagesize()
# endif
+#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \
+ && ((defined(MIPS) && (CPP_WORDSZ == 32)) \
+ || defined(ARM32) || defined(I386) /* but not x32 */)
+ /* tkill() exists only on arm32/mips(32)/x86. */
+ /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */
+# define USE_TKILL_ON_ANDROID
+#endif
+
# if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
/* OS has SVR4 generic features. Probably others also qualify. */
# define SVR4
diff --git a/libgc/pthread_stop_world.c b/libgc/pthread_stop_world.c
index f93ce26b562..4a49a6d578c 100644
--- a/libgc/pthread_stop_world.c
+++ b/libgc/pthread_stop_world.c
@@ -336,7 +336,7 @@ void GC_push_all_stacks()
pthread_t GC_stopping_thread;
int GC_stopping_pid;
-#ifdef HOST_ANDROID
+#ifdef USE_TKILL_ON_ANDROID
static
int android_thread_kill(pid_t tid, int sig)
{
diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c
index ad9b8823f8f..3542b32b540 100644
--- a/mono/metadata/threads.c
+++ b/mono/metadata/threads.c
@@ -77,8 +77,12 @@ mono_native_thread_join_handle (HANDLE thread_handle, gboolean close_handle);
#include <zircon/syscalls.h>
#endif
-#if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64)
-#define USE_TKILL_ON_ANDROID 1
+#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \
+ && ((defined(MIPS) && (CPP_WORDSZ == 32)) \
+ || defined(ARM32) || defined(I386) /* but not x32 */)
+ /* tkill() exists only on arm32/mips(32)/x86. */
+ /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */
+# define USE_TKILL_ON_ANDROID
#endif
#ifdef HOST_ANDROID
diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c
index 3e4bf93de5f..79c9f731fe7 100644
--- a/mono/utils/mono-threads-posix.c
+++ b/mono/utils/mono-threads-posix.c
@@ -31,8 +31,12 @@
#include <errno.h>
-#if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64)
-#define USE_TKILL_ON_ANDROID 1
+#if defined(HOST_ANDROID) && !(__ANDROID_API__ >= 23) \
+ && ((defined(MIPS) && (CPP_WORDSZ == 32)) \
+ || defined(ARM32) || defined(I386) /* but not x32 */)
+ /* tkill() exists only on arm32/mips(32)/x86. */
+ /* NDK r11+ deprecates tkill() but keeps it for Mono clients. */
+# define USE_TKILL_ON_ANDROID
#endif
#ifdef USE_TKILL_ON_ANDROID