From: Khem Raj Date: Thu, 3 Aug 2023 04:55:08 +0000 (-0700) Subject: systemd: Make 254 work on musl X-Git-Tag: lucaceresoli/bug-15201-perf-libtraceevent-missing~208 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2a7dc1deaa7514c8257d828ee84da70185fc3eda;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git systemd: Make 254 work on musl Signed-off-by: Khem Raj Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- diff --git a/meta/recipes-core/systemd/systemd/0028-sd-event-Make-malloc_trim-conditional-on-glibc.patch b/meta/recipes-core/systemd/systemd/0028-sd-event-Make-malloc_trim-conditional-on-glibc.patch new file mode 100644 index 00000000000..c9ec00012e8 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0028-sd-event-Make-malloc_trim-conditional-on-glibc.patch @@ -0,0 +1,39 @@ +From 148645ba8b62f04c7c5ff5907378663f97880f22 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 2 Aug 2023 12:06:27 -0700 +Subject: [PATCH 1/4] sd-event: Make malloc_trim() conditional on glibc + +musl does not have this API + +Upstream-Status: Inappropriate [musl-specific] +Signed-off-by: Khem Raj +--- + src/libsystemd/sd-event/sd-event.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c +index aba458185b..48c94a7672 100644 +--- a/src/libsystemd/sd-event/sd-event.c ++++ b/src/libsystemd/sd-event/sd-event.c +@@ -1874,7 +1874,7 @@ _public_ int sd_event_add_exit( + } + + _public_ int sd_event_trim_memory(void) { +- int r; ++ int r = 0; + + /* A default implementation of a memory pressure callback. Simply releases our own allocation caches + * and glibc's. This is automatically used when people call sd_event_add_memory_pressure() with a +@@ -1888,7 +1888,9 @@ _public_ int sd_event_trim_memory(void) { + + usec_t before_timestamp = now(CLOCK_MONOTONIC); + hashmap_trim_pools(); ++#ifdef __GLIBC__ + r = malloc_trim(0); ++#endif + usec_t after_timestamp = now(CLOCK_MONOTONIC); + + if (r > 0) +-- +2.41.0 + diff --git a/meta/recipes-core/systemd/systemd/0029-shared-Do-not-use-malloc_info-on-musl.patch b/meta/recipes-core/systemd/systemd/0029-shared-Do-not-use-malloc_info-on-musl.patch new file mode 100644 index 00000000000..8e386551a19 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0029-shared-Do-not-use-malloc_info-on-musl.patch @@ -0,0 +1,50 @@ +From 9430646e72ea5d260ade300038a6d976fecf7da5 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 2 Aug 2023 12:20:40 -0700 +Subject: [PATCH 4/4] shared: Do not use malloc_info on musl + +Upstream-Status: Inappropriate [musl-specific] +Signed-off-by: Khem Raj +--- + src/shared/bus-util.c | 5 +++-- + src/shared/common-signal.c | 4 ++-- + 2 files changed, 5 insertions(+), 4 deletions(-) + +--- a/src/shared/bus-util.c ++++ b/src/shared/bus-util.c +@@ -617,15 +617,16 @@ static int method_dump_memory_state_by_f + _cleanup_close_ int fd = -EBADF; + size_t dump_size; + FILE *f; +- int r; ++ int r = 0; + + assert(message); + + f = memstream_init(&m); + if (!f) + return -ENOMEM; +- ++#ifdef __GLIBC__ + r = RET_NERRNO(malloc_info(/* options= */ 0, f)); ++#endif + if (r < 0) + return r; + +--- a/src/shared/common-signal.c ++++ b/src/shared/common-signal.c +@@ -65,12 +65,12 @@ int sigrtmin18_handler(sd_event_source * + log_oom(); + break; + } +- ++#ifdef __GLIBC__ + if (malloc_info(0, f) < 0) { + log_error_errno(errno, "Failed to invoke malloc_info(): %m"); + break; + } +- ++#endif + (void) memstream_dump(LOG_INFO, &m); + break; + } diff --git a/meta/recipes-core/systemd/systemd_254.bb b/meta/recipes-core/systemd/systemd_254.bb index 7ba4233f6a2..ea1a4f02f05 100644 --- a/meta/recipes-core/systemd/systemd_254.bb +++ b/meta/recipes-core/systemd/systemd_254.bb @@ -53,6 +53,8 @@ SRC_URI_MUSL = "\ file://0025-include-sys-file.h-for-LOCK_EX.patch \ file://0026-test-test-sizeof-Include-sys-timex.h-for-struct-time.patch \ file://0027-include-missing-sys-file.h-for-LOCK_EX.patch \ + file://0028-sd-event-Make-malloc_trim-conditional-on-glibc.patch \ + file://0029-shared-Do-not-use-malloc_info-on-musl.patch \ " PAM_PLUGINS = " \