diff options
author | Christian Scheuer <info@creatix.dk> | 2018-02-04 03:47:18 +0300 |
---|---|---|
committer | Morgan Brown <morganbr@users.noreply.github.com> | 2018-02-04 03:47:18 +0300 |
commit | f19daaae780f2b0b2675792a8b0ef071dc1e58ff (patch) | |
tree | 638ec60b9f3f2c538b9288a1f8ab32f8dc8f0048 /tests | |
parent | 2aaccdfc08dc2217bbc1777d4c98dda2a4867fb7 (diff) |
Add support for building wasm on OSX and Ubuntu 16 (#5297)
* Enable wasm building on OSX.
Upgrade libLLVM to 4.0.0 and LLVMSharp to 5.0.0
LLVM upgrade: Fix 'Use still stuck around after Def is destroyed' of the deleted basic blocks
Add wasm support in runtest.sh
Remove HelloWasm.csproj reference to .ilproj on non-windows OS because of dependency on ilasm
Fix LinkNative target to execute correct commands for Unix wasm builds.
Added support for building on Ubuntu 16.04.3
Update documentation on how to build WebAssembly.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runtest.sh | 47 | ||||
-rw-r--r-- | tests/src/Simple/HelloWasm/HelloWasm.csproj | 8 | ||||
-rw-r--r-- | tests/src/Simple/HelloWasm/Program.cs | 4 | ||||
-rw-r--r-- | tests/src/Simple/HelloWasm/no_unix | 1 | ||||
-rwxr-xr-x | tests/testenv.sh | 47 |
5 files changed, 75 insertions, 32 deletions
diff --git a/tests/runtest.sh b/tests/runtest.sh index 15bff4f2e..36d087023 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -41,6 +41,9 @@ run_test_dir() if [ "${__mode}" = "Cpp" ]; then __extra_args="${__extra_args} /p:NativeCodeGen=cpp" fi + if [ "${__mode}" = "Wasm" ]; then + __extra_args="${__extra_args} /p:NativeCodeGen=wasm" + fi if [ -n "${__extra_cxxflags}" ]; then __extra_cxxflags="/p:AdditionalCppCompilerFlags=\"${__extra_cxxflags}\"" fi @@ -176,6 +179,12 @@ while [ "$1" != "" ]; do usage exit 1 ;; + wasm) + CoreRT_BuildArch=wasm + CoreRT_BuildOS=WebAssembly + CoreRT_TestCompileMode=wasm + CoreRT_TestRun=false + ;; x86) CoreRT_BuildArch=x86 ;; @@ -319,7 +328,8 @@ __CppTotalTests=0 __CppPassedTests=0 __JitTotalTests=0 __JitPassedTests=0 - +__WasmTotalTests=0 +__WasmPassedTests=0 if [ ! -d ${__CoreRTTestBinDir} ]; then mkdir -p ${__CoreRTTestBinDir} @@ -330,20 +340,28 @@ __BuildOsLowcase=$(echo "${CoreRT_BuildOS}" | tr '[:upper:]' '[:lower:]') __TestSearchPath=${CoreRT_TestRoot}/src/Simple/${CoreRT_TestName} for csproj in $(find ${__TestSearchPath} -name "*.csproj") do - if [ ! -e `dirname ${csproj}`/no_unix ]; then - if [ "${CoreRT_TestCompileMode}" != "cpp" ]; then + if [ -e `dirname ${csproj}`/no_unix ]; then continue; fi + if [ -e `dirname ${csproj}`/no_linux ] && [ "${CoreRT_HostOS}" != "OSX" ]; then continue; fi + + if [ "${CoreRT_TestCompileMode}" = "ryujit" ] || [ "${CoreRT_TestCompileMode}" = "" ]; then + if [ ! -e `dirname ${csproj}`/no_ryujit ]; then run_test_dir ${csproj} "Jit" fi + fi + if [ "${CoreRT_TestCompileMode}" = "cpp" ] || [ "${CoreRT_TestCompileMode}" = "" ]; then if [ ! -e `dirname ${csproj}`/no_cpp ]; then - if [ "${CoreRT_TestCompileMode}" != "ryujit" ]; then - run_test_dir ${csproj} "Cpp" "$CoreRT_ExtraCXXFlags" "$CoreRT_ExtraLinkFlags" - fi + run_test_dir ${csproj} "Cpp" "$CoreRT_ExtraCXXFlags" "$CoreRT_ExtraLinkFlags" + fi + fi + if [ "${CoreRT_TestCompileMode}" = "wasm" ]; then + if [ -e `dirname ${csproj}`/wasm ]; then + run_test_dir ${csproj} "Wasm" fi fi done -__TotalTests=$((${__JitTotalTests} + ${__CppTotalTests})) -__PassedTests=$((${__JitPassedTests} + ${__CppPassedTests})) +__TotalTests=$((${__JitTotalTests} + ${__CppTotalTests} + ${__WasmTotalTests})) +__PassedTests=$((${__JitPassedTests} + ${__CppPassedTests} + ${__WasmPassedTests})) __FailedTests=$((${__TotalTests} - ${__PassedTests})) if [ "$CoreRT_MultiFileConfiguration" = "MultiModule" ]; then @@ -366,19 +384,26 @@ echo "</assemblies>" >> ${__TestResultsLog} echo "JIT - TOTAL: ${__JitTotalTests} PASSED: ${__JitPassedTests}" echo "CPP - TOTAL: ${__CppTotalTests} PASSED: ${__CppPassedTests}" +echo "WASM - TOTAL: ${__WasmTotalTests} PASSED: ${__WasmPassedTests}" -if [ ${__JitTotalTests} == 0 ]; then +if [ ${__JitTotalTests} == 0 ] && [ "${CoreRT_TestCompileMode}" != "wasm" ]; then exit 1 fi - -if [ ${__CppTotalTests} == 0 ]; then +if [ ${__CppTotalTests} == 0 ] && [ "${CoreRT_TestCompileMode}" != "wasm" ]; then exit 1 fi +if [ ${__WasmTotalTests} == 0 ] && [ "${CoreRT_TestCompileMode}" = "wasm" ]; then + exit 1 +fi + if [ ${__JitTotalTests} -gt ${__JitPassedTests} ]; then exit 1 fi if [ ${__CppTotalTests} -gt ${__CppPassedTests} ]; then exit 1 fi +if [ ${__WasmTotalTests} -gt ${__WasmPassedTests} ]; then + exit 1 +fi exit 0 diff --git a/tests/src/Simple/HelloWasm/HelloWasm.csproj b/tests/src/Simple/HelloWasm/HelloWasm.csproj index b767a5dbd..f070f287a 100644 --- a/tests/src/Simple/HelloWasm/HelloWasm.csproj +++ b/tests/src/Simple/HelloWasm/HelloWasm.csproj @@ -2,9 +2,13 @@ <ItemGroup> <Compile Include="*.cs" /> - <ProjectReference Include="CpObj.ilproj" /> - <IlcArg Include="-r:$(IntermediateOutputPath)\CpObj.dll" /> + <ProjectReference Include="CpObj.ilproj" Condition="'$(OS)' == 'Windows_NT'" /> + <IlcArg Include="-r:$(IntermediateOutputPath)\CpObj.dll" Condition="'$(OS)' == 'Windows_NT'" /> </ItemGroup> + <PropertyGroup Condition="'$(OS)' == 'Windows_NT'"> + <DefineConstants>PLATFORM_WINDOWS;$(DefineConstants)</DefineConstants> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" /> </Project> diff --git a/tests/src/Simple/HelloWasm/Program.cs b/tests/src/Simple/HelloWasm/Program.cs index 2800c7579..bb8962c12 100644 --- a/tests/src/Simple/HelloWasm/Program.cs +++ b/tests/src/Simple/HelloWasm/Program.cs @@ -4,7 +4,9 @@ using System; using System.Runtime.InteropServices; +#if PLATFORM_WINDOWS using CpObj; +#endif internal static class Program { @@ -122,6 +124,7 @@ internal static class Program PrintLine("SwitchOpDefault test: Ok."); } +#if PLATFORM_WINDOWS var cpObjTestA = new TestValue { Field = 1234 }; var cpObjTestB = new TestValue { Field = 5678 }; CpObjTest.CpObj(ref cpObjTestB, ref cpObjTestA); @@ -129,6 +132,7 @@ internal static class Program { PrintLine("CpObj test: Ok."); } +#endif Func<int> staticDelegate = StaticDelegateTarget; if(staticDelegate() == 7) diff --git a/tests/src/Simple/HelloWasm/no_unix b/tests/src/Simple/HelloWasm/no_unix deleted file mode 100644 index e6c22996c..000000000 --- a/tests/src/Simple/HelloWasm/no_unix +++ /dev/null @@ -1 +0,0 @@ -Doesn't work on OSX.
\ No newline at end of file diff --git a/tests/testenv.sh b/tests/testenv.sh index 69a636bca..bdf8765ce 100755 --- a/tests/testenv.sh +++ b/tests/testenv.sh @@ -14,6 +14,9 @@ for i in "$@" usage exit 1 ;; + wasm) + CoreRT_BuildArch=wasm + ;; x86) CoreRT_BuildArch=x86 ;; @@ -47,7 +50,7 @@ for i in "$@" done if [ -z ${CoreRT_BuildArch} ]; then - echo "Set CoreRT_BuildArch to x86/x64/arm/arm64" + echo "Set CoreRT_BuildArch to x86/x64/arm/arm64/wasm" exit -1 fi @@ -56,31 +59,39 @@ if [ -z ${CoreRT_BuildType} ]; then exit -1 fi + # Use uname to determine what the OS is. -OSName=$(uname -s) +export OSName=$(uname -s) case $OSName in - Darwin) - CoreRT_BuildOS=OSX - ;; + Darwin) + export CoreRT_HostOS=OSX + ;; - FreeBSD) - CoreRT_BuildOS=FreeBSD - ;; + FreeBSD) + export CoreRT_HostOS=FreeBSD + ;; - Linux) - CoreRT_BuildOS=Linux - ;; + Linux) + export CoreRT_HostOS=Linux + ;; - NetBSD) - CoreRT_BuildOS=NetBSD - ;; + NetBSD) + export CoreRT_HostOS=NetBSD + ;; - *) - echo "Unsupported OS $OSName detected, configuring as if for Linux" - CoreRT_BuildOS=Linux - ;; + *) + echo "Unsupported OS $OSName detected, configuring as if for Linux" + export CoreRT_HostOS=Linux + ;; esac +export CoreRT_BuildOS=${CoreRT_HostOS} + +# Overwrite __BuildOS with WebAssembly if wasm is target build arch, but keep the CoreRT_HostOS to match the Host OS +if [ $__BuildArch == "wasm" ]; then + export CoreRT_BuildOS=WebAssembly +fi + export CoreRT_BuildArch export CoreRT_BuildType export CoreRT_BuildOS |