Skip to content

Add Clang/LLVM builds instead of GCC and MSVC - #18

Open
vladimirsamsonov wants to merge 3 commits into
HumbleUI:masterfrom
vladimirsamsonov:clang_build
Open

vladimirsamsonov wants to merge 3 commits into
HumbleUI:masterfrom
vladimirsamsonov:clang_build

Conversation

@vladimirsamsonov

@vladimirsamsonov vladimirsamsonov commented Sep 11, 2026

Copy link
Copy Markdown

What is the purpose of these changes?

Build the native Skia binaries with Clang/clang-cl instead of GCC/MSVC.

Skia's software rasterizer contains generated code and performance-critical routines that are specifically optimized for Clang. According to Skia's own build documentation, using other compilers can result in dramatically worse software-rasterization performance.

This has a significant impact on the binaries currently published by this repository.

Benchmark

Same scene, same machine (Windows 11, Core Ultra 7 258V, 1024×1400 page, 5 s warmup / 10 s measurement):

Stack Toolchain Throughput Frame p50
Java / Skija, current build MSVC 2.5 fps 394 ms
Java / Skija, Clang build clang-cl 47.8 fps 20.7 ms
C# / SkiaSharp 3.119.4 lld-link 48.4 fps 20.4 ms
C# / SkiaSharp 4.151.2 lld-link 47.6 fps 20.7 ms

The two SkiaSharp versions are useful controls: both ship Clang-built Skia for Windows and perform within ~1.5% of the Clang build of the same Skia milestone produced here.

In other words, ~47–48 fps is the expected performance for this scene, while the 2.5 fps MSVC build is the outlier. The difference is roughly 19× in this benchmark.

Absolute throughput is somewhat bimodal on this hybrid-core laptop: Clang-built binaries alternate between ~47 fps and ~31–37 fps across runs, both under the JVM and .NET hosts. The MSVC build remains at ~2.5 fps. Even with this variation, the performance difference is substantial.

Linux

Linux shows the same issue, although the gap is smaller:

  • GCC 9.5: 6.7 fps
  • Clang 18.1.3: 49.4 fps

That's approximately a 7.4× improvement on the raster-heavy benchmark. In a broader workload, such as a synthetic test or a real PDF page renderer where Skia rasterization is only part of the total work, the improvement was approximately 2.5×.

This is also consistent with SkiaSharp's build configuration: its Linux native builds use Clang, and shipped linux-x64 binaries contain the corresponding Clang version information.

Why Clang?

Skia explicitly recommends Clang for software rasterization:

A number of routines in Skia's software backend have been written to run fastest when compiled with Clang. If you depend on software rasterization, image decoding, or color space conversion and compile Skia with a compiler other than Clang, you will see dramatically worse performance.

For Windows, Skia specifically recommends clang-cl:

Skia uses generated code that is only optimized when Skia is built with clang. Other compilers get generic unoptimized code.

See the Skia build documentation for details.

SkiaSharp follows the same approach: its Windows native packages are built with Clang/LLVM and linked with lld-link, while its Linux builds use Clang as well.

Scope

  • Windows: switch the native Skia build from MSVC to clang-cl.
  • Linux: switch the native Skia build from GCC to Clang.
  • macOS / Android: no changes; these platforms already use Clang-based toolchains.

The goal is therefore not to change Skia itself, but to ensure that the binaries published by this repository are built with the compiler configuration recommended by Skia and achieve the expected software-rasterization performance.

What changes

  • script/build.py — Linux switches from gcc-10/g++-10 to clang/clang++. The arm64 cross build passes --target=aarch64-linux-gnu, since Clang is a single cross compiler rather than a per-target driver; the cross GCC that prepare_linux.sh already installs supplies the sysroot, the C++ headers and libstdc++. Windows gets clang_win.
  • script/prepare_linux.sh — installs clang.
  • .github/workflows/build.ymlversion moves to m143-da51f0d60e-5.
  • README.md — notes the toolchain requirement.

Artifact names are unchanged, and no flag is introduced: these platforms are simply built with Clang now.

@vladimirsamsonov vladimirsamsonov mentioned this pull request Sep 11, 2026
@tonsky

tonsky commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Yay! LLM-generated PR :)

Release is built twice: once with the platform default compiler and once with Clang/LLVM

Why build twice? Why not just switch to clang and only use clang?

@vladimirsamsonov

Copy link
Copy Markdown
Author

Hello, Ideally, I’d like to use approach with Clang only. If there are no objections, I’ll adjust the changes accordingly. And regarding the test runs and build - yes, the AI ​​certainly helped out there :)

@tonsky

tonsky commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Ideally, I’d like to use approach with Clang only

Let's do it!

@vladimirsamsonov
vladimirsamsonov force-pushed the clang_build branch 2 times, most recently from cc166e8 to 69da3e4 Compare September 12, 2026 08:53
@vladimirsamsonov vladimirsamsonov changed the title Add Clang/LLVM builds alongside GCC and MSVC Add Clang/LLVM builds instead of GCC and MSVC Sep 12, 2026
@vladimirsamsonov
vladimirsamsonov marked this pull request as ready for review September 14, 2026 11:30
@vladimirsamsonov

Copy link
Copy Markdown
Author

Reworked this as we discussed: Linux and Windows are now built with Clang only, instead of alongside the platform compilers. Also description has been updated.

Full matrix is green: https://github.com/vladimirsamsonov/SkiaBuild/actions/runs/34836134415

Could you take another look when you get a chance?

@tonsky

tonsky commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Yup, will look soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants