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 Aug 3, 2024
1 parent b762a2d commit 6ed9d3d
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions docs/encoders/SVT-AV1-PSY.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,41 +159,37 @@ 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 (GCC/Clang) and MSVC. This guide explains how to build SVT-AV1-PSY using Clang-CL.

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: Get "Desktop development with C++" and under optional, get "C++ Clang tools".
- CMake
- NASM
- Git

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
```

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

```bash
pacman -Syu --needed mingw-w64-ucrt-x86_64-clang
git clone --depth 10 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
cmake -B svt_build -T ClangCL -DBUILD_SHARED_LIBS=OFF -DBUILD_DEC=OFF -DENABLE_AVX512=ON -DCMAKE_CXX_FLAGS_RELEASE="-flto /O2 /Ob2 /DNDEBUG -march=native" -DCMAKE_C_FLAGS_RELEASE="-flto /O2 /Ob2 /DNDEBUG -march=native"
```
**Note**: It could be that on your machine, `-march=native` actually gives slower speed than a generic build. If that's the case, simply remove `-march=native`.

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
```

```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
```bash
cmake --build svt_build --config Release --parallel
```

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.
If you'd like to build from the latest release (2.1.0-A at the time of writing - last updated 3 August 2024) please run `git reset --hard 88cd12ee10e79cbba1c00a050501d0c47f3f5589` in the cloned directory.
</TabItem>
</Tabs>

Expand Down

0 comments on commit 6ed9d3d

Please sign in to comment.