Skip to content

Commit 80b2a5f

Browse files
authored
Add more details for Windows MSVC build process. (#156)
* Add process for Windows MSVC build. Signed-off-by: Wang Jikai <wangjikai@hust.edu.cn> * Update LLVM version of Windows build. Signed-off-by: Wang Jikai <wangjikai@hust.edu.cn> --------- Signed-off-by: Wang Jikai <wangjikai@hust.edu.cn>
1 parent 256c116 commit 80b2a5f

File tree

2 files changed

+58
-30
lines changed
  • docs/contribute/source/os
  • i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os

2 files changed

+58
-30
lines changed

docs/contribute/source/os/windows.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,55 @@ cd WasmEdge
1515

1616
## Requirements and Dependencies
1717

18-
WasmEdge requires LLVM 13 and you may need to install these following dependencies by yourself.
18+
WasmEdge requires LLVM 16 and you may need to install these following dependencies by yourself.
1919

2020
- [Chocolatey](https://chocolatey.org/install), we use it to install `cmake`, `ninja`, and `vswhere`.
2121
- [Windows SDK 19041](https://blogs.windows.com/windowsdeveloper/2020/05/12/start-developing-on-windows-10-version-2004-today/)
22-
- 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.
22+
- 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.
23+
24+
<!-- prettier-ignore -->
25+
:::note
26+
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.
27+
:::
2328

2429
```powershell
2530
# Install the required tools
2631
choco install cmake ninja vswhere
2732
2833
$vsPath = (vswhere -latest -property installationPath)
34+
# If vswhere.exe is not in PATH, try the following instead.
35+
# $vsPath = (&"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
36+
2937
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
3038
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
3139
32-
# Download our pre-built LLVM 13 binary
33-
$llvm = "LLVM-13.0.1-win64.zip"
34-
curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win64.zip -o $llvm
40+
# Download our pre-built LLVM 16 binary
41+
$llvm = "LLVM-16.0.6-win64-MultiThreadedDLL.zip"
42+
curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-16.0.6/LLVM-16.0.6-win64-MultiThreadedDLL.zip -o $llvm
3543
Expand-Archive -Path $llvm
3644
3745
# Set LLVM environment
38-
$llvm_dir = "$pwd\\LLVM-13.0.1-win64\\LLVM-13.0.1-win64\\lib\\cmake\\llvm"
39-
$Env:CC = "clang-cl"
40-
$Env:CXX = "clang-cl"
46+
$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm"
4147
```
4248

4349
## Build WasmEdge
4450

45-
```bash
51+
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`.
52+
53+
```powershell
4654
$vsPath = (vswhere -latest -property installationPath)
4755
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
4856
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
57+
# If you would like to use MSVC, and want to use a specific version of MSVC, set the arg `vcvars_ver` like the following.
58+
# Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0 -vcvars_ver=14.34.31933"
59+
60+
# Set LLVM path according to the download location
61+
$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm"
62+
63+
# Use clang-cl as the compiler.
64+
# Comment out the following two lines to use MSVC.
65+
$Env:CC = "clang-cl"
66+
$Env:CXX = "clang-cl"
4967
5068
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" .
5169
cmake --build build
@@ -57,12 +75,8 @@ The following tests are available only when the build option `WASMEDGE_BUILD_TES
5775

5876
Users can use these tests to verify the correctness of WasmEdge binaries.
5977

60-
```bash
61-
$vsPath = (vswhere -latest -property installationPath)
62-
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
63-
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
64-
65-
$Env:PATH += ";$pwd\\build\\lib\\api"
78+
```powershell
79+
$Env:PATH += ";$pwd\build\lib\api"
6680
cd build
6781
ctest --output-on-failure
6882
cd -

i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/os/windows.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,55 @@ cd WasmEdge
1515

1616
## Requirements and Dependencies
1717

18-
WasmEdge requires LLVM 13 and you may need to install these following dependencies by yourself.
18+
WasmEdge requires LLVM 16 and you may need to install these following dependencies by yourself.
1919

2020
- [Chocolatey](https://chocolatey.org/install), we use it to install `cmake`, `ninja`, and `vswhere`.
2121
- [Windows SDK 19041](https://blogs.windows.com/windowsdeveloper/2020/05/12/start-developing-on-windows-10-version-2004-today/)
22-
- 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.
22+
- 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.
23+
24+
<!-- prettier-ignore -->
25+
:::note
26+
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.
27+
:::
2328

2429
```powershell
2530
# Install the required tools
2631
choco install cmake ninja vswhere
2732
2833
$vsPath = (vswhere -latest -property installationPath)
34+
# If vswhere.exe is not in PATH, try the following instead.
35+
# $vsPath = (&"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
36+
2937
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
3038
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
3139
32-
# Download our pre-built LLVM 13 binary
33-
$llvm = "LLVM-13.0.1-win64.zip"
34-
curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win64.zip -o $llvm
40+
# Download our pre-built LLVM 16 binary
41+
$llvm = "LLVM-16.0.6-win64-MultiThreadedDLL.zip"
42+
curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-16.0.6/LLVM-16.0.6-win64-MultiThreadedDLL.zip -o $llvm
3543
Expand-Archive -Path $llvm
3644
3745
# Set LLVM environment
38-
$llvm_dir = "$pwd\\LLVM-13.0.1-win64\\LLVM-13.0.1-win64\\lib\\cmake\\llvm"
39-
$Env:CC = "clang-cl"
40-
$Env:CXX = "clang-cl"
46+
$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm"
4147
```
4248

4349
## Build WasmEdge
4450

45-
```bash
51+
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`.
52+
53+
```powershell
4654
$vsPath = (vswhere -latest -property installationPath)
4755
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
4856
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
57+
# If you would like to use MSVC, and want to use a specific version of MSVC, set the arg `vcvars_ver` like the following.
58+
# Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0 -vcvars_ver=14.34.31933"
59+
60+
# Set LLVM path according to the download location
61+
$llvm_dir = "$pwd\LLVM-16.0.6-win64-MultiThreadedDLL\LLVM-16.0.6-win64\lib\cmake\llvm"
62+
63+
# Use clang-cl as the compiler.
64+
# Comment out the following two lines to use MSVC.
65+
$Env:CC = "clang-cl"
66+
$Env:CXX = "clang-cl"
4967
5068
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" .
5169
cmake --build build
@@ -57,12 +75,8 @@ The following tests are available only when the build option `WASMEDGE_BUILD_TES
5775

5876
Users can use these tests to verify the correctness of WasmEdge binaries.
5977

60-
```bash
61-
$vsPath = (vswhere -latest -property installationPath)
62-
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
63-
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
64-
65-
$Env:PATH += ";$pwd\\build\\lib\\api"
78+
```powershell
79+
$Env:PATH += ";$pwd\build\lib\api"
6680
cd build
6781
ctest --output-on-failure
6882
cd -

0 commit comments

Comments
 (0)