mesa: Prevent building with LTO

LTO is not supported with Mesa. It has caused random impossible-to-debug
bugs for a long time, and LTO bug reports are generally considered a
"WONTFIX please disable LTO instead". Let's make this clear to users
and packagers so they don't run into more weird issues that result in
inactionable reports.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39671>
This commit is contained in:
Natalie Vock 2026-02-03 09:50:06 +01:00 committed by Marge Bot
parent e48f46e342
commit cb571550cc
2 changed files with 13 additions and 0 deletions

View file

@ -45,6 +45,12 @@ endif
if get_option('b_lto')
project_version += '-lto'
# LTO causes random issues that are nearly impossible to debug, so bug reports from LTO builds have been
# rejected for a long time now.
# Explicitly reject LTO when building to prevent more people from running into bugs that end up inactionable.
if not get_option('allow-broken-lto')
error('Building Mesa with LTO is not supported. Please disable LTO for building Mesa.')
endif
endif
with_llvm = get_option('llvm')

View file

@ -865,3 +865,10 @@ option(
type : 'feature',
description : 'Use SPIRV-Tools for dumping SPIR-V for debugging purposes (required by CLC)'
)
option(
'allow-broken-lto',
type : 'boolean',
value : false,
description : 'Manual override switch to enable LTO, which is unsupported due to being broken. WARNING: This option may break your driver randomly!'
)