Skip to content

Commit

Permalink
Switch to Clang-CL for faster Windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Uranite committed Nov 13, 2024
1 parent bc83f17 commit fa95fcf
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions docs/encoders/SVT-AV1-PSY.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,41 +159,36 @@ Building & installing SVT-AV1-PSY is the same as building & installing mainline
```
</TabItem>
<TabItem value="windows" label="Windows">
**MSYS2** is the best option for building in Windows, as it provides a Unix-like environment for building SVT-AV1-PSY. This makes the compilation procedure the same as described for Linux & macOS. The full build process is detailed here.
**Clang-CL** is the best option for building in Windows, as it results in faster binaries than building with MSYS2 (either GCC/Clang) and MSVC. The full build process is detailed here.

0. Make sure you have downloaded & installed MSYS2 from [the MSYS2 website](https://www.msys2.org/) before beginning the build process.
0. Make sure you have the following prerequisites before beginning the build process:
- [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools): Inside Build Tools, select "Desktop development with C++" and under optional, select "C++ Clang tools"
- [CMake](https://cmake.org/download)
- [NASM](https://nasm.us)
- [Git](https://git-scm.com/downloads)

1. Start the UCRT64 console & install the required dependencies:
```bash
pacman -Syu --needed git mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-yasm
```
1. Clone the SVT-AV1-PSY repository:

2. \[Optional\] Clang is the recommended compiler for SVT-AV1 & SVT-AV1-PSY, so you may wish to download it with the following command:

```bash
pacman -Syu --needed mingw-w64-ucrt-x86_64-clang
```bash title="Clone SVT-AV1-PSY"
git clone https://github.com/gianni-rosato/svt-av1-psy.git
cd svt-av1-psy
```

3. Now, we may follow the steps for Linux & macOS to complete building. Please note that CMake may require you to include `-G "Ninja"` in any CMake commands.
2. Configure compilation:

```bash title="Clone SVT-AV1-PSY"
git clone https://github.com/gianni-rosato/svt-av1-psy
cd SVT-AV1/Build/linux
```bash title="Configure SVT-AV1-PSY"
cmake --fresh -B svt_build -T ClangCL -DBUILD_SHARED_LIBS=OFF -DSVT_AV1_LTO=OFF -DCMAKE_CXX_FLAGS_RELEASE="-flto /clang:-O2 /DNDEBUG -march=native" -DCMAKE_C_FLAGS_RELEASE="-flto /clang:-O2 /DNDEBUG -march=native"
```
**Note**: On Ryzen 5000, `-march=native` actually decrease performance. Please use `-march=znver2` instead.

In the directory, simply run `./build.sh [flags]` to build. Be aware that building requires CMake version 3.16 or higher and either GCC or Clang. It is recommended to use Clang, and ideally it will be installed as per Step 2.
3. Compile:

```bash title="Build release"
./build.sh release
cmake --build svt_build --config Release --parallel
```

```bash title="Statically build just the encoder with clang and enable link-time optimization"
./build.sh jobs=8 all cc=clang cxx=clang++ no-dec enable-lto static native
```

The compiled binaries will be in the `Bin/Release` directory, including SvtAv1EncApp. If you just want the encoder, adding the `no-dec` flag will skip building SvtAv1DecApp and save on compilation time.

If you'd like to build from the latest release (2.1.0 at the time of writing - last updated 23 May 2024) please run `git reset --hard 5471bd78311d70ab4691af1ae54fd80e25f214f5` in the cloned directory.
The compiled binary will be in the `Bin/Release` directory.
For more information, findings and discussions about the builds (including the Ryzen 5000 case, parameters used and tested, Windows 10/11, Clang 17-19, Ninja, and **PGO**), check the [Community Builds Thread for v2.2.1-A](https://github.com/gianni-rosato/svt-av1-psy/discussions/69)
</TabItem>
</Tabs>

Expand Down

0 comments on commit fa95fcf

Please sign in to comment.