Skip to content

Commit 1f8d2a4

Browse files
committed
wip
1 parent ae6ad88 commit 1f8d2a4

File tree

12 files changed

+73
-16
lines changed

12 files changed

+73
-16
lines changed

eng/native/gen-buildsys.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ if /i "%__Arch%" == "wasm" (
6060
set __UseEmcmake=1
6161
)
6262
if /i "%__Os%" == "wasi" (
63+
set "__repoRoot=!__repoRoot:\=/!"
6364
if "%WASI_SDK_PATH%" == "" (
6465
if not exist "%__repoRoot%\src\mono\wasi\wasi-sdk" (
6566
echo Error: Should set WASI_SDK_PATH environment variable pointing to WASI SDK root.
@@ -72,7 +73,7 @@ if /i "%__Arch%" == "wasm" (
7273
set "WASI_SDK_PATH=!WASI_SDK_PATH:\=/!"
7374
if not "!WASI_SDK_PATH:~-1!" == "/" set "WASI_SDK_PATH=!WASI_SDK_PATH!/"
7475
set __CmakeGenerator=Ninja
75-
set __ExtraCmakeParams=%__ExtraCmakeParams% -DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm "-DWASI_SDK_PREFIX=!WASI_SDK_PATH!" "-DCMAKE_TOOLCHAIN_FILE=!WASI_SDK_PATH!/share/cmake/wasi-sdk.cmake" "-DCMAKE_SYSROOT=!WASI_SDK_PATH!/share/wasi-sysroot"
76+
set __ExtraCmakeParams=%__ExtraCmakeParams% -DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm "-DWASI_SDK_PREFIX=!WASI_SDK_PATH!" "-DCMAKE_TOOLCHAIN_FILE=!__repoRoot!/src/native/external/wasi-sdk-p2.cmake" "-DCMAKE_SYSROOT=!WASI_SDK_PATH!/share/wasi-sysroot"
7677
)
7778
) else (
7879
set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0"

eng/native/gen-buildsys.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55

66
scriptroot="$( cd -P "$( dirname "$0" )" && pwd )"
7+
reporoot="$(cd "$scriptroot"/../..; pwd -P)"
78

89
if [[ "$#" -lt 4 ]]; then
910
echo "Usage..."
@@ -97,7 +98,7 @@ if [[ "$host_arch" == "wasm" ]]; then
9798
if [[ "$target_os" == "browser" ]]; then
9899
cmake_command="emcmake $cmake_command"
99100
elif [[ "$target_os" == "wasi" ]]; then
100-
true
101+
cmake_extra_defines="$cmake_extra_defines -DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$WASI_SDK_PATH -DCMAKE_TOOLCHAIN_FILE=$reporoot/src/native/external/wasi-sdk-p2.cmake" "-DCMAKE_SYSROOT=!WASI_SDK_PATH!/share/wasi-sysroot"
101102
else
102103
echo "target_os was not specified"
103104
exit 1

src/mono/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ if(NOT AOT_TARGET_TRIPLE STREQUAL "")
150150
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-none")
151151
set(TARGET_SYSTEM_NAME "emscripten")
152152
set(TARGET_ARCH "wasm")
153-
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-wasi")
153+
elseif(AOT_TARGET_TRIPLE STREQUAL "wasm32-unknown-wasip2")
154154
set(TARGET_SYSTEM_NAME "wasi")
155155
set(TARGET_ARCH "wasm")
156156
elseif(AOT_TARGET_TRIPLE STREQUAL "x86_64-none-linux-android")

src/mono/Directory.Build.props

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,9 @@
3434

3535
<!-- Directory to provision and use WASI sdk if WASI_SDK_PATH env variable is not set -->
3636
<PropertyGroup Condition="'$(TargetsWasi)' == 'true'">
37-
<!-- force download temmporarily https://github.com/dotnet/runtime/issues/101528
38-
<WASI_SDK_PATH Condition="'$(WASI_SDK_PATH)' == ''">$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
39-
-->
4037
<WASI_SDK_PATH>$([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk'))</WASI_SDK_PATH>
4138
<WASI_SDK_PATH>$([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/'))</WASI_SDK_PATH>
42-
<ShouldProvisionWasiSdk Condition="!Exists($(_ProvisionWasiSdkDir))">true</ShouldProvisionWasiSdk>
39+
<ShouldProvisionWasiSdk Condition="!Exists($(WASI_SDK_PATH))">true</ShouldProvisionWasiSdk>
4340
</PropertyGroup>
4441

4542
<PropertyGroup>

src/mono/mono.proj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ JS_ENGINES = [NODE_JS]
327327
Condition="'$(HostOS)' == 'windows'"
328328
WorkingDirectory="$(ArtifactsObjDir)"
329329
IgnoreStandardErrorWarningFormat="true" />
330+
331+
<Copy SourceFiles="$(MSBuildThisFileDirectory)/wasi/wasi-sdk/share/wasi-sysroot/include/wasm32-wasi-threads/pthread.h"
332+
DestinationFiles="$(MSBuildThisFileDirectory)/wasi/wasi-sdk/share/wasi-sysroot/include/wasm32-wasip2/pthread.h"
333+
/>
334+
330335
</Target>
331336

332337
<Target Name="ValidateWasiSdk" Condition="'$(SkipMonoCrossJitConfigure)' != 'true'">
@@ -728,7 +733,7 @@ JS_ENGINES = [NODE_JS]
728733
<_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) &quot;$(MonoProjectRoot.TrimEnd('\/'))&quot;</_MonoCMakeConfigureCommand>
729734
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoSkipInitCompiler)' != 'true' and '$(HostOS)' != 'windows'">sh -c 'build_arch=&quot;$(_CompilerTargetArch)&quot; compiler=&quot;$(MonoCCompiler)&quot; . &quot;$(RepositoryEngineeringCommonDir)native/init-compiler.sh&quot; &amp;&amp; @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
730735
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoSkipInitCompiler)' == 'true' and '$(HostOS)' != 'windows'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
731-
<_MonoCMakeConfigureCommand Condition="'$(TargetsWasi)' == 'true'">$(_MonoCMakeConfigureCommand) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK_PATH)share/cmake/wasi-sdk.cmake -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot"</_MonoCMakeConfigureCommand>
736+
<_MonoCMakeConfigureCommand Condition="'$(TargetsWasi)' == 'true'">$(_MonoCMakeConfigureCommand) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot -DCMAKE_TOOLCHAIN_FILE=$(RepoRoot)src/native/external/wasi-sdk-p2.cmake -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot"</_MonoCMakeConfigureCommand>
732737

733738
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' == 'windows'">call &quot;$(RepositoryEngineeringDir)native\init-vs-env.cmd&quot; $(_CompilerTargetArch) &amp;&amp; cd /D &quot;$(MonoObjDir)&quot; &amp;&amp; @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)</_MonoCMakeConfigureCommand>
734739
<_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' != 'windows'">bash -c 'source $(_EmsdkEnvScriptPath) 2>&amp;1 &amp;&amp; emcmake $(_MonoCMakeConfigureCommand)'</_MonoCMakeConfigureCommand>
@@ -851,7 +856,7 @@ JS_ENGINES = [NODE_JS]
851856
<PropertyGroup Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">
852857
<MonoUseCrossTool>true</MonoUseCrossTool>
853858
<MonoAotAbi Condition="'$(TargetsBrowser)' == 'true'">wasm32-unknown-none</MonoAotAbi>
854-
<MonoAotAbi Condition="'$(TargetsWasi)' == 'true'">wasm32-unknown-wasi</MonoAotAbi>
859+
<MonoAotAbi Condition="'$(TargetsWasi)' == 'true'">wasm32-unknown-wasip2</MonoAotAbi>
855860
<MonoAotOffsetsFile>$(MonoObjCrossDir)offsets-wasm32-unknown-none.h</MonoAotOffsetsFile>
856861
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(MonoLLVMDir)/$(BuildArchitecture)/lib/libclang.dylib</MonoLibClang>
857862
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(MonoLLVMDir)/$(BuildArchitecture)/lib/libclang.so</MonoLibClang>

src/mono/mono/mini/mini-wasm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ typedef struct {
9292
#define MONO_ARCH_HAVE_SDB_TRAMPOLINES 1
9393
#define MONO_ARCH_LLVM_TARGET_LAYOUT "e-m:e-p:32:32-i64:64-n32:64-S128"
9494
#ifdef TARGET_WASI
95-
#define MONO_ARCH_LLVM_TARGET_TRIPLE "wasm32-unknown-wasi"
95+
#define MONO_ARCH_LLVM_TARGET_TRIPLE "wasm32-unknown-wasip2"
9696
#else
9797
#define MONO_ARCH_LLVM_TARGET_TRIPLE "wasm32-unknown-emscripten"
9898
#endif

src/mono/mono/tools/offsets-tool/offsets-tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def require_emscipten_path (args):
9090
if "wasm" in args.abi:
9191
if args.wasi_path != None:
9292
require_sysroot (args)
93-
self.sys_includes = [args.wasi_path + "/share/wasi-sysroot/include", args.wasi_path + "/lib/clang/18/include", args.mono_path + "/wasi/mono-include"]
93+
self.sys_includes = [args.wasi_path + "/share/wasi-sysroot/include/wasm32-wasip2", args.wasi_path + "/lib/clang/18/include", args.mono_path + "/wasi/mono-include"]
9494
self.target = Target ("TARGET_WASI", None, ["TARGET_WASM"] + WASI_DEFINES)
9595
self.target_args += ["-target", args.abi]
9696
self.target_args += ["--sysroot", args.sysroot]

src/mono/wasi/build/WasiApp.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@
323323
<_WasmNativeFileForLinking Remove="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmEHLibToExclude)" />
324324
<_WasmNativeFileForLinking Remove="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)$(_WasmSIMDLibToExclude)" />
325325

326-
<_WasmNativeFileForLinking Include="$(WasiSysRoot)\lib\wasm32-wasi\libc++.a" />
327-
<_WasmNativeFileForLinking Include="$(WasiSysRoot)\lib\wasm32-wasi\libc++abi.a" />
326+
<_WasmNativeFileForLinking Include="$(WasiSysRoot)\lib\wasm32-wasip2\libc++.a" />
327+
<_WasmNativeFileForLinking Include="$(WasiSysRoot)\lib\wasm32-wasip2\libc++abi.a" />
328328

329329
<_WasmNativeFileForLinking Include="@(NativeFileReference)" />
330330
</ItemGroup>

src/mono/wasi/provision.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ Invoke-WebRequest -Uri $WasiSdkUrl -OutFile ./wasi-sdk-$WasiSdkVersion.0-mingw.t
1717
tar --strip-components=1 -xzf ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz -C $WasiSdkPath
1818
Copy-Item $WasiLocalPath/wasi-sdk-version.txt $WasiSdkPath/wasi-sdk-version.txt
1919
Remove-Item ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz -fo
20+
21+
# Temporary WASI-SDK 22 workaround #2: The version of `wasm-component-ld` that
22+
# ships with WASI-SDK 22 contains a
23+
# [bug](https://github.com/bytecodealliance/wasm-component-ld/issues/22) which
24+
# has been fixed in a v0.5.3 of that utility, so we upgrade it here.
25+
Invoke-WebRequest -Uri https://github.com/bytecodealliance/wasm-component-ld/releases/download/v0.5.3/wasm-component-ld-v0.5.3-x86_64-windows.zip -OutFile wasm-component-ld-v0.5.3-x86_64-windows.zip
26+
Expand-Archive -LiteralPath wasm-component-ld-v0.5.3-x86_64-windows.zip -DestinationPath .
27+
Copy-Item wasm-component-ld-v0.5.3-x86_64-windows/wasm-component-ld.exe $WasiSdkPath/bin

src/mono/wasi/runtime/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ set_target_properties(dotnet PROPERTIES COMPILE_FLAGS ${CONFIGURATION_WASICC_FLA
1414

1515
target_link_libraries(dotnet
1616
PRIVATE
17-
${CMAKE_SYSROOT}/lib/wasm32-wasi/libc++.a
18-
${CMAKE_SYSROOT}/lib/wasm32-wasi/libc++abi.a
17+
${CMAKE_SYSROOT}/lib/wasm32-wasip2/libc++.a
18+
${CMAKE_SYSROOT}/lib/wasm32-wasip2/libc++abi.a
1919
${ICU_LIB_DIR}/libicudata.a
2020
${ICU_LIB_DIR}/libicuuc.a
2121
${ICU_LIB_DIR}/libicui18n.a

0 commit comments

Comments
 (0)