diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2019-02-02 15:57:01 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2019-02-02 18:46:15 +0100 |
commit | 6010bc114193c8dd04ea8a0eef668cb0f03bb553 (patch) | |
tree | 8bab3e7b8442c6273c4e49d0002af2d6b8106590 | |
parent | 436a957859012e92e19d806e671093d1c6e380dd (diff) | |
download | NetworkManager-bg/lto.tar.gz |
build: fix building with LTObg/lto
Building with link-time optimization requires some tricks explained
in [1].
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200#c28
-rw-r--r-- | m4/compiler_options.m4 | 4 | ||||
-rw-r--r-- | meson.build | 11 | ||||
-rw-r--r-- | shared/nm-utils/nm-macros-internal.h | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index 1f283db692..9d0c58814b 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -150,9 +150,9 @@ fi AC_DEFUN([NM_LTO], [AC_ARG_ENABLE(lto, AS_HELP_STRING([--enable-lto], [Enable Link Time Optimization for smaller size (default: no)])) if (test "${enable_lto}" = "yes"); then - CC_CHECK_FLAG_APPEND([lto_flags], [CFLAGS], [-flto]) + CC_CHECK_FLAG_APPEND([lto_flags], [CFLAGS], [-flto -flto-partition=none]) if (test -n "${lto_flags}"); then - CFLAGS="-flto $CFLAGS" + CFLAGS="-flto -flto-partition=none $CFLAGS" else AC_MSG_ERROR([Link Time Optimization -flto is not supported.]) fi diff --git a/meson.build b/meson.build index c9307a6cad..0f2d946169 100644 --- a/meson.build +++ b/meson.build @@ -147,6 +147,15 @@ if enable_ld_gc common_ldflags += test_ldflags 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 +endif + if nm_debug common_flags += cc.get_supported_arguments([ '-fno-strict-aliasing', @@ -986,7 +995,7 @@ if enable_valgrind endif output += '\n' output += ' code coverage: ' + get_option('b_coverage').to_string() + '\n' -output += ' LTO: ' + get_option('b_lto').to_string() + '\n' +output += ' LTO: ' + enable_lto.to_string() + '\n' output += ' Linker garbage collection: ' + enable_ld_gc.to_string() + '\n' output += ' JSON validation for libnm: ' + enable_json_validation.to_string() + '\n' output += ' crypto: ' + crypto + ' (have-gnutls: ' + crypto_gnutls_dep.found().to_string() + ', have-nss: ' + crypto_nss_dep.found().to_string() + ')\n' diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index 0b2e458fd4..134d08ef79 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -1245,7 +1245,7 @@ fcn_name (lookup_type val) \ #define _NM_BACKPORT_SYMBOL_IMPL(version, return_type, orig_func, versioned_func, args_typed, args) \ return_type versioned_func args_typed; \ -return_type versioned_func args_typed \ +__attribute__ ((externally_visible)) return_type versioned_func args_typed \ { \ return orig_func args; \ } \ |