From 57af89b42df08e336ff90987c52b7a3d20ae4488 Mon Sep 17 00:00:00 2001 From: Wang Jikai Date: Mon, 21 Aug 2023 09:51:30 +0800 Subject: [PATCH 1/2] Add process for Windows MSVC build. Signed-off-by: Wang Jikai --- docs/contribute/source/os/windows.md | 29 ++++++++++++------- .../current/contribute/source/os/windows.md | 29 ++++++++++++------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/docs/contribute/source/os/windows.md b/docs/contribute/source/os/windows.md index 4bf7423a4..343bb844d 100644 --- a/docs/contribute/source/os/windows.md +++ b/docs/contribute/source/os/windows.md @@ -26,6 +26,9 @@ WasmEdge requires LLVM 13 and you may need to install these following dependenci choco install cmake ninja vswhere $vsPath = (vswhere -latest -property installationPath) +# If vswhere.exe is not in PATH, try the following instead. +# $vsPath = (&"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath) + Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" @@ -35,17 +38,27 @@ curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13. Expand-Archive -Path $llvm # Set LLVM environment -$llvm_dir = "$pwd\\LLVM-13.0.1-win64\\LLVM-13.0.1-win64\\lib\\cmake\\llvm" -$Env:CC = "clang-cl" -$Env:CXX = "clang-cl" +$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" ``` ## Build WasmEdge -```bash +On Windows, either Clang-cl or MSVC can be used to build WasmEdge. To use MSVC, simply comment out the two lines that set the environment variables `CC` and `CXX`. + +```powershell $vsPath = (vswhere -latest -property installationPath) Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" +# If you would like to use MSVC, and want to use a specific version of MSVC, set the arg `vcvars_ver` like the following. +# Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0 -vcvars_ver=14.34.31933" + +# Set LLVM path according to the download location +$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" + +# Use clang-cl as the compiler. +# Comment out the following two lines to use MSVC. +$Env:CC = "clang-cl" +$Env:CXX = "clang-cl" cmake -Bbuild -GNinja -DCMAKE_SYSTEM_VERSION=10.0.19041.0 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL "-DLLVM_DIR=$llvm_dir" -DWASMEDGE_BUILD_TESTS=ON -DWASMEDGE_BUILD_PACKAGE="ZIP" . cmake --build build @@ -57,12 +70,8 @@ The following tests are available only when the build option `WASMEDGE_BUILD_TES Users can use these tests to verify the correctness of WasmEdge binaries. -```bash -$vsPath = (vswhere -latest -property installationPath) -Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") -Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" - -$Env:PATH += ";$pwd\\build\\lib\\api" +```powershell +$Env:PATH += ";$pwd\build\lib\api" cd build ctest --output-on-failure cd - diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md b/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md index 4bf7423a4..343bb844d 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md @@ -26,6 +26,9 @@ WasmEdge requires LLVM 13 and you may need to install these following dependenci choco install cmake ninja vswhere $vsPath = (vswhere -latest -property installationPath) +# If vswhere.exe is not in PATH, try the following instead. +# $vsPath = (&"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath) + Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" @@ -35,17 +38,27 @@ curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13. Expand-Archive -Path $llvm # Set LLVM environment -$llvm_dir = "$pwd\\LLVM-13.0.1-win64\\LLVM-13.0.1-win64\\lib\\cmake\\llvm" -$Env:CC = "clang-cl" -$Env:CXX = "clang-cl" +$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" ``` ## Build WasmEdge -```bash +On Windows, either Clang-cl or MSVC can be used to build WasmEdge. To use MSVC, simply comment out the two lines that set the environment variables `CC` and `CXX`. + +```powershell $vsPath = (vswhere -latest -property installationPath) Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" +# If you would like to use MSVC, and want to use a specific version of MSVC, set the arg `vcvars_ver` like the following. +# Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0 -vcvars_ver=14.34.31933" + +# Set LLVM path according to the download location +$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" + +# Use clang-cl as the compiler. +# Comment out the following two lines to use MSVC. +$Env:CC = "clang-cl" +$Env:CXX = "clang-cl" cmake -Bbuild -GNinja -DCMAKE_SYSTEM_VERSION=10.0.19041.0 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL "-DLLVM_DIR=$llvm_dir" -DWASMEDGE_BUILD_TESTS=ON -DWASMEDGE_BUILD_PACKAGE="ZIP" . cmake --build build @@ -57,12 +70,8 @@ The following tests are available only when the build option `WASMEDGE_BUILD_TES Users can use these tests to verify the correctness of WasmEdge binaries. -```bash -$vsPath = (vswhere -latest -property installationPath) -Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") -Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" - -$Env:PATH += ";$pwd\\build\\lib\\api" +```powershell +$Env:PATH += ";$pwd\build\lib\api" cd build ctest --output-on-failure cd - From cc7a1c32982108c00af4c04edb2ae3ddda9c4a83 Mon Sep 17 00:00:00 2001 From: Wang Jikai Date: Fri, 1 Sep 2023 18:06:23 +0800 Subject: [PATCH 2/2] Update LLVM version of Windows build. Signed-off-by: Wang Jikai --- docs/contribute/source/os/windows.md | 19 ++++++++++++------- .../current/contribute/source/os/windows.md | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/docs/contribute/source/os/windows.md b/docs/contribute/source/os/windows.md index 343bb844d..b2adaee14 100644 --- a/docs/contribute/source/os/windows.md +++ b/docs/contribute/source/os/windows.md @@ -15,11 +15,16 @@ cd WasmEdge ## Requirements and Dependencies -WasmEdge requires LLVM 13 and you may need to install these following dependencies by yourself. +WasmEdge requires LLVM 16 and you may need to install these following dependencies by yourself. - [Chocolatey](https://chocolatey.org/install), we use it to install `cmake`, `ninja`, and `vswhere`. - [Windows SDK 19041](https://blogs.windows.com/windowsdeveloper/2020/05/12/start-developing-on-windows-10-version-2004-today/) -- LLVM 13.0.1, you can find the pre-built files [here](https://github.com/WasmEdge/llvm-windows/releases) or you can just follow the `instructions/commands` to download automatically. +- LLVM 16.0.6, download the pre-built files [here](https://github.com/WasmEdge/llvm-windows/releases) or you can just follow the `instructions/commands` to download automatically. + + +:::note +If you use the community version of Visual Studio, you may encounter errors like: `ninja: error: 'C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK/lib/amd64/diaguids.lib', needed by 'test/aot/wasmedgeAOTCoreTests.exe', missing and no known rule to make it`. You need to manually open the file `LLVM-16.0.6-win64/lib/cmake/llvm/LLVMExports.cmake`, search for the only occurrence of `Enterprise` and change it to `Community`. See [this issue](https://github.com/WasmEdge/WasmEdge/issues/1290#issuecomment-1056784554) for details. +::: ```powershell # Install the required tools @@ -32,13 +37,13 @@ $vsPath = (vswhere -latest -property installationPath) Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" -# Download our pre-built LLVM 13 binary -$llvm = "LLVM-13.0.1-win64.zip" -curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win64.zip -o $llvm +# Download our pre-built LLVM 16 binary +$llvm = "LLVM-16.0.6-win64-MultiThreadedDLL.zip" +curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-16.0.6/LLVM-16.0.6-win64-MultiThreadedDLL.zip -o $llvm Expand-Archive -Path $llvm # Set LLVM environment -$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" +$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm" ``` ## Build WasmEdge @@ -53,7 +58,7 @@ Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments # Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0 -vcvars_ver=14.34.31933" # Set LLVM path according to the download location -$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" +$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm" # Use clang-cl as the compiler. # Comment out the following two lines to use MSVC. diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md b/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md index 343bb844d..b2adaee14 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md @@ -15,11 +15,16 @@ cd WasmEdge ## Requirements and Dependencies -WasmEdge requires LLVM 13 and you may need to install these following dependencies by yourself. +WasmEdge requires LLVM 16 and you may need to install these following dependencies by yourself. - [Chocolatey](https://chocolatey.org/install), we use it to install `cmake`, `ninja`, and `vswhere`. - [Windows SDK 19041](https://blogs.windows.com/windowsdeveloper/2020/05/12/start-developing-on-windows-10-version-2004-today/) -- LLVM 13.0.1, you can find the pre-built files [here](https://github.com/WasmEdge/llvm-windows/releases) or you can just follow the `instructions/commands` to download automatically. +- LLVM 16.0.6, download the pre-built files [here](https://github.com/WasmEdge/llvm-windows/releases) or you can just follow the `instructions/commands` to download automatically. + + +:::note +If you use the community version of Visual Studio, you may encounter errors like: `ninja: error: 'C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK/lib/amd64/diaguids.lib', needed by 'test/aot/wasmedgeAOTCoreTests.exe', missing and no known rule to make it`. You need to manually open the file `LLVM-16.0.6-win64/lib/cmake/llvm/LLVMExports.cmake`, search for the only occurrence of `Enterprise` and change it to `Community`. See [this issue](https://github.com/WasmEdge/WasmEdge/issues/1290#issuecomment-1056784554) for details. +::: ```powershell # Install the required tools @@ -32,13 +37,13 @@ $vsPath = (vswhere -latest -property installationPath) Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0" -# Download our pre-built LLVM 13 binary -$llvm = "LLVM-13.0.1-win64.zip" -curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win64.zip -o $llvm +# Download our pre-built LLVM 16 binary +$llvm = "LLVM-16.0.6-win64-MultiThreadedDLL.zip" +curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-16.0.6/LLVM-16.0.6-win64-MultiThreadedDLL.zip -o $llvm Expand-Archive -Path $llvm # Set LLVM environment -$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" +$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm" ``` ## Build WasmEdge @@ -53,7 +58,7 @@ Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments # Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0 -vcvars_ver=14.34.31933" # Set LLVM path according to the download location -$llvm_dir = "$pwd\LLVM-13.0.1-win64\LLVM-13.0.1-win64\lib\cmake\llvm" +$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm" # Use clang-cl as the compiler. # Comment out the following two lines to use MSVC.