From 2d4ceca8a5f606beed5f11b0d307913727590c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 19 Dec 2017 14:19:46 +0100 Subject: [PATCH] meson: link libbasic and libshared_static into libshared gcrypt_util_sources had to be moved because otherwise they appeared twice in libshared.so halfproducts, causing an error. -fvisibility=default is added to libbasic, libshared_static so that the symbols appear properly in the exported symbol list in libshared. The advantage is that files are not compiled twice. When configured with -Dman=false, the ninja target list is reduced from 1588 to 1347 targets. The difference in compilation time is small (<10%). I think this is because of -O0 and ccache and multiple cores, and in different settings the compilation time could be reduced. The main advantage is that errors and warnings are not reported twice. --- meson.build | 4 ++-- src/basic/meson.build | 8 ++++---- src/journal/meson.build | 2 -- src/shared/meson.build | 20 ++++++++++---------- src/test/meson.build | 3 ++- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/meson.build b/meson.build index 70b2d1b2c9..8ea3c03788 100644 --- a/meson.build +++ b/meson.build @@ -1231,8 +1231,7 @@ includes = include_directories('src/basic', 'src/libsystemd/sd-netlink', 'src/libsystemd/sd-network', 'src/libsystemd-network', - '.', - ) + '.') add_project_arguments('-include', 'config.h', language : 'c') @@ -1259,6 +1258,7 @@ libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sy libsystemd = shared_library( 'systemd', journal_internal_sources, + gcrypt_util_sources, version : libsystemd_version, include_directories : includes, link_args : ['-shared', diff --git a/src/basic/meson.build b/src/basic/meson.build index a37e279e57..43a2e11356 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see . -basic_sources_plain = files(''' +basic_sources = files(''' MurmurHash2.c MurmurHash2.h af-list.c @@ -294,7 +294,7 @@ foreach item : [['af', af_list_txt, 'af', ''], generated_gperf_headers += [target1, target2] endforeach -basic_sources = basic_sources_plain + [missing_h] + generated_gperf_headers +basic_sources += [missing_h] + generated_gperf_headers libbasic = static_library( 'basic', @@ -303,6 +303,6 @@ libbasic = static_library( dependencies : [threads, libcap, libblkid, - libselinux, - ], + libselinux], + c_args : ['-fvisibility=default'], install : false) diff --git a/src/journal/meson.build b/src/journal/meson.build index edb2a1a30e..e4d78f330d 100644 --- a/src/journal/meson.build +++ b/src/journal/meson.build @@ -44,8 +44,6 @@ if conf.get('HAVE_GCRYPT') == 1 fsprg.c fsprg.h '''.split()) - - journal_internal_sources += gcrypt_util_sources endif ############################################################ diff --git a/src/shared/meson.build b/src/shared/meson.build index 4620eaa007..a9ad217fec 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -159,24 +159,24 @@ libshared_deps = [threads, libshared_sym_path = '@0@/libshared.sym'.format(meson.current_source_dir()) -libshared = shared_library( +libshared_static = static_library( libshared_name, shared_sources, - basic_sources, + include_directories : includes, + dependencies : libshared_deps, + c_args : ['-fvisibility=default']) + +libshared = shared_library( + libshared_name, journal_internal_sources, libsystemd_sources, libudev_sources, include_directories : includes, link_args : ['-shared', - '-Wl,--version-script=' + libshared_sym_path], + '-Wl,--version-script=' + libshared_sym_path], + link_whole : [libshared_static, + libbasic], c_args : ['-fvisibility=default'], dependencies : libshared_deps, install : true, install_dir : rootlibexecdir) - -libshared_static = static_library( - libshared_name, - shared_sources, - basic_sources, - include_directories : includes, - dependencies : libshared_deps) diff --git a/src/test/meson.build b/src/test/meson.build index dcec53fa51..7ba73af704 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -119,6 +119,7 @@ tests += [ [['src/test/test-dns-domain.c'], [libcore, + libshared, libsystemd_network], []], @@ -167,7 +168,7 @@ tests += [ []], [['src/test/test-copy.c'], - [libshared_static], + [], []], [['src/test/test-sigbus.c'],