From 19d8c9c9b7b3507eb2fdcf668a85456a4ae0dbeb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 5 Oct 2018 16:38:42 +0200 Subject: [PATCH 1/7] meson: include more build settings in status output --- meson.build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meson.build b/meson.build index 554e67e5dd..1d5a4f924e 100644 --- a/meson.build +++ b/meson.build @@ -2981,6 +2981,10 @@ alt_time_epoch = run_command('date', '-Is', '-u', '-d', status += [ 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)] +status += [ + 'static libsystemd: @0@'.format(get_option('static-libsystemd')), + 'static libudev: @0@'.format(get_option('static-libudev'))] + # TODO: # CFLAGS: ${OUR_CFLAGS} ${CFLAGS} # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} @@ -3080,6 +3084,8 @@ foreach tuple : [ ['debug mmap cache'], ['valgrind', conf.get('VALGRIND') == 1], ['trace logging', conf.get('LOG_TRACE') == 1], + ['link-udev-shared', get_option('link-udev-shared')], + ['link-systemctl-shared', get_option('link-systemctl-shared')], ] if tuple.length() >= 2 From 5dbf13fa6c2d5311a9fc236a0a95c1babcc11937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 24 Jul 2018 14:39:14 +0200 Subject: [PATCH 2/7] meson: drop workaround It was added way back, and seems to work fine now without it. --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index 1d5a4f924e..d25b724807 100644 --- a/meson.build +++ b/meson.build @@ -1380,7 +1380,6 @@ libjournal_core = static_library( libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym) libsystemd = shared_library( 'systemd', - 'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug version : libsystemd_version, include_directories : includes, link_args : ['-shared', From c42c98192484f48342c2c032ea3d00022bd20e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 24 Jul 2018 14:49:22 +0200 Subject: [PATCH 3/7] meson: remove old comment The linked page is gone, and I can't quite remember what the warning was about. Something about recursive copying... Everything seems to work. --- meson.build | 3 --- 1 file changed, 3 deletions(-) diff --git a/meson.build b/meson.build index d25b724807..1ef07ae1a3 100644 --- a/meson.build +++ b/meson.build @@ -2778,12 +2778,9 @@ subdir('shell-completion/zsh') subdir('docs/sysvinit') subdir('docs/var-log') -# FIXME: figure out if the warning is true: -# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir install_subdir('factory/etc', install_dir : factorydir) - install_data('xorg/50-systemd-user.sh', install_dir : xinitrcdir) install_data('modprobe.d/systemd.conf', From 6939fb9eb4c76de630b71f6b2ad98686d7fbd1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 24 Jul 2018 15:04:28 +0200 Subject: [PATCH 4/7] meson: update bug reference https://github.com/mesonbuild/meson/issues/1644 was resolved in 0.42: https://github.com/mesonbuild/meson/pull/2191/commits/be4428005dff8b17af5696c8f05567de9af1a8c5, but still no-go. --- man/meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/meson.build b/man/meson.build index 9cd93df846..05197d6ef4 100644 --- a/man/meson.build +++ b/man/meson.build @@ -166,7 +166,8 @@ foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directiv html_pages += p3 endforeach -# cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved +# Cannot use run_target because those targets are used in depends +# Also see https://github.com/mesonbuild/meson/issues/368. man = custom_target( 'man', output : 'man', From 7c48ea02800782651b7da373c6165abb052f1382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 9 Oct 2018 15:53:35 +0200 Subject: [PATCH 5/7] Move use_pool() to mempool.c and rename to mempool_enabled() The only user is in hashmap.c, but it's a mempool thing. --- src/basic/hashmap.c | 15 +-------------- src/basic/mempool.c | 16 ++++++++++++++-- src/basic/mempool.h | 2 ++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c index 44d718c83d..018ef5e7d8 100644 --- a/src/basic/hashmap.c +++ b/src/basic/hashmap.c @@ -6,7 +6,6 @@ #include #include "alloc-util.h" -#include "env-util.h" #include "fileio.h" #include "hashmap.h" #include "macro.h" @@ -767,24 +766,12 @@ static void reset_direct_storage(HashmapBase *h) { memset(p, DIB_RAW_INIT, sizeof(dib_raw_t) * hi->n_direct_buckets); } -static bool use_pool(void) { - static int b = -1; - - if (!is_main_thread()) - return false; - - if (b < 0) - b = getenv_bool("SYSTEMD_MEMPOOL") != 0; - - return b; -} - static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enum HashmapType type HASHMAP_DEBUG_PARAMS) { HashmapBase *h; const struct hashmap_type_info *hi = &hashmap_type_info[type]; bool up; - up = use_pool(); + up = mempool_enabled(); h = up ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size); if (!h) diff --git a/src/basic/mempool.c b/src/basic/mempool.c index a5ec8a1020..9f17b77e47 100644 --- a/src/basic/mempool.c +++ b/src/basic/mempool.c @@ -3,8 +3,10 @@ #include #include +#include "env-util.h" #include "macro.h" #include "mempool.h" +#include "process-util.h" #include "util.h" struct pool { @@ -70,8 +72,19 @@ void mempool_free_tile(struct mempool *mp, void *p) { mp->freelist = p; } -#if VALGRIND +bool mempool_enabled(void) { + static int b = -1; + if (!is_main_thread()) + return false; + + if (b < 0) + b = getenv_bool("SYSTEMD_MEMPOOL") != 0; + + return b; +} + +#if VALGRIND void mempool_drop(struct mempool *mp) { struct pool *p = mp->first_pool; while (p) { @@ -81,5 +94,4 @@ void mempool_drop(struct mempool *mp) { p = n; } } - #endif diff --git a/src/basic/mempool.h b/src/basic/mempool.h index 4098535c6f..d3ad63628f 100644 --- a/src/basic/mempool.h +++ b/src/basic/mempool.h @@ -22,6 +22,8 @@ static struct mempool pool_name = { \ .at_least = alloc_at_least, \ } +bool mempool_enabled(void); + #if VALGRIND void mempool_drop(struct mempool *mp); #endif From a5d8835c78112206bbf0812dd4cb471f803bfe88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 9 Oct 2018 16:02:55 +0200 Subject: [PATCH 6/7] mempool: only enable mempool use when linked to libsystemd-shared.so Mempool use is enabled or disabled based on the mempool_use_allowed symbol that is linked in. Should fix assert crashes in external programs caused by #9792. Replaces #10286. v2: - use two different source files instead of a gcc constructor --- meson.build | 3 +++ src/basic/mempool.c | 2 ++ src/basic/mempool.h | 2 ++ src/libsystemd/disable-mempool.c | 5 +++++ src/libsystemd/meson.build | 2 ++ src/shared/enable-mempool.c | 5 +++++ src/shared/meson.build | 1 + 7 files changed, 20 insertions(+) create mode 100644 src/libsystemd/disable-mempool.c create mode 100644 src/shared/enable-mempool.c diff --git a/meson.build b/meson.build index 1ef07ae1a3..09986d58dc 100644 --- a/meson.build +++ b/meson.build @@ -1380,6 +1380,7 @@ libjournal_core = static_library( libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym) libsystemd = shared_library( 'systemd', + disable_mempool_c, version : libsystemd_version, include_directories : includes, link_args : ['-shared', @@ -1461,6 +1462,7 @@ subdir('test') test_dlopen = executable( 'test-dlopen', test_dlopen_c, + disable_mempool_c, include_directories : includes, link_with : [libbasic], dependencies : [libdl], @@ -1481,6 +1483,7 @@ foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'], nss = shared_library( 'nss_' + module, 'src/nss-@0@/nss-@0@.c'.format(module), + disable_mempool_c, version : '2', include_directories : includes, # Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned diff --git a/src/basic/mempool.c b/src/basic/mempool.c index 9f17b77e47..159c963377 100644 --- a/src/basic/mempool.c +++ b/src/basic/mempool.c @@ -78,6 +78,8 @@ bool mempool_enabled(void) { if (!is_main_thread()) return false; + if (!mempool_use_allowed) + b = false; if (b < 0) b = getenv_bool("SYSTEMD_MEMPOOL") != 0; diff --git a/src/basic/mempool.h b/src/basic/mempool.h index d3ad63628f..0eecca0f92 100644 --- a/src/basic/mempool.h +++ b/src/basic/mempool.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once +#include #include struct pool; @@ -22,6 +23,7 @@ static struct mempool pool_name = { \ .at_least = alloc_at_least, \ } +extern const bool mempool_use_allowed; bool mempool_enabled(void); #if VALGRIND diff --git a/src/libsystemd/disable-mempool.c b/src/libsystemd/disable-mempool.c new file mode 100644 index 0000000000..034bd24dc4 --- /dev/null +++ b/src/libsystemd/disable-mempool.c @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +#include "mempool.h" + +const bool mempool_use_allowed = false; diff --git a/src/libsystemd/meson.build b/src/libsystemd/meson.build index e3716a68d8..d95406e7ac 100644 --- a/src/libsystemd/meson.build +++ b/src/libsystemd/meson.build @@ -81,6 +81,8 @@ libsystemd_sources = files(''' sd-utf8/sd-utf8.c '''.split()) + id128_sources + sd_daemon_c + sd_event_c + sd_login_c +disable_mempool_c = files('disable-mempool.c') + libsystemd_c_args = ['-fvisibility=default'] libsystemd_static = static_library( diff --git a/src/shared/enable-mempool.c b/src/shared/enable-mempool.c new file mode 100644 index 0000000000..a571b43f57 --- /dev/null +++ b/src/shared/enable-mempool.c @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: LGPL-2.1+ */ + +#include "mempool.h" + +const bool mempool_use_allowed = true; diff --git a/src/shared/meson.build b/src/shared/meson.build index 498b73c750..84d52a37eb 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -36,6 +36,7 @@ shared_sources = files(''' dropin.h efivars.c efivars.h + enable-mempool.c fdset.c fdset.h firewall-util.h From abc8caf76cc3158ec3569b9189ca3a09b220b4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 11 Oct 2018 11:10:53 +0200 Subject: [PATCH 7/7] meson: use vars we already have defined in status --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 09986d58dc..6c1b36eb06 100644 --- a/meson.build +++ b/meson.build @@ -2981,8 +2981,8 @@ status += [ 'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)] status += [ - 'static libsystemd: @0@'.format(get_option('static-libsystemd')), - 'static libudev: @0@'.format(get_option('static-libudev'))] + 'static libsystemd: @0@'.format(static_libsystemd), + 'static libudev: @0@'.format(static_libudev)] # TODO: # CFLAGS: ${OUR_CFLAGS} ${CFLAGS}