build: allow building with clang+lto

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2053
This commit is contained in:
Luna D Dragon
2024-10-30 17:41:06 +05:30
committed by Lubomir Rintel
parent fd1a5b3c4b
commit 40c187dc15

View File

@@ -173,11 +173,18 @@ endif
enable_lto = get_option('b_lto')
if enable_lto
# meson already adds '-flto'
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([