Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT-LLVM] add support for building WASI and browser debug & release on Linux #2605

Merged
merged 44 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c548c19
Add Linux WASI and browser jobs
yowl Jul 30, 2024
3851fb9
remove test file
yowl Jul 30, 2024
2d11a40
attempt to add the publishing platforms
yowl Jul 30, 2024
252de09
Address feedback
yowl Aug 8, 2024
956b5a2
update a few more platform names
yowl Aug 8, 2024
d63c3a9
revert publish changes
yowl Aug 8, 2024
e6a2f60
hard code container in matrix
yowl Aug 8, 2024
e3d1d02
remove container from runtimelab.yml
yowl Aug 8, 2024
7cdb862
reinstate and rename script extension as emcc does not use `.sh` on l…
yowl Aug 8, 2024
65eba09
update platform name
yowl Aug 8, 2024
7b9e291
Merge remote-tracking branch 'origin/feature/NativeAOT-LLVM' into lin…
yowl Aug 14, 2024
6aa3cc2
linux install of wasmtime
yowl Aug 15, 2024
a1ad87d
Set NATIVEAOT_CI_WASM_BUILD_EMSDK_PATH
yowl Aug 16, 2024
8bf20e9
remove NATIVEAOT_CI_WASM_BUILD_EMSDK_PATH, use EMSDK
yowl Aug 16, 2024
ede31c0
log EMSDK and use Write-Output
yowl Aug 16, 2024
918c041
Add CI parameter
yowl Aug 16, 2024
07d7a43
fix syntax
yowl Aug 16, 2024
2af3505
sync with yml
yowl Aug 16, 2024
a5c8cc9
use InstallDir/emsdk
yowl Aug 16, 2024
bd5aac5
include native for browser
yowl Aug 17, 2024
589aed9
Update eng/testing/FindWasmHostExecutable.sh
yowl Aug 18, 2024
22f145b
Remove libtinfo dependency
yowl Aug 19, 2024
67a40f1
Change container, dropp ROOTFS env
yowl Aug 19, 2024
199f246
take upstream #106569
yowl Aug 19, 2024
7451bbb
Revert "take upstream #106569"
yowl Aug 19, 2024
41331b4
Revert "take upstream #106569"
yowl Aug 20, 2024
775b6ee
take upstream #106569
yowl Aug 20, 2024
80695e0
Update eng/pipelines/runtimelab/install-llvm.ps1
yowl Aug 20, 2024
186f8ca
remove -DCMAKE_SYSTEM_NAME
yowl Aug 20, 2024
7f5ed09
Merge branch 'linux-x64-jobs' of https://github.com/yowl/runtimelab i…
yowl Aug 20, 2024
87552df
address some feedback - try to remove TestWrapperTargetsWindows
yowl Aug 21, 2024
d4f0b94
Update src/tests/Common/scripts/nativeaottest.sh
yowl Aug 22, 2024
04294da
feedback - redundant.
yowl Aug 22, 2024
21ac4f7
Merge branch 'linux-x64-jobs' of https://github.com/yowl/runtimelab i…
yowl Aug 22, 2024
bc4e580
simplify script
yowl Aug 22, 2024
d5c980f
Try removing call to emsdk_env
yowl Aug 22, 2024
2234927
remove empty lines
yowl Aug 22, 2024
2142e30
add logging
yowl Aug 22, 2024
87fdc26
try remove more emsdk_env
yowl Aug 22, 2024
35c9e1d
add back emsdk
yowl Aug 22, 2024
34371cf
Update src/tests/build.proj
yowl Aug 23, 2024
eb95f4e
Update src/tests/build.sh - thanks
yowl Aug 23, 2024
bd93b70
remove unwanted browser check
yowl Aug 23, 2024
c234965
Merge branch 'linux-x64-jobs' of https://github.com/yowl/runtimelab i…
yowl Aug 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@ if is_cygwin_or_mingw; then
scriptroot=$(cygpath -d "$scriptroot")
powershell -c "$scriptroot\\build.cmd" $@
else
if [[ "$*" == *"wasm"* && "$*" == *"-ci"* ]]; then
# This is a bit of a workaround for the fact that the pipelines do not have a great
# way of preserving the environment between scripts. Set by install-emscripten.ps1.
if [[ -n $EMSDK ]]; then
source $EMSDK/emsdk_env.sh
fi
fi
"$scriptroot/eng/build.sh" $@
fi
2 changes: 1 addition & 1 deletion eng/native/tryrun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if(DARWIN)
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
endif()
elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86|x64)$" OR FREEBSD OR ILLUMOS OR TIZEN OR HAIKU)
elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86|x64|wasm)$" OR FREEBSD OR ILLUMOS OR TIZEN OR HAIKU)
set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0)
set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 0)
set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0)
Expand Down
19 changes: 11 additions & 8 deletions eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,22 +210,25 @@ jobs:

# Install Wasm dependencies: emscripten, LLVM, NodeJS
- ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.archType, 'wasm')) }}:
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-emscripten.ps1 $(Build.SourcesDirectory)/wasm-tools
displayName: Install/activate emscripten
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/set-cmake-path.cmd
displayName: Set CMake path
# Install Powershell on OSes that don't come with it by default
- ${{ if ne(parameters.hostedOs, 'windows') }}:
- script: $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-pwsh.sh $(Build.SourcesDirectory)/wasm-tools
displayName: Install Powershell 7
- script: $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-python.sh $(Build.SourcesDirectory)/wasm-tools
displayName: set PYTHON3
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-emscripten.ps1 $(Build.SourcesDirectory)/wasm-tools -CI
displayName: Install/activate emscripten
- ${{ if eq(parameters.hostedOs, 'windows') }}:
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/set-cmake-path.cmd
displayName: Set CMake path
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-llvm.ps1 -CloneDir $(Build.SourcesDirectory)/wasm-tools -Configs ${{ parameters.buildConfig }} -CI
displayName: Install/build LLVM
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-nodejs.ps1 $(Build.SourcesDirectory)\wasm-tools
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-nodejs.ps1 $(Build.SourcesDirectory)/wasm-tools
displayName: Install NodeJS

- ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.platform, 'wasi_wasm_win')) }}:
# Install Wasi Wasm dependencies: wasi-sdk, wasmer
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-wasi-sdk.cmd $(Build.SourcesDirectory)\wasm-tools
- ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), or(eq(parameters.platform, 'wasi_wasm_win'), eq(parameters.platform, 'wasi_wasm_linux_x64_naot_llvm'))) }}:
# Install Wasi Wasm dependencies: wasi-sdk, wasmtime
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-wasi-sdk.ps1 -CI -InstallDir $(Build.SourcesDirectory)/wasm-tools
displayName: Install wasi-sdk
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-wasmtime.ps1 -CI -InstallDir $(Build.SourcesDirectory)/wasm-tools
displayName: Install wasmtime
Expand Down
42 changes: 42 additions & 0 deletions eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,48 @@ jobs:
buildConfig: ${{ parameters.buildConfig }}
${{ insert }}: ${{ parameters.jobParameters }}

# Browser WebAssembly Linux X64 for NAOT-LLVM

- ${{ if containsValue(parameters.platforms, 'Browser_wasm_linux_x64_naot_llvm') }}:
- template: xplat-setup.yml
parameters:
jobTemplate: ${{ parameters.jobTemplate }}
helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }}
variables: ${{ parameters.variables }}
osGroup: browser
archType: wasm
targetRid: browser-wasm
platform: Browser_wasm_linux_x64_naot_llvm
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
container: linux_x64_sanitizer
jobParameters:
hostedOs: linux
runtimeFlavor: ${{ parameters.runtimeFlavor }}
stagedBuild: ${{ parameters.stagedBuild }}
buildConfig: ${{ parameters.buildConfig }}
${{ insert }}: ${{ parameters.jobParameters }}

# WASI WebAssembly Linux X64 for NAOT-LLVM

- ${{ if containsValue(parameters.platforms, 'wasi_wasm_linux_x64_naot_llvm') }}:
- template: xplat-setup.yml
parameters:
jobTemplate: ${{ parameters.jobTemplate }}
helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }}
variables: ${{ parameters.variables }}
osGroup: wasi
archType: wasm
targetRid: wasi-wasm
platform: wasi_wasm_linux_x64_naot_llvm
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
container: linux_x64_sanitizer
jobParameters:
hostedOs: linux
runtimeFlavor: ${{ parameters.runtimeFlavor }}
stagedBuild: ${{ parameters.stagedBuild }}
buildConfig: ${{ parameters.buildConfig }}
${{ insert }}: ${{ parameters.jobParameters }}

# Browser WebAssembly

- ${{ if containsValue(parameters.platforms, 'browser_wasm') }}:
Expand Down
6 changes: 6 additions & 0 deletions eng/pipelines/runtimelab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ extends:
- windows_x64
- Browser_wasm_win
- wasi_wasm_win
# Use a different name to differentiate from upstream as we need the -sanitizer image to get build tools that are not present in the stock wasi-wasm image.
- Browser_wasm_linux_x64_naot_llvm
- wasi_wasm_linux_x64_naot_llvm
jobParameters:
timeoutInMinutes: 300
buildArgs: -s clr.aot+libs+nativeaot.packages -c debug -rc $(_BuildConfig)
Expand Down Expand Up @@ -104,6 +107,9 @@ extends:
- windows_x64
- Browser_wasm_win
- wasi_wasm_win
# Use a different name to differentiate from upstream as we need the -sanitizer image to get build tools that are not present in the stock wasi-wasm image.
- wasi_wasm_linux_x64_naot_llvm
- Browser_wasm_linux_x64_naot_llvm
jobParameters:
timeoutInMinutes: 300
buildArgs: -s clr.aot+libs+nativeaot.packages -c $(_BuildConfig) /p:ArchiveTests=true
Expand Down
11 changes: 9 additions & 2 deletions eng/pipelines/runtimelab/install-emscripten.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
param(
$InstallDir
$InstallDir,
[switch]$CI
)

$ErrorActionPreference="Stop"
Expand All @@ -17,4 +18,10 @@ git checkout ca7b40ae222a2d8763b6ac845388744b0e57cfb7
./emsdk install 3.1.56
./emsdk activate 3.1.56

Write-Host "##vso[task.setvariable variable=EMSDK]$env:EMSDK"

if ($CI)
{
Write-Host "Setting EMSDK to '$InstallDir/emsdk'"
Write-Output "##vso[task.setvariable variable=EMSDK]$InstallDir/emsdk"
}

26 changes: 25 additions & 1 deletion eng/pipelines/runtimelab/install-llvm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ else
git clone https://github.com/llvm/llvm-project --branch $LlvmProjectTag $DepthOption
}


# Set the compiler for CI on non-Windows
if (!$IsWindows) {
$RepoDir = Split-path $PSScriptRoot | Split-Path | Split-Path

bash -c "build_arch=amd64 compiler=clang source $RepoDir/eng/common/native/init-compiler.sh && set | grep -e CC -e CXX -e LDFLAGS" |
ForEach-Object {
if ($CI)
{
# Split the "<name>=<value>" line into the variable's name and value.
$name, $value = $_ -split '=', 2
# Define it as a process-level environment variable in PowerShell.
Set-Content ENV:$name $value
}
}
}

# There is no [C/c]hecked LLVM config, so change to Debug
foreach ($Config in $Configs | % { if ($_ -eq "Checked") { "Debug" } else { $_ } } | Select-Object -Unique)
{
Expand All @@ -71,7 +88,7 @@ foreach ($Config in $Configs | % { if ($_ -eq "Checked") { "Debug" } else { $_ }
$CmakeGenerator = "Unix Makefiles"
}

$CmakeConfigureCommandLine = "-G", "$CmakeGenerator", "-DLLVM_INCLUDE_BENCHMARKS=OFF"
$CmakeConfigureCommandLine = "-G", "$CmakeGenerator", "-DLLVM_INCLUDE_BENCHMARKS=OFF", "-DLLVM_ENABLE_TERMINFO=0"
$CmakeConfigureCommandLine += "-S", $SourceDirName, "-B", $BuildDirPath
if ($Config -eq "Release")
{
Expand All @@ -90,6 +107,11 @@ foreach ($Config in $Configs | % { if ($_ -eq "Checked") { "Debug" } else { $_ }
}
}
$CmakeConfigureCommandLine += "-DCMAKE_BUILD_TYPE=$LlvmConfig"

if (!$IsWindows)
{
$CmakeConfigureCommandLine += "-DCMAKE_SYSROOT=/crossrootfs/x64", "-DCMAKE_INSTALL_PREFIX=/usr/local/llvm-cross"
}

Write-Host "Invoking CMake configure: 'cmake $CmakeConfigureCommandLine'"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging deleted intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, thanks

cmake @CmakeConfigureCommandLine
Expand Down Expand Up @@ -118,6 +140,8 @@ foreach ($Config in $Configs | % { if ($_ -eq "Checked") { "Debug" } else { $_ }
if ($CI)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($CI)
Write-Host "Setting $LlvmCmakeConfigEnvVarName to '$LlvmCmakeConfigPath'"
if ($CI)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

{
Write-Output "##vso[task.setvariable variable=$LlvmCmakeConfigEnvVarName]$LlvmCmakeConfigPath"
# We need LLVM_DIR for Linux
Write-Output "##vso[task.setvariable variable=LLVM_DIR]$LlvmCmakeConfigPath"
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions eng/pipelines/runtimelab/install-pwsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ tar zxf powershell.tar.gz -C powershell7
# Set execute permissions
chmod +x powershell7/pwsh

echo setting PATH
echo ##vso[task.setvariable variable=PATH]$PATH:$1/powershell7
echo setting PATH $PATH:$1/powershell7
echo '##vso[task.setvariable variable=PATH]'$PATH:$1/powershell7
3 changes: 3 additions & 0 deletions eng/pipelines/runtimelab/install-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

echo '##vso[task.setvariable variable=EMSDK_PYTHON]'/usr/bin/python3
25 changes: 22 additions & 3 deletions eng/pipelines/runtimelab/install-wasi-sdk.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
$WasiSdkVersion = 24
param(
$InstallDir,
[switch]$CI
)

$WasiSdkVersion = 24
Set-Location -Path $InstallDir
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"

Expand All @@ -11,13 +16,27 @@ if ($WasiSdkVersion -lt [int]$UpstreamWasiSdkVersion)
exit
}

$WasiSdkHost = "x86_64-windows"
if ($IsWindows)
{
$WasiSdkHost = "x86_64-windows"
}
else
{
$WasiSdkHost = "x86_64-linux"
}
$WasiSdkDirName = "wasi-sdk-$WasiSdkVersion.0-$WasiSdkHost"
$WasiSdkGzFile = "$WasiSdkDirName.tar.gz"
Invoke-WebRequest -Uri "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WasiSdkVersion/$WasiSdkGzFile" -OutFile $WasiSdkGzFile

Invoke-WebRequest -Uri https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WasiSdkVersion/$WasiSdkGzFile -OutFile $WasiSdkGzFile

tar -xzf $WasiSdkGzFile
mv $WasiSdkDirName wasi-sdk

# The upstream build expects this sentinel to exist, otherwise it tries to use a provisioned SDK.
$WasiSdkVersion > wasi-sdk/"VERSION$("$WasiSdkVersion".ToUpper())"

if ($CI)
{
Write-Host "Setting WASI_SDK_PATH to '$InstallDir/wasi-sdk'"
Write-Output "##vso[task.setvariable variable=WASI_SDK_PATH]$InstallDir/wasi-sdk"
}
34 changes: 30 additions & 4 deletions eng/pipelines/runtimelab/install-wasmtime.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,37 @@ $ProgressPreference = "SilentlyContinue"
Set-Location $InstallDir

$WasmtimeVersion = "v21.0.1"
$WasmtimeFolderName = "wasmtime-$WasmtimeVersion-x86_64-windows"
Invoke-WebRequest -Uri https://github.com/bytecodealliance/wasmtime/releases/download/v21.0.1/$WasmtimeFolderName.zip -OutFile wasmtime.zip
Expand-Archive -LiteralPath wasmtime.zip -DestinationPath .

if (!(Test-Path variable:global:IsWindows))
{
$IsWindows = [Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT
}

if ($IsWIndows)
{
$WasmtimeBaseName = "wasmtime-$WasmtimeVersion-x86_64-windows"
$WasmtimeArchive = "$WasmtimeBaseName.zip"
}
else
{
$WasmtimeBaseName = "wasmtime-$WasmtimeVersion-x86_64-linux"
$WasmtimeArchive = "$WasmtimeBaseName.tar.xz"
}

Invoke-WebRequest -Uri https://github.com/bytecodealliance/wasmtime/releases/download/$WasmtimeVersion/$WasmtimeArchive -OutFile $WasmtimeArchive
if ($IsWIndows)
{
Expand-Archive -LiteralPath $WasmtimeArchive -DestinationPath .
}
else
{
New-Item -ItemType Directory -Force -Path $WasmtimeBaseName
tar -xf $WasmtimeArchive -C $WasmtimeBaseName
}

if ($CI)
{
Write-Output "##vso[task.prependpath]$pwd/$WasmtimeFolderName"
Write-Host "Setting WASMTIME_EXECUTABLE to '$pwd/$WasmtimeBaseName/$WasmtimeBaseName/wasmtime'"
Write-Output "##vso[task.setvariable variable=WASMTIME_EXECUTABLE]$pwd/$WasmtimeBaseName/$WasmtimeBaseName/wasmtime"
Write-Output "##vso[task.prependpath]$pwd/$WasmtimeBaseName"
}
17 changes: 12 additions & 5 deletions eng/pipelines/runtimelab/runtimelab-post-build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ steps:
# Now we need to build the cross-targeting compilers, RyuJit and ILC. Likewise with packages.

- ${{ if eq(parameters.archType, 'wasm') }}:
- script: $(Build.SourcesDirectory)/build$(scriptExt) clr.wasmjit+clr.aot -c $(buildConfigUpper) $(_officialBuildParameter) -ci
- script: $(Build.SourcesDirectory)/build$(scriptExt) clr.wasmjit+clr.aot -c $(buildConfigUpper) $(_officialBuildParameter) -ci -cross
displayName: Build the ILC and RyuJit cross-compilers

- ${{ if and(eq(parameters.isOfficialBuild, true), eq(parameters.platform, 'browser_wasm_win')) }}:
Expand All @@ -34,9 +34,17 @@ steps:
displayName: Build WebAssembly tests
- ${{ elseif eq(parameters.platform, 'wasi_wasm_win') }}:
- script: |
call $(Build.SourcesDirectory)\wasm-tools\emsdk\emsdk_env
$(Build.SourcesDirectory)/src/tests/build$(scriptExt) nativeaot $(buildConfigUpper) ${{ parameters.archType }} wasi tree nativeaot /p:LibrariesConfiguration=${{ parameters.librariesConfiguration }}
displayName: Build WebAssembly tests
- ${{ elseif eq(parameters.platform, 'Browser_wasm_linux_x64_naot_llvm') }}:
- script: |
source $(Build.SourcesDirectory)/wasm-tools/emsdk/emsdk_env.sh
$(Build.SourcesDirectory)/src/tests/build$(scriptExt) nativeaot $(buildConfigUpper) -browser tree nativeaot /p:LibrariesConfiguration=${{ parameters.librariesConfiguration }}
displayName: Build WebAssembly tests
- ${{ elseif eq(parameters.platform, 'wasi_wasm_linux_x64_naot_llvm') }}:
- script: |
$(Build.SourcesDirectory)/src/tests/build$(scriptExt) nativeaot $(buildConfigUpper) -wasi tree nativeaot /p:LibrariesConfiguration=${{ parameters.librariesConfiguration }}
displayName: Build WebAssembly tests

- ${{ elseif eq(parameters.osGroup, 'windows') }}:
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) nativeaot $(buildConfigUpper) ${{ parameters.archType }} ${{ parameters.testFilter }} /p:NativeAotMultimodule=true /p:LibrariesConfiguration=${{ parameters.librariesConfiguration }}
Expand All @@ -52,15 +60,14 @@ steps:
$(Build.SourcesDirectory)/src/tests/run$(scriptExt) runnativeaottests $(buildConfigUpper) ${{ parameters.archType }} ${{ parameters.osGroup }}
displayName: Run WebAssembly tests in single file mode
- ${{ elseif eq(parameters.osGroup, 'windows') }}:
- script: $(Build.SourcesDirectory)/src/tests/run$(scriptExt) runnativeaottests $(buildConfigUpper) ${{ parameters.archType }}
- script: $(Build.SourcesDirectory)/src/tests/run$(scriptExt) runnativeaottests $(buildConfigUpper) ${{ parameters.archType }} ${{ parameters.osGroup }}
displayName: Run tests in single file mode
- ${{ else }}:
- script: $(Build.SourcesDirectory)/src/tests/run$(scriptExt) --runnativeaottests $(buildConfigUpper) ${{ parameters.archType }}
- script: $(Build.SourcesDirectory)/src/tests/run$(scriptExt) --runnativeaottests $(buildConfigUpper) ${{ parameters.archType }} ${{ parameters.osGroup }}
displayName: Run tests in single file mode

- ${{ if eq(parameters.archType, 'wasm') }}:
- script: |
call $(Build.SourcesDirectory)\wasm-tools\emsdk\emsdk_env
$(Build.SourcesDirectory)/build$(scriptExt) libs.tests -test -a ${{ parameters.archType }} -os ${{ parameters.osGroup }} -lc ${{ parameters.librariesConfiguration }} -rc $(buildConfigUpper) /p:TestNativeAot=true /p:RunSmokeTestsOnly=true
displayName: Build and run WebAssembly libraries tests

Expand Down
27 changes: 27 additions & 0 deletions eng/testing/FindWasmHostExecutable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

exename=$(basename "$1" .wasm)
exename=$(basename "$exename" .dll)
exename=$(basename "$exename" .js)
dirname=$(dirname "$1")

node="node --stack_trace_limit=100"
WASM_HOST_ARGS_SEPERATOR=""

if [ -e "${dirname}/${exename}.js" ]; then
WASM_HOST_EXECUTABLE=$node
WASM_BINARY_TO_EXECUTE="${dirname}/${exename}.js"
elif [ -e "${dirname}/main.js" ]; then
WASM_HOST_EXECUTABLE=$node
WASM_BINARY_TO_EXECUTE="${dirname}/main.js"
elif [ -e "${dirname}/${exename}.mjs" ]; then
WASM_HOST_EXECUTABLE=$node
WASM_BINARY_TO_EXECUTE="${dirname}/${exename}.mjs"
elif [ -e "${dirname}/main.mjs" ]; then
WASM_HOST_EXECUTABLE=$node
WASM_BINARY_TO_EXECUTE="${dirname}/main.mjs"
elif [ -e "${dirname}/${exename}.wasm" ]; then
WASM_HOST_EXECUTABLE=$WASMTIME_EXECUTABLE
WASM_HOST_ARGS_SEPERATOR="--"
WASM_BINARY_TO_EXECUTE="${dirname}/${exename}.wasm"
fi
14 changes: 14 additions & 0 deletions eng/testing/FindWasmHostExecutableAndRun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)

source $SCRIPT_DIR/FindWasmHostExecutable.sh "$1"

if [ -n "${WASM_HOST_EXECUTABLE}" ]; then
shift
echo $WASM_HOST_EXECUTABLE "$WASM_BINARY_TO_EXECUTE" $WASM_HOST_ARGS_SEPERATOR "$@"
$WASM_HOST_EXECUTABLE "$WASM_BINARY_TO_EXECUTE" $WASM_HOST_ARGS_SEPERATOR "$@"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.cmd also logs the command it is about to run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added log, thanks.

else
echo WASM_HOST_EXECUTABLE not set.
exit 1
fi
Loading