mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 00:10:31 +01:00
build: remove -flto-partition=none when building with GCC
Older versions of GCC (< 12) have issues building NM with LTO because
they drop libnm symbols added via '_asm__(".symver " ...)', which we
use to support symbols backported to older versions of the DSO.
Nowadays, GCC supports a new "__symver__" attribute that is
LTO-friendly; use that when possible and remove the
-flto-partition=none hack, as it increases memory usage when
compiling.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1714
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2142
This commit is contained in:
parent
481afec6ea
commit
5ed963e054
2 changed files with 23 additions and 6 deletions
12
meson.build
12
meson.build
|
|
@ -173,13 +173,13 @@ endif
|
|||
|
||||
enable_lto = get_option('b_lto')
|
||||
if enable_lto
|
||||
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)
|
||||
cc_version = cc.version()
|
||||
if cc.get_id() == 'clang'
|
||||
if cc_version <= '18.0.0'
|
||||
error('Clang version should be greater than 18.0.0, got : ' + cc_version)
|
||||
endif
|
||||
else
|
||||
# Meson already adds '-flto'
|
||||
elif cc_version < '12.0'
|
||||
# GCC < 12 breaks libnm symbol versioning with LTO, use workarounds
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1021,6 +1021,22 @@ nm_g_variant_equal(GVariant *a, GVariant *b)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 12)
|
||||
#define _NM_BACKPORT_SYMBOL_IMPL(version, \
|
||||
return_type, \
|
||||
orig_func, \
|
||||
versioned_func, \
|
||||
args_typed, \
|
||||
args) \
|
||||
return_type versioned_func args_typed; \
|
||||
\
|
||||
__attribute__((__symver__( \
|
||||
G_STRINGIFY(orig_func) "@" G_STRINGIFY(version)))) return_type versioned_func args_typed \
|
||||
{ \
|
||||
return orig_func args; \
|
||||
} \
|
||||
return_type orig_func args_typed;
|
||||
#else
|
||||
#define _NM_BACKPORT_SYMBOL_IMPL(version, \
|
||||
return_type, \
|
||||
orig_func, \
|
||||
|
|
@ -1035,6 +1051,7 @@ nm_g_variant_equal(GVariant *a, GVariant *b)
|
|||
return_type orig_func args_typed; \
|
||||
__asm__(".symver " G_STRINGIFY(versioned_func) ", " G_STRINGIFY(orig_func) "@" G_STRINGIFY( \
|
||||
version))
|
||||
#endif
|
||||
|
||||
#define NM_BACKPORT_SYMBOL(version, return_type, func, args_typed, args) \
|
||||
_NM_BACKPORT_SYMBOL_IMPL(version, return_type, func, _##func##_##version, args_typed, args)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue