-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Mesa: Investigate if using Clang with ThinLTO improves the performance #327
Comments
Seems problematic to compile with ThinLTO.
This can be mitigated with |
diff --git a/mesa/mesa/PKGBUILD b/mesa/mesa/PKGBUILD
index b46a1df..39d27c8 100644
--- a/mesa/mesa/PKGBUILD
+++ b/mesa/mesa/PKGBUILD
@@ -214,10 +214,23 @@ build() {
-D vulkan-layers=device-select,intel-nullhw,overlay
)
+ # Set Clang as compiler
+ export AR=llvm-ar
+ export CC=clang
+ export CXX=clang++
+ export NM=llvm-nm
+ export RANLIB=llvm-ranlib
+
+ export CFLAGS+=" -flto=thin"
+ export CXXFLAGS+=" -flto=thin"
+ export LDFLAGS+=" -Wl,--undefined-version -fuse-ld=lld"
# Build only minimal debug info to reduce size
CFLAGS+=" -g1"
CXXFLAGS+=" -g1"
+ # LTO needs more open files
+ ulimit -n 4096
+
# Inject subproject packages
export MESON_PACKAGE_CACHE_DIR="$srcdir"
Diff to get ThinLTO correclty working. WIll provide some test packages |
@1Naim @SoulHarsh007 |
With a Radeon 660M (iGPU), I did not notice any performance gains from ThinLTO. However, there is a sizeable reduction in package size (notably in lib32-mesa, but approx. 28MB total). With that said, there is a need in testing this in much more hardware and environments so we are sure there are no issues with this build. Example case of building with ThinLTO can be seen in mesa/#8003, due note that this was built with gcc + LTO so the issues might not necessarily be present when building with clang + LTO. |
FYI this error comes from building with the llvm stack in general, not just when building with ThinLTO. |
That linked bug report brings back some memories. :) The encountered error should be reported though as there was some work to fix building Mesa without having to use I've been compiling Mesa with Clang + FullLTO and occasional ThinLTO for quite a while with more aggressive flags (see below). Recently, the performance differences weren't that big any longer against an optimized GCC-14 build. Clang was still a bit better overall on my hardware (Haswell-EP/Raptor Lake and 6950 XT). For me personally, the biggest advantage in using Clang is for PGO as the instrumented Mesa is very slow with GCC. Compile times were faster with GCC though. I was also experimenting with using Polly. While that didn't improve the average FPS, it did have some positive effects on the perceived smoothness. Unfortunately the used Polly flags caused some bugs which impacted Chrome's VAAPI and website rendering. My Clang CFLAGS without PGO and Polly just for reference, feel free to pick and test the ones you like:
|
mesa is currently compiled without LTO due bugs in GCC 14.
We could starting to consider, to enable ThinLTO and a clang built mesa.
Anyone needs to benchmark with AMD or Intel cards, if this improves the performance
The text was updated successfully, but these errors were encountered: