Add Clang/LLVM builds instead of GCC and MSVC - #18
vladimirsamsonov wants to merge 3 commits into
Conversation
|
Yay! LLM-generated PR :)
Why build twice? Why not just switch to clang and only use clang? |
|
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 :) |
Let's do it! |
cc166e8 to
69da3e4
Compare
69da3e4 to
0363f9c
Compare
|
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? |
|
Yup, will look soon! |
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):
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:
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-x64binaries contain the corresponding Clang version information.Why Clang?
Skia explicitly recommends Clang for software rasterization:
For Windows, Skia specifically recommends clang-cl:
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
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 fromgcc-10/g++-10toclang/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 thatprepare_linux.shalready installs supplies the sysroot, the C++ headers and libstdc++. Windows getsclang_win.script/prepare_linux.sh— installsclang..github/workflows/build.yml—versionmoves tom143-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.