dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.42k stars 199 forks source link

NativeAOT-LLVM: switch WASI target to wasm32-wasi #2317

Closed yowl closed 1 year ago

yowl commented 1 year ago

This PR changes the target for WASI from wasm32-wasi-threads to wasm32-wasi. wasm32-wasi-threads seemed easier to bring up, but that fact that there is less support in WASI runtimes, makes it not that useful for progressing wit-bindgen . So this PR reverts that decision and adds stubs for the missing pthread/mprotect/__cxa_thread_atexit functions.

Closes #2295

yowl commented 1 year ago

We still have these undefined so -Wl,--unresolved-symbols=ignore-all is still required.

wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(cgroup.cpp.obj): undefined symbol: getrlimit(int, rlimit*)
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_create
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_attr_destroy
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_broadcast
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_wait
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_timedwait
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_destroy
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(gcenv.unix.cpp.obj): undefined symbol: madvise
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_destroy
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_broadcast
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_wait
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libPortableRuntime.a(PalRedhawkUnix.cpp.obj): undefined symbol: pthread_cond_timedwait
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libCppExceptionHandling.a(ExceptionHandling.Cpp.cpp.obj): undefined symbol: __cxa_allocate_exception
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libCppExceptionHandling.a(ExceptionHandling.Cpp.cpp.obj): undefined symbol: __cxa_throw
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/coreclr/wasi.wasm.Debug/aotsdk/libCppExceptionHandling.a(ExceptionHandling.Cpp.cpp.obj): undefined symbol: __cxa_end_catch
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/microsoft.netcore.app.runtime.wasi-wasm/debug/runtimes/wasi-wasm/native/libSystem.Native.a(pal_errno.c.obj): undefined symbol: gai_strerror
wasm-ld: error: E:/GitHub/runtimelab/artifacts/bin/microsoft.netcore.app.runtime.wasi-wasm/debug/runtimes/wasi-wasm/native/libSystem.Native.a(pal_datetime.c.obj): undefined symbol: mono_wasm_get_bundled_file
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: CompareStringEx
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: CompareStringOrdinal
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: FindNLSStringEx
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: FindStringOrdinal
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: GetCalendarInfoEx
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: GetLocaleInfoEx
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: LCMapStringEx
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: LocaleNameToLCID
wasm-ld: error: E:/GitHub/runtimelab/artifacts/tests/coreclr/obj/wasi.wasm.Debug/Managed/nativeaot/SmokeTests/HelloWasm/HelloWasm/native/HelloWasm.external.o: undefined symbol: emscripten_get_callstack
yowl commented 1 year ago

cc @dotnet/nativeaot-llvm

yowl commented 1 year ago

draft while odd LLVM assert is fixed