Skip to content
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

mesa/lib32-mesa: Use Clang and ThinLTO #328

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mesa/lib32-mesa/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pkgbase = lib32-mesa
pkgdesc = Open-source OpenGL drivers - 32-bit
pkgver = 24.2.2
pkgrel = 3
pkgrel = 5
epoch = 1
url = https://www.mesa3d.org/
arch = x86_64
Expand Down Expand Up @@ -49,11 +49,14 @@ pkgbase = lib32-mesa
makedepends = rust-bindgen
makedepends = wayland-protocols
makedepends = xorgproto
makedepends = lld
makedepends = llvm-libs
options = !lto
source = https://mesa.freedesktop.org/archive/mesa-24.2.2.tar.xz
source = https://mesa.freedesktop.org/archive/mesa-24.2.2.tar.xz.sig
source = fix-rusticl-build.patch::https://gitlab.freedesktop.org/mesa/mesa/-/commit/93e96da9458c9d0348f2390dc0bea67cf140b1a0.patch
source = https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31122.patch
source = lib32-clang
source = ucd-trie-0.1.6.tar.gz::https://crates.io/api/v1/crates/ucd-trie/0.1.6/download
source = pest_meta-2.7.11.tar.gz::https://crates.io/api/v1/crates/pest_meta/2.7.11/download
source = indexmap-2.2.6.tar.gz::https://crates.io/api/v1/crates/indexmap/2.2.6/download
Expand Down Expand Up @@ -98,6 +101,7 @@ pkgbase = lib32-mesa
b2sums = SKIP
b2sums = da196d667e31f647c376c37b394caed7787f4a41d79526ac2177f328920f49d183ef10bdf16b369c00aee4eecc6bc8cd3038908065438d99e58ac97e62c5cbba
b2sums = 53d57d8fcfa140e24bec9dbb377f852d4719c0404fc08c3b7a0cca6e0a9b2bfc607bb85126579b00d498283ae2b173fca63982128421151b238aa9051e8754f9
b2sums = 2b860354deb7af7f96ba5f441e71ab92fd4b5d81f44c27702b4d60c714050a048bd2ee89b83e96a7c08eaea45b530e18822e14580938f178b89cd228ffa5586f
b2sums = a6d47c903be6094423d89b8ec3ca899d0a84df6dbd6e76632bb6c9b9f40ad9c216f8fa400310753d392f85072756b43ac3892e0a2c4d55f87ab6463002554823
b2sums = 9c34f1ab14ad5ae124882513e0f14b1d731d06a43203bdc37fa3b202dd3ce93dbe8ebb554d01bab475689fe6ffd3ec0cbc0d5365c9b984cb83fb34ea3e9e732e
b2sums = fac5cf6339dc3c0a40b100035a5c874cc7b2efeafeb31c51488d25156e392dc9db86a497e76eead351d2126f69d060422faa9c55d73407a0de9f5be18d234123
Expand Down
18 changes: 16 additions & 2 deletions mesa/lib32-mesa/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pkgname=(
lib32-vulkan-virtio
)
pkgver=24.2.2
pkgrel=3
pkgrel=5
epoch=1
pkgdesc="Open-source OpenGL drivers - 32-bit"
url="https://www.mesa3d.org/"
Expand Down Expand Up @@ -75,6 +75,8 @@ makedepends=(
rust-bindgen
wayland-protocols
xorgproto
lld
llvm-libs
)
options=(
# GCC 14 LTO causes segfault in LLVM under si_llvm_optimize_module
Expand All @@ -87,6 +89,7 @@ source=(
"https://mesa.freedesktop.org/archive/mesa-$pkgver.tar.xz"{,.sig}
"fix-rusticl-build.patch::https://gitlab.freedesktop.org/mesa/mesa/-/commit/93e96da9458c9d0348f2390dc0bea67cf140b1a0.patch"
"https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31122.patch"
"lib32-clang"
)
validpgpkeys=(
946D09B5E4C9845E63075FF1D961C596A7203456 # Andres Gomez <[email protected]>
Expand Down Expand Up @@ -127,6 +130,7 @@ b2sums=('14b29989b056c3bc76cb64babef6e93dd31af37ea72674adaad3f7ef7373c004996e375
'SKIP'
'da196d667e31f647c376c37b394caed7787f4a41d79526ac2177f328920f49d183ef10bdf16b369c00aee4eecc6bc8cd3038908065438d99e58ac97e62c5cbba'
'53d57d8fcfa140e24bec9dbb377f852d4719c0404fc08c3b7a0cca6e0a9b2bfc607bb85126579b00d498283ae2b173fca63982128421151b238aa9051e8754f9'
'2b860354deb7af7f96ba5f441e71ab92fd4b5d81f44c27702b4d60c714050a048bd2ee89b83e96a7c08eaea45b530e18822e14580938f178b89cd228ffa5586f'
'a6d47c903be6094423d89b8ec3ca899d0a84df6dbd6e76632bb6c9b9f40ad9c216f8fa400310753d392f85072756b43ac3892e0a2c4d55f87ab6463002554823'
'9c34f1ab14ad5ae124882513e0f14b1d731d06a43203bdc37fa3b202dd3ce93dbe8ebb554d01bab475689fe6ffd3ec0cbc0d5365c9b984cb83fb34ea3e9e732e'
'fac5cf6339dc3c0a40b100035a5c874cc7b2efeafeb31c51488d25156e392dc9db86a497e76eead351d2126f69d060422faa9c55d73407a0de9f5be18d234123'
Expand Down Expand Up @@ -181,7 +185,7 @@ prepare() {

build() {
local meson_options=(
--cross-file lib32
--cross-file "$srcdir/lib32-clang"
-D android-libbacktrace=disabled
-D b_ndebug=true
-D gallium-drivers=r300,r600,radeonsi,nouveau,virgl,svga,llvmpipe,softpipe,iris,crocus,i915,zink
Expand All @@ -207,10 +211,20 @@ build() {

export BINDGEN_EXTRA_CLANG_ARGS="-m32"

# Set Clang as compiler
export AR=llvm-ar CC=clang CXX=clang++ NM=llvm-nm 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"

Expand Down
19 changes: 19 additions & 0 deletions mesa/lib32-mesa/lib32-clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[binaries]
c = ['clang', '-m32']
cpp = ['clang++', '-m32']
rust = ['rustc', '--target', 'i686-unknown-linux-gnu']
pkgconfig = 'i686-pc-linux-gnu-pkg-config'
cups-config = 'cups-config'
llvm-config = 'llvm-config32'
strip = 'strip'

[built-in options]
libdir = 'lib32'

[host_machine]
system = 'linux'
subsystem = 'linux'
kernel = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'
3 changes: 2 additions & 1 deletion mesa/mesa/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pkgbase = mesa
pkgdesc = Open-source OpenGL drivers
pkgver = 24.2.2
pkgrel = 2
pkgrel = 5
epoch = 1
url = https://www.mesa3d.org/
arch = x86_64
Expand Down Expand Up @@ -35,6 +35,7 @@ pkgbase = mesa
makedepends = xcb-util-keysyms
makedepends = zlib
makedepends = zstd
makedepends = lld
makedepends = cbindgen
makedepends = clang
makedepends = cmake
Expand Down
17 changes: 15 additions & 2 deletions mesa/mesa/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pkgname=(
mesa-docs
)
pkgver=24.2.2
pkgrel=3
pkgrel=5
epoch=1
pkgdesc="Open-source OpenGL drivers"
url="https://www.mesa3d.org/"
Expand Down Expand Up @@ -60,7 +60,7 @@ makedepends=(
xcb-util-keysyms
zlib
zstd

lld
# shared between mesa and lib32-mesa
cbindgen
clang
Expand Down Expand Up @@ -218,10 +218,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"

Expand Down