From 40c187dc15d3715443d0bac56ea3e3eff609e74c Mon Sep 17 00:00:00 2001 From: Luna D Dragon Date: Wed, 30 Oct 2024 17:41:06 +0530 Subject: [PATCH] build: allow building with clang+lto https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2053 --- meson.build | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index a46aae642..1b8be0b02 100644 --- a/meson.build +++ b/meson.build @@ -173,11 +173,18 @@ endif enable_lto = get_option('b_lto') if enable_lto - # meson already adds '-flto' - lto_flag = '-flto-partition=none' - assert(cc.has_argument(lto_flag), '-flto-partition=none not supported. Disable link-time optimization with -Db_lto=false.') - common_flags += lto_flag - common_ldflags += lto_flag + if cc.get_id() == 'clang' + clang_version = cc.version() + if clang_version <= '18.0.0' + error('Clang version should be greater then 18.0.0 got : ' + clang_version) + endif + else + # Meson already adds '-flto' + lto_flag = '-flto-partition=none' + assert(cc.has_argument(lto_flag), '-flto-partition=none not supported. Disable link-time optimization with -Db_lto=false.') + common_flags += lto_flag + common_ldflags += lto_flag + endif endif common_flags += cc.get_supported_arguments([