diff --git a/eng/native/gen-buildsys.cmd b/eng/native/gen-buildsys.cmd index 2f1ef10a51e40..b81ef55cbe49b 100644 --- a/eng/native/gen-buildsys.cmd +++ b/eng/native/gen-buildsys.cmd @@ -60,20 +60,19 @@ if /i "%__Arch%" == "wasm" ( set __UseEmcmake=1 ) if /i "%__Os%" == "wasi" ( - set "__repoRoot=!__repoRoot:\=/!" - if "%WASI_SDK22_PATH%" == "" ( + if "%WASI_SDK_PATH%" == "" ( if not exist "%__repoRoot%\src\mono\wasi\wasi-sdk" ( - echo Error: Should set WASI_SDK22_PATH environment variable pointing to WASI SDK root. + echo Error: Should set WASI_SDK_PATH environment variable pointing to WASI SDK root. exit /B 1 ) - set "WASI_SDK22_PATH=%__repoRoot%\src\mono\wasi\wasi-sdk" + set "WASI_SDK_PATH=%__repoRoot%\src\mono\wasi\wasi-sdk" ) :: replace backslash with forward slash and append last slash - set "WASI_SDK22_PATH=!WASI_SDK22_PATH:\=/!" - if not "!WASI_SDK22_PATH:~-1!" == "/" set "WASI_SDK22_PATH=!WASI_SDK22_PATH!/" + set "WASI_SDK_PATH=!WASI_SDK_PATH:\=/!" + if not "!WASI_SDK_PATH:~-1!" == "/" set "WASI_SDK_PATH=!WASI_SDK_PATH!/" set __CmakeGenerator=Ninja - set __ExtraCmakeParams=%__ExtraCmakeParams% -DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm "-DWASI_SDK_PREFIX=!WASI_SDK22_PATH!" "-DCMAKE_TOOLCHAIN_FILE=!WASI_SDK22_PATH!share/cmake/wasi-sdk.cmake" "-DCMAKE_SYSROOT=!WASI_SDK22_PATH!share/wasi-sysroot" + 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" ) ) else ( set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_SYSTEM_VERSION=10.0" diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index c4d79110b8c82..4c1ed0943c45a 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -4,7 +4,6 @@ # scriptroot="$( cd -P "$( dirname "$0" )" && pwd )" -reporoot="$(cd "$scriptroot"/../..; pwd -P)" if [[ "$#" -lt 4 ]]; then echo "Usage..." @@ -98,7 +97,7 @@ if [[ "$host_arch" == "wasm" ]]; then if [[ "$target_os" == "browser" ]]; then cmake_command="emcmake $cmake_command" elif [[ "$target_os" == "wasi" ]]; then - cmake_extra_defines="$cmake_extra_defines -DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$WASI_SDK22_PATH -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK22_PATH}share/cmake/wasi-sdk.cmake" "-DCMAKE_SYSROOT=${WASI_SDK22_PATH}share/wasi-sysroot" + true else echo "target_os was not specified" exit 1 diff --git a/eng/testing/tests.wasi.targets b/eng/testing/tests.wasi.targets index 4aa0b76692dee..d7183c26cb597 100644 --- a/eng/testing/tests.wasi.targets +++ b/eng/testing/tests.wasi.targets @@ -13,8 +13,7 @@ >true - $([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasi', 'wasi-sdk')) - $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK22_PATH)').Replace('\', '/')) + $([MSBuild]::NormalizeDirectory($(MonoProjectRoot), 'wasi', 'wasi-sdk')) <_BundleAOTTestWasmAppForHelixDependsOn>$(_BundleAOTTestWasmAppForHelixDependsOn);PrepareForWasiBuildApp;_PrepareForAOTOnHelix diff --git a/src/libraries/sendtohelix-wasi.targets b/src/libraries/sendtohelix-wasi.targets index dff72dccfe949..ff1b8f17b277f 100644 --- a/src/libraries/sendtohelix-wasi.targets +++ b/src/libraries/sendtohelix-wasi.targets @@ -46,8 +46,7 @@ false false - $([MSBuild]::NormalizeDirectory($(RepoRoot), 'src', 'mono', 'wasi', 'wasi-sdk')) - $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK22_PATH)').Replace('\', '/')) + $(RepoRoot)src\mono\wasi\wasi-sdk\ $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasi', 'build')) $(HelixDependenciesStagingPath)$(WorkItemPrefix)wasi-sdk $(HelixDependenciesStagingPath)$(WorkItemPrefix)wasmtime @@ -64,7 +63,7 @@ - + @@ -74,7 +73,7 @@ - + @@ -83,7 +82,7 @@ - + @@ -93,8 +92,8 @@ - - + + diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 4d44b54312bcb..3608f1cae63d0 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -355,7 +355,7 @@ diff --git a/src/mono/Directory.Build.props b/src/mono/Directory.Build.props index 5181dd77d674e..d97bf84a1da66 100644 --- a/src/mono/Directory.Build.props +++ b/src/mono/Directory.Build.props @@ -32,11 +32,14 @@ $(ProvisionEmscriptenDir.Replace('\', '/')) - + - $([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk')) - $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK22_PATH)').Replace('\', '/')) - true + + $([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk')) + $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) + true diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 6166d92f8f487..ceb783599086e 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -125,7 +125,7 @@ - + @@ -302,7 +302,7 @@ JS_ENGINES = [NODE_JS] - + @@ -317,36 +317,20 @@ JS_ENGINES = [NODE_JS] https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0.m-mingw.tar.gz - - + - - - - - - - - + @@ -356,7 +340,7 @@ JS_ENGINES = [NODE_JS] %(_ActualVersionLines.Identity) %(_ExpectedVersionLines.Identity) - @@ -738,14 +722,13 @@ JS_ENGINES = [NODE_JS] $([MSBuild]::EnsureTrailingSlash('$(EMSDK_PATH)').Replace('\', '/')) - $([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi', 'wasi-sdk')) - $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK22_PATH)').Replace('\', '/')) + $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) <_EmsdkEnvScriptPath>$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env$(ScriptExt)')) <_MonoCMakeConfigureCommand>cmake @(_MonoCMakeArgs, ' ') $(MonoCMakeExtraArgs) "$(MonoProjectRoot.TrimEnd('\/'))" <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoSkipInitCompiler)' != 'true' and '$(HostOS)' != 'windows'">sh -c 'build_arch="$(_CompilerTargetArch)" compiler="$(MonoCCompiler)" . "$(RepositoryEngineeringCommonDir)native/init-compiler.sh" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand)' <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(_MonoSkipInitCompiler)' == 'true' and '$(HostOS)' != 'windows'">$(_MonoCCOption) $(_MonoCXXOption) @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) - <_MonoCMakeConfigureCommand Condition="'$(TargetsWasi)' == 'true'">$(_MonoCMakeConfigureCommand) -DWASI_SDK_PREFIX=$(WASI_SDK22_PATH) -DCMAKE_SYSROOT=$(WASI_SDK22_PATH)share/wasi-sysroot -DCMAKE_TOOLCHAIN_FILE=$(WASI_SDK22_PATH)share/cmake/wasi-sdk.cmake -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK22_PATH)share/wasi-sysroot" + <_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 Condition="'$(TargetsBrowser)' != 'true' and '$(TargetsWasi)' != 'true' and '$(HostOS)' == 'windows'">call "$(RepositoryEngineeringDir)native\init-vs-env.cmd" $(_CompilerTargetArch) && cd /D "$(MonoObjDir)" && @(_MonoBuildEnv, ' ') $(_MonoCMakeConfigureCommand) <_MonoCMakeConfigureCommand Condition="'$(TargetsBrowser)' == 'true' and '$(HostOS)' != 'windows'">bash -c 'source $(_EmsdkEnvScriptPath) 2>&1 && emcmake $(_MonoCMakeConfigureCommand)' @@ -941,7 +924,7 @@ JS_ENGINES = [NODE_JS] - + diff --git a/src/mono/wasi/build/WasiSdk.Defaults.props b/src/mono/wasi/build/WasiSdk.Defaults.props index 4958eae7c8fdb..eeebd23130e8d 100644 --- a/src/mono/wasi/build/WasiSdk.Defaults.props +++ b/src/mono/wasi/build/WasiSdk.Defaults.props @@ -1,12 +1,11 @@ - $([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), '..', 'wasi-sdk')) - $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK22_PATH)').Replace('\', '/')) - $([MSBuild]::NormalizeDirectory($(WASI_SDK22_PATH), 'share', 'wasi-sysroot')) - $(WASI_SDK22_PATH)bin/clang + $(WASI_SDK_PATH) + $([MSBuild]::NormalizeDirectory($(WasiSdkRoot), 'share', 'wasi-sysroot')) + $(WasiSdkRoot)\bin\clang $(WasiClang).exe - $([MSBuild]::NormalizeDirectory($(WASI_SDK22_PATH), 'bin')) + $([MSBuild]::NormalizeDirectory($(WasiSdkRoot), 'bin')) diff --git a/src/mono/wasi/provision.ps1 b/src/mono/wasi/provision.ps1 index 1a6f40cb462de..ff336ef4bc22b 100644 --- a/src/mono/wasi/provision.ps1 +++ b/src/mono/wasi/provision.ps1 @@ -17,11 +17,3 @@ Invoke-WebRequest -Uri $WasiSdkUrl -OutFile ./wasi-sdk-$WasiSdkVersion.0-mingw.t tar --strip-components=1 -xzf ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz -C $WasiSdkPath Copy-Item $WasiLocalPath/wasi-sdk-version.txt $WasiSdkPath/wasi-sdk-version.txt Remove-Item ./wasi-sdk-$WasiSdkVersion.0-mingw.tar.gz -fo - -# Temporary WASI-SDK 22 workaround #2: The version of `wasm-component-ld` that -# ships with WASI-SDK 22 contains a -# [bug](https://github.com/bytecodealliance/wasm-component-ld/issues/22) which -# has been fixed in a v0.5.3 of that utility, so we upgrade it here. -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 -Expand-Archive -LiteralPath wasm-component-ld-v0.5.3-x86_64-windows.zip -DestinationPath . -Copy-Item wasm-component-ld-v0.5.3-x86_64-windows/wasm-component-ld.exe $WasiSdkPath/bin \ No newline at end of file diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 7b50cd016833a..99bf8a6ee54f8 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -19,18 +19,17 @@ <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp false - $([MSBuild]::NormalizeDirectory($(MSBuildThisFileDirectory), 'wasi-sdk')) - $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK22_PATH)').Replace('\', '/')) - $(WASI_SDK22_PATH)bin/clang + $(WASI_SDK_PATH) + $(WasiSdkRoot)\bin\clang $(WasiClang).exe - $(WASI_SDK22_PATH)bin/llvm-ar + $(WasiSdkRoot)\bin\llvm-ar $(WasiLLVMAr).exe - + @@ -206,6 +205,8 @@ $(WasiObjDir)\pinvoke-table.h $(WasiObjDir)\wasm_m2n_invoke.g.h + $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK_PATH)').Replace('\', '/')) + -g -Os -DDEBUG=1 -DENABLE_AOT_PROFILER=1 -Oz @@ -215,10 +216,10 @@ cmake $(MSBuildThisFileDirectory)runtime cmake -G Ninja $(MSBuildThisFileDirectory)runtime - $(CMakeBuildRuntimeConfigureCmd) --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE="$([MSBuild]::NormalizePath('$(WASI_SDK22_PATH)', 'share/cmake/wasi-sdk.cmake'))" - $(CMakeBuildRuntimeConfigureCmd) -DWASI_SDK_PREFIX=$(WASI_SDK22_PATH) - $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_SYSROOT=$(WASI_SDK22_PATH)share/wasi-sysroot - $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK22_PATH)share/wasi-sysroot" + $(CMakeBuildRuntimeConfigureCmd) --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE="$([MSBuild]::NormalizePath('$(WASI_SDK_PATH)', 'share/cmake/wasi-sdk.cmake'))" + $(CMakeBuildRuntimeConfigureCmd) -DWASI_SDK_PREFIX=$(WASI_SDK_PATH) + $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_SYSROOT=$(WASI_SDK_PATH)share/wasi-sysroot + $(CMakeBuildRuntimeConfigureCmd) -DCMAKE_CXX_FLAGS="--sysroot=$(WASI_SDK_PATH)share/wasi-sysroot" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_WASICC_FLAGS="$(CMakeConfigurationWasiFlags)" $(CMakeBuildRuntimeConfigureCmd) -DCONFIGURATION_LINK_FLAGS="$(CMakeConfigurationLinkFlags)" diff --git a/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs b/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs index 25d96339c8cb2..e2cf9b3dbf8b4 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Common/EnvironmentVariables.cs @@ -23,7 +23,7 @@ internal static class EnvironmentVariables internal static readonly bool ShowBuildOutput = IsRunningOnCI || Environment.GetEnvironmentVariable("SHOW_BUILD_OUTPUT") is not null; internal static readonly bool UseWebcil = Environment.GetEnvironmentVariable("USE_WEBCIL_FOR_TESTS") is "true"; internal static readonly string? SdkDirName = Environment.GetEnvironmentVariable("SDK_DIR_NAME"); - internal static readonly string? WasiSdkPath = Environment.GetEnvironmentVariable("WASI_SDK22_PATH"); + internal static readonly string? WasiSdkPath = Environment.GetEnvironmentVariable("WASI_SDK_PATH"); internal static readonly bool WorkloadsTestPreviousVersions = Environment.GetEnvironmentVariable("WORKLOADS_TEST_PREVIOUS_VERSIONS") is "true"; } } diff --git a/src/mono/wasm/build/WasmApp.LocalBuild.props b/src/mono/wasm/build/WasmApp.LocalBuild.props index bfdbdce919f65..3c81958b03722 100644 --- a/src/mono/wasm/build/WasmApp.LocalBuild.props +++ b/src/mono/wasm/build/WasmApp.LocalBuild.props @@ -30,8 +30,7 @@ $(RuntimeSrcDir)\artifacts\bin\ $(RuntimeSrcDir)\src\mono\browser\emsdk\ - $([MSBuild]::NormalizeDirectory($(RuntimeSrcDir), 'src', 'mono', 'wasi', 'wasi-sdk')) - $([MSBuild]::EnsureTrailingSlash('$(WASI_SDK22_PATH)').Replace('\', '/')) + $(RuntimeSrcDir)\src\mono\wasi\wasi-sdk\ $([MSBuild]::NormalizeDirectory($(ArtifactsBinDir), 'microsoft.netcore.app.runtime.$(RuntimeIdentifier)', $(RuntimeConfig))) diff --git a/src/mono/wasm/data/aot-tests/Directory.Build.props b/src/mono/wasm/data/aot-tests/Directory.Build.props index 4f6672b647b7d..c52f8028de5b1 100644 --- a/src/mono/wasm/data/aot-tests/Directory.Build.props +++ b/src/mono/wasm/data/aot-tests/Directory.Build.props @@ -10,7 +10,7 @@ <_WasmTargetsDir>$(WasmBuildSupportDir)\wasm\ <_WasmSharedDir>$(WasmBuildSupportDir)\wasm-shared\ $(WasmBuildSupportDir)\emsdk\ - $(WasmBuildSupportDir)\wasi-sdk\ + $(WasmBuildSupportDir)\wasi-sdk\ diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index bda22dc50d63f..d3fefa7685a97 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -65,18 +65,18 @@ if [[ "$__TargetOS" == browser ]]; then source "$EMSDK_PATH"/emsdk_env.sh export CLR_CC=$(which emcc) elif [[ "$__TargetOS" == wasi ]]; then - if [[ -z "$WASI_SDK22_PATH" ]]; then + if [[ -z "$WASI_SDK_PATH" ]]; then if [[ -d "$__RepoRootDir"/src/mono/wasi/wasi-sdk ]]; then - export WASI_SDK22_PATH="$__RepoRootDir"/src/mono/wasi/wasi-sdk + export WASI_SDK_PATH="$__RepoRootDir"/src/mono/wasi/wasi-sdk else - echo "Error: You need to set the WASI_SDK22_PATH environment variable pointing to the WASI SDK root." + echo "Error: You need to set the WASI_SDK_PATH environment variable pointing to the WASI SDK root." exit 1 fi fi - export WASI_SDK22_PATH="${WASI_SDK22_PATH%/}/" - export CLR_CC="$WASI_SDK22_PATH"bin/clang + export WASI_SDK_PATH="${WASI_SDK_PATH%/}/" + export CLR_CC="$WASI_SDK_PATH"bin/clang export TARGET_BUILD_ARCH=wasm - __CMakeArgs="-DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$WASI_SDK22_PATH -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK22_PATH}share/cmake/wasi-sdk.cmake $__CMakeArgs" + __CMakeArgs="-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 $__CMakeArgs" elif [[ "$__TargetOS" == ios || "$__TargetOS" == iossimulator ]]; then # nothing to do here true