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', diff --git a/meson.build b/meson.build index 35b6ea0e34..6f1fa39e24 100644 --- a/meson.build +++ b/meson.build @@ -1383,7 +1383,7 @@ 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 + disable_mempool_c, version : libsystemd_version, include_directories : includes, link_args : ['-shared', @@ -1465,6 +1465,7 @@ subdir('test') test_dlopen = executable( 'test-dlopen', test_dlopen_c, + disable_mempool_c, include_directories : includes, link_with : [libbasic], dependencies : [libdl], @@ -1485,6 +1486,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 @@ -2782,12 +2784,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', @@ -2984,6 +2983,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(static_libsystemd), + 'static libudev: @0@'.format(static_libudev)] + # TODO: # CFLAGS: ${OUR_CFLAGS} ${CFLAGS} # CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS} @@ -3083,6 +3086,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 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..159c963377 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,21 @@ 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 (!mempool_use_allowed) + b = 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 +96,4 @@ void mempool_drop(struct mempool *mp) { p = n; } } - #endif diff --git a/src/basic/mempool.h b/src/basic/mempool.h index 4098535c6f..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,9 @@ static struct mempool pool_name = { \ .at_least = alloc_at_least, \ } +extern const bool mempool_use_allowed; +bool mempool_enabled(void); + #if VALGRIND void mempool_drop(struct mempool *mp); #endif 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 ff9453f480..83a2592c0a 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