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:
12
meson.build
12
meson.build
@@ -173,13 +173,13 @@ endif
|
|||||||
|
|
||||||
enable_lto = get_option('b_lto')
|
enable_lto = get_option('b_lto')
|
||||||
if enable_lto
|
if enable_lto
|
||||||
if cc.get_id() == 'clang'
|
cc_version = cc.version()
|
||||||
clang_version = cc.version()
|
if cc.get_id() == 'clang'
|
||||||
if clang_version <= '18.0.0'
|
if cc_version <= '18.0.0'
|
||||||
error('Clang version should be greater then 18.0.0 got : ' + clang_version)
|
error('Clang version should be greater than 18.0.0, got : ' + cc_version)
|
||||||
endif
|
endif
|
||||||
else
|
elif cc_version < '12.0'
|
||||||
# Meson already adds '-flto'
|
# GCC < 12 breaks libnm symbol versioning with LTO, use workarounds
|
||||||
lto_flag = '-flto-partition=none'
|
lto_flag = '-flto-partition=none'
|
||||||
assert(cc.has_argument(lto_flag), '-flto-partition=none not supported. Disable link-time optimization with -Db_lto=false.')
|
assert(cc.has_argument(lto_flag), '-flto-partition=none not supported. Disable link-time optimization with -Db_lto=false.')
|
||||||
common_flags += lto_flag
|
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, \
|
#define _NM_BACKPORT_SYMBOL_IMPL(version, \
|
||||||
return_type, \
|
return_type, \
|
||||||
orig_func, \
|
orig_func, \
|
||||||
@@ -1035,6 +1051,7 @@ nm_g_variant_equal(GVariant *a, GVariant *b)
|
|||||||
return_type orig_func args_typed; \
|
return_type orig_func args_typed; \
|
||||||
__asm__(".symver " G_STRINGIFY(versioned_func) ", " G_STRINGIFY(orig_func) "@" G_STRINGIFY( \
|
__asm__(".symver " G_STRINGIFY(versioned_func) ", " G_STRINGIFY(orig_func) "@" G_STRINGIFY( \
|
||||||
version))
|
version))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NM_BACKPORT_SYMBOL(version, return_type, func, args_typed, args) \
|
#define NM_BACKPORT_SYMBOL(version, return_type, func, args_typed, args) \
|
||||||
_NM_BACKPORT_SYMBOL_IMPL(version, return_type, func, _##func##_##version, args_typed, args)
|
_NM_BACKPORT_SYMBOL_IMPL(version, return_type, func, _##func##_##version, args_typed, args)
|
||||||
|
Reference in New Issue
Block a user