summaryrefslogtreecommitdiff
path: root/libnm-core
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-02-01 11:38:25 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2020-02-03 10:53:33 +0100
commitd2d6a68697556877b30703e412852ac5032957e9 (patch)
tree5f1999e302d94f71aab3ef1dcf84753466a24e12 /libnm-core
parentc11ac34f4c565018aa1a5fcbdef72d5b8b2f6070 (diff)
downloadNetworkManager-d2d6a68697556877b30703e412852ac5032957e9.tar.gz
build: use -fcommon when building libnm-core
Building with GCC 10 gives the following error: multiple definition of_nm_jansson_json_object_iter_key'; libnm/.libs/liblibnm.a(libnm_core_la-nm-json.o):/builddir/build/BUILD/NetworkManager-1.23.1/libnm-core/nm-json.c:24: first defined here /usr/bin/ld: libnm/.libs/liblibnm.a(libnm_core_la-nm-team-utils.o):/usr/include/jansson.h:202: multiple definition of _nm_jansson_json_object_iter'; This happens because GCC 10 defaults to -fno-common and so multiple definitions of the same global variable are not merged together. _nm_jansson_json_* symbols are defined in nm-json.c as void pointers and, due to the following macros in nm-json.h: #define json_object_iter_next (*_nm_jansson_json_object_iter_next) ... the function declaration in jansson.h: void *json_object_iter_next(json_t *object, void *iter); becomes a global variable as well: void *(*_nm_jansson_json_object_iter_next)(json_t *object, void *iter); So, the symbol is present in nm-json.o and all other object files that include nm-json.h, and -fcommon is required. Without it, it would be necessary to define the symbols only in one place (for example, nm-json.c), but then static inline functions from the jannson.h header would still refer to the original (missing) jansson functions. For the moment, just use -fcommon.
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/meson.build5
1 files changed, 4 insertions, 1 deletions
diff --git a/libnm-core/meson.build b/libnm-core/meson.build
index 27d6e2c8cc..42340f6457 100644
--- a/libnm-core/meson.build
+++ b/libnm-core/meson.build
@@ -188,9 +188,12 @@ links = [
libnm_libnm_core_intern,
]
+libnm_core_c_args = common_c_flags
+
if enable_json_validation
libnm_core_sources += files('nm-json.c')
deps += jansson_dep
+ libnm_core_c_args += ['-fcommon']
endif
libnm_core = static_library(
@@ -198,7 +201,7 @@ libnm_core = static_library(
sources: libnm_core_sources + libnm_core_enum_sources + nm_meta_setting_source + [nm_version_macro_header],
include_directories: top_inc,
dependencies: deps,
- c_args: common_c_flags,
+ c_args: libnm_core_c_args,
link_with: links,
)