From cb571550cc63f6bb22e0212dc681d8a2cd90926c Mon Sep 17 00:00:00 2001 From: Natalie Vock Date: Tue, 3 Feb 2026 09:50:06 +0100 Subject: [PATCH] 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: --- meson.build | 6 ++++++ meson.options | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/meson.build b/meson.build index 6113deb0aa0..e9c3dccfceb 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/meson.options b/meson.options index 9a132f802c3..d22431f82e0 100644 --- a/meson.options +++ b/meson.options @@ -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!' +)