From: Arkadiusz Miśkiewicz Date: Tue, 15 May 2018 10:20:33 +0000 (+0200) Subject: - rel 7; fixes build with glibc 2.27 X-Git-Tag: auto/th/systemd-235-7 X-Git-Url: http://git.pld-linux.org/?p=packages%2Fsystemd.git;a=commitdiff_plain;h=c145854 - rel 7; fixes build with glibc 2.27 --- diff --git a/systemd-glibc.patch b/systemd-glibc.patch new file mode 100644 index 0000000..adcf185 --- /dev/null +++ b/systemd-glibc.patch @@ -0,0 +1,639 @@ +commit 0e50bfaefde2a01792f4e4bcad7e0d822c74835b +Author: Yu Watanabe +Date: Mon Dec 25 19:42:42 2017 +0900 + + meson: define _GNU_SOURCE to detect copy_file_range() (#7734) + + Follow-up for bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f of git + repository for glibc. + + Recently glibc added `copy_file_range()`, but to use it, + `_GNU_SOURCE` needs to be defined. This adds the flag in + meson.build to detect the function by meson correctly. + +diff --git a/meson.build b/meson.build +index be8e61045..f3a65b389 100644 +--- a/meson.build ++++ b/meson.build +@@ -468,7 +468,8 @@ foreach ident : [ + ['kcmp', '''#include '''], + ['keyctl', '''#include + #include '''], +- ['copy_file_range', '''#include ++ ['copy_file_range', '''#define _GNU_SOURCE ++ #include + #include '''], + ['bpf', '''#include + #include '''], +commit 85db59b794d1ca7f16ea816c916bb4472958cc1b +Author: Lennart Poettering +Date: Mon Dec 25 12:01:14 2017 +0100 + + meson: use "args" for setting _GNU_SOURCE when checking for functions + + This reworks how we set _GNU_SOURCE when checking for the availability + of functions: + + 1. We set it for most of the functions we look for. After all we set it + for our entire built anyway, and it's usually how Linux-specific + definitions in glibc are protected these days. Given that we usually + have checks for such modern stuff only anyway, let's just blanket enable + it. + + 2. Use "args" instead of "prefix" to set the macro. This is what is + suggested in the meson docs, hence let's do it. + +diff --git a/meson.build b/meson.build +index f3a65b389..eda9e382b 100644 +--- a/meson.build ++++ b/meson.build +@@ -431,29 +431,26 @@ foreach ident : [ + ['memfd_create', '''#include '''], + ['gettid', '''#include '''], + ['pivot_root', '''#include '''], # no known header declares pivot_root +- ['name_to_handle_at', '''#define _GNU_SOURCE +- #include ++ ['name_to_handle_at', '''#include + #include + #include '''], +- ['setns', '''#define _GNU_SOURCE +- #include '''], ++ ['setns', '''#include '''], + ['renameat2', '''#include '''], + ['kcmp', '''#include '''], + ['keyctl', '''#include + #include '''], +- ['copy_file_range', '''#define _GNU_SOURCE +- #include ++ ['copy_file_range', '''#include + #include '''], + ['bpf', '''#include + #include '''], + ['explicit_bzero' , '''#include '''], + ] + +- have = cc.has_function(ident[0], prefix : ident[1]) ++ have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') + conf.set10('HAVE_' + ident[0].to_upper(), have) + endforeach + +-if cc.has_function('getrandom', prefix : '''#include ''') ++if cc.has_function('getrandom', prefix : '''#include ''', args : '-D_GNU_SOURCE') + conf.set10('USE_SYS_RANDOM_H', true) + conf.set10('HAVE_GETRANDOM', true) + else + +missing_syscall: when adding syscall replacements, use different names ( + +#8229) + +In meson.build we check that functions are available using: + meson.get_compiler('c').has_function('foo') +which checks the following: +- if __stub_foo or __stub___foo are defined, return false +- if foo is declared (a pointer to the function can be taken), return true +- otherwise check for __builtin_memfd_create + +_stub is documented by glibc as + It defines a symbol '__stub_FUNCTION' for each function + in the C library which is a stub, meaning it will fail + every time called, usually setting errno to ENOSYS. + +So if __stub is defined, we know we don't want to use the glibc version, but +this doesn't tell us if the name itself is defined or not. If it _is_ defined, +and we define our replacement as an inline static function, we get an error: + +In file included from ../src/basic/missing.h:1358:0, + from ../src/basic/util.h:47, + from ../src/basic/calendarspec.h:29, + from ../src/basic/calendarspec.c:34: +../src/basic/missing_syscall.h:65:19: error: static declaration of 'memfd_create' follows non-static declaration + static inline int memfd_create(const char *name, unsigned int flags) { + ^~~~~~~~~~~~ +.../usr/include/bits/mman-shared.h:46:5: note: previous declaration of 'memfd_create' was here + int memfd_create (const char *__name, unsigned int __flags) __THROW; + ^~~~~~~~~~~~ + +To avoid this problem, call our inline functions different than glibc, +and use a #define to map the official name to our replacement. + +Fixes #8099. + +v2: +- use "missing_" as the prefix instead of "_" + +v3: +- rebase and update for statx() + + Unfortunately "statx" is also present in "struct statx", so the define + causes issues. Work around this by using a typedef. + +I checked that systemd compiles with current glibc +(glibc-devel-2.26-24.fc27.x86_64) if HAVE_MEMFD_CREATE, HAVE_GETTID, +HAVE_PIVOT_ROOT, HAVE_SETNS, HAVE_RENAMEAT2, HAVE_KCMP, HAVE_KEYCTL, +HAVE_COPY_FILE_RANGE, HAVE_BPF, HAVE_STATX are forced to 0. + +Setting HAVE_NAME_TO_HANDLE_AT to 0 causes an issue, but it's not because of +the define, but because of struct file_handle. + + +backport https://github.com/systemd/systemd/commit/5187dd2c403caf92d09f3491e41f1ceb3f10491f + +Signed-off-by: Khem Raj +Upstream-Status: Backport [https://github.com/systemd/systemd/issues/8099] +Index: git/src/basic/missing_syscall.h +=================================================================== +--- git.orig/src/basic/missing_syscall.h ++++ git/src/basic/missing_syscall.h +@@ -26,9 +26,11 @@ + #include + + #if !HAVE_PIVOT_ROOT +-static inline int pivot_root(const char *new_root, const char *put_old) { ++static inline int missing_pivot_root(const char *new_root, const char *put_old) { + return syscall(SYS_pivot_root, new_root, put_old); + } ++ ++# define pivot_root missing_pivot_root + #endif + + #if !HAVE_CANONICALIZE_FILE_NAME +@@ -68,7 +70,7 @@ static inline char *canonicalize_file_na + # endif + # endif + +-static inline int memfd_create(const char *name, unsigned int flags) { ++static inline int missing_memfd_create(const char *name, unsigned int flags) { + # ifdef __NR_memfd_create + return syscall(__NR_memfd_create, name, flags); + # else +@@ -76,6 +78,8 @@ static inline int memfd_create(const cha + return -1; + # endif + } ++ ++# define memfd_create missing_memfd_create + #endif + + /* ======================================================================= */ +@@ -115,7 +119,7 @@ static inline int memfd_create(const cha + # endif + # endif + +-static inline int getrandom(void *buffer, size_t count, unsigned flags) { ++static inline int missing_getrandom(void *buffer, size_t count, unsigned flags) { + # ifdef __NR_getrandom + return syscall(__NR_getrandom, buffer, count, flags); + # else +@@ -123,14 +127,18 @@ static inline int getrandom(void *buffer + return -1; + # endif + } ++ ++# define getrandom missing_getrandom + #endif + + /* ======================================================================= */ + + #if !HAVE_GETTID +-static inline pid_t gettid(void) { ++static inline pid_t missing_gettid(void) { + return (pid_t) syscall(SYS_gettid); + } ++ ++# define gettid missing_gettid + #endif + + /* ======================================================================= */ +@@ -158,7 +166,7 @@ struct file_handle { + unsigned char f_handle[0]; + }; + +-static inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) { ++static inline int missing_name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) { + # ifdef __NR_name_to_handle_at + return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags); + # else +@@ -166,6 +174,8 @@ static inline int name_to_handle_at(int + return -1; + # endif + } ++ ++# define name_to_handle_at missing_name_to_handle_at + #endif + + /* ======================================================================= */ +@@ -183,7 +193,7 @@ static inline int name_to_handle_at(int + # endif + # endif + +-static inline int setns(int fd, int nstype) { ++static inline int missing_setns(int fd, int nstype) { + # ifdef __NR_setns + return syscall(__NR_setns, fd, nstype); + # else +@@ -191,6 +201,8 @@ static inline int setns(int fd, int nsty + return -1; + # endif + } ++ ++# define setns missing_setns + #endif + + /* ======================================================================= */ +@@ -236,7 +248,7 @@ static inline pid_t raw_getpid(void) { + # endif + # endif + +-static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) { ++static inline int missing_renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) { + # ifdef __NR_renameat2 + return syscall(__NR_renameat2, oldfd, oldname, newfd, newname, flags); + # else +@@ -244,12 +256,14 @@ static inline int renameat2(int oldfd, c + return -1; + # endif + } ++ ++# define renameat2 missing_renameat2 + #endif + + /* ======================================================================= */ + + #if !HAVE_KCMP +-static inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) { ++static inline int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) { + # ifdef __NR_kcmp + return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2); + # else +@@ -257,36 +271,44 @@ static inline int kcmp(pid_t pid1, pid_t + return -1; + # endif + } ++ ++# define kcmp missing_kcmp + #endif + + /* ======================================================================= */ + + #if !HAVE_KEYCTL +-static inline long keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4,unsigned long arg5) { ++static inline long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4,unsigned long arg5) { + # ifdef __NR_keyctl + return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); + # else + errno = ENOSYS; + return -1; + # endif ++ ++# define keyctl missing_keyctl + } + +-static inline key_serial_t add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) { ++static inline key_serial_t missing_add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) { + # ifdef __NR_add_key + return syscall(__NR_add_key, type, description, payload, plen, ringid); + # else + errno = ENOSYS; + return -1; + # endif ++ ++# define add_key missing_add_key + } + +-static inline key_serial_t request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) { ++static inline key_serial_t missing_request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) { + # ifdef __NR_request_key + return syscall(__NR_request_key, type, description, callout_info, destringid); + # else + errno = ENOSYS; + return -1; + # endif ++ ++# define request_key missing_request_key + } + #endif + +@@ -313,10 +335,10 @@ static inline key_serial_t request_key(c + # endif + # endif + +-static inline ssize_t copy_file_range(int fd_in, loff_t *off_in, +- int fd_out, loff_t *off_out, +- size_t len, +- unsigned int flags) { ++static inline ssize_t missing_copy_file_range(int fd_in, loff_t *off_in, ++ int fd_out, loff_t *off_out, ++ size_t len, ++ unsigned int flags) { + # ifdef __NR_copy_file_range + return syscall(__NR_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags); + # else +@@ -324,6 +346,8 @@ static inline ssize_t copy_file_range(in + return -1; + # endif + } ++ ++# define copy_file_range missing_copy_file_range + #endif + + /* ======================================================================= */ +@@ -351,7 +375,7 @@ static inline ssize_t copy_file_range(in + + union bpf_attr; + +-static inline int bpf(int cmd, union bpf_attr *attr, size_t size) { ++static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) { + #ifdef __NR_bpf + return (int) syscall(__NR_bpf, cmd, attr, size); + #else +@@ -360,6 +384,7 @@ static inline int bpf(int cmd, union bpf + #endif + } + ++# define bpf missing_bpf + #endif + + /* ======================================================================= */ +commit 848e863acc51ecfb0f3955c498874588201d9130 +Author: Franck Bui +Date: Thu Mar 15 06:23:46 2018 +0100 + + basic/macros: rename noreturn into _noreturn_ (#8456) + + "noreturn" is reserved and can be used in other header files we include: + + [ 16s] In file included from /usr/include/gcrypt.h:30:0, + [ 16s] from ../src/journal/journal-file.h:26, + [ 16s] from ../src/journal/journal-vacuum.c:31: + [ 16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token + [ 16s] void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); + + Here we include grcrypt.h (which in turns include gpg-error.h) *after* we + "noreturn" was defined in macro.h. + +diff --git a/src/basic/log.c b/src/basic/log.c +index 7a7f2cbec..16a2431c5 100644 +--- a/src/basic/log.c ++++ b/src/basic/log.c +@@ -814,7 +814,7 @@ static void log_assert( + log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer); + } + +-noreturn void log_assert_failed_realm( ++_noreturn_ void log_assert_failed_realm( + LogRealm realm, + const char *text, + const char *file, +@@ -826,7 +826,7 @@ noreturn void log_assert_failed_realm( + abort(); + } + +-noreturn void log_assert_failed_unreachable_realm( ++_noreturn_ void log_assert_failed_unreachable_realm( + LogRealm realm, + const char *text, + const char *file, +diff --git a/src/basic/log.h b/src/basic/log.h +index efcf0f1bf..314be128a 100644 +--- a/src/basic/log.h ++++ b/src/basic/log.h +@@ -186,7 +186,7 @@ int log_dump_internal( + char *buffer); + + /* Logging for various assertions */ +-noreturn void log_assert_failed_realm( ++_noreturn_ void log_assert_failed_realm( + LogRealm realm, + const char *text, + const char *file, +@@ -195,7 +195,7 @@ noreturn void log_assert_failed_realm( + #define log_assert_failed(text, ...) \ + log_assert_failed_realm(LOG_REALM, (text), __VA_ARGS__) + +-noreturn void log_assert_failed_unreachable_realm( ++_noreturn_ void log_assert_failed_unreachable_realm( + LogRealm realm, + const char *text, + const char *file, +diff --git a/src/basic/macro.h b/src/basic/macro.h +index 95be63a20..8911edfc4 100644 +--- a/src/basic/macro.h ++++ b/src/basic/macro.h +@@ -53,6 +53,15 @@ + #else + #define _fallthrough_ + #endif ++/* Define C11 noreturn without and even on older gcc ++ * compiler versions */ ++#ifndef _noreturn_ ++#if __STDC_VERSION__ >= 201112L ++#define _noreturn_ _Noreturn ++#else ++#define _noreturn_ __attribute__((noreturn)) ++#endif ++#endif + + /* Temporarily disable some warnings */ + #define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT \ +@@ -414,16 +423,6 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { + #endif + #endif + +-/* Define C11 noreturn without and even on older gcc +- * compiler versions */ +-#ifndef noreturn +-#if __STDC_VERSION__ >= 201112L +-#define noreturn _Noreturn +-#else +-#define noreturn __attribute__((noreturn)) +-#endif +-#endif +- + #define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \ + static inline void func##p(type *p) { \ + if (*p) \ +diff --git a/src/basic/process-util.c b/src/basic/process-util.c +index aa9846db5..e6120af5b 100644 +--- a/src/basic/process-util.c ++++ b/src/basic/process-util.c +@@ -987,7 +987,7 @@ bool is_main_thread(void) { + return cached > 0; + } + +-noreturn void freeze(void) { ++_noreturn_ void freeze(void) { + + log_close(); + +diff --git a/src/basic/process-util.h b/src/basic/process-util.h +index 93029e36e..5170adec7 100644 +--- a/src/basic/process-util.h ++++ b/src/basic/process-util.h +@@ -91,7 +91,7 @@ int pid_from_same_root_fs(pid_t pid); + + bool is_main_thread(void); + +-noreturn void freeze(void); ++_noreturn_ void freeze(void); + + bool oom_score_adjust_is_valid(int oa); + +diff --git a/src/core/main.c b/src/core/main.c +index 076846a41..4b2d14923 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -141,7 +141,7 @@ static uint64_t arg_default_tasks_max = UINT64_MAX; + static sd_id128_t arg_machine_id = {}; + static EmergencyAction arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE; + +-noreturn static void freeze_or_reboot(void) { ++_noreturn_ static void freeze_or_reboot(void) { + + if (arg_crash_reboot) { + log_notice("Rebooting in 10s..."); +@@ -156,7 +156,7 @@ noreturn static void freeze_or_reboot(void) { + freeze(); + } + +-noreturn static void crash(int sig) { ++_noreturn_ static void crash(int sig) { + struct sigaction sa; + pid_t pid; + +diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c +index 5a88b2774..d87bdbdd3 100644 +--- a/src/journal/test-journal-interleaving.c ++++ b/src/journal/test-journal-interleaving.c +@@ -37,7 +37,7 @@ + + static bool arg_keep = false; + +-noreturn static void log_assert_errno(const char *text, int error, const char *file, int line, const char *func) { ++_noreturn_ static void log_assert_errno(const char *text, int error, const char *file, int line, const char *func) { + log_internal(LOG_CRIT, error, file, line, func, + "'%s' failed at %s:%u (%s): %m", text, file, line, func); + abort(); +diff --git a/src/shared/pager.c b/src/shared/pager.c +index 75db3c985..681af9c40 100644 +--- a/src/shared/pager.c ++++ b/src/shared/pager.c +@@ -47,7 +47,7 @@ static int stored_stderr = -1; + static bool stdout_redirected = false; + static bool stderr_redirected = false; + +-noreturn static void pager_fallback(void) { ++_noreturn_ static void pager_fallback(void) { + int r; + + r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, (uint64_t) -1, 0); +diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c +index 2821640e9..c8fa47b3d 100644 +--- a/src/udev/collect/collect.c ++++ b/src/udev/collect/collect.c +@@ -58,7 +58,7 @@ static inline struct _mate *node_to_mate(struct udev_list_node *node) + return container_of(node, struct _mate, node); + } + +-noreturn static void sig_alrm(int signo) ++_noreturn_ static void sig_alrm(int signo) + { + exit(4); + } +From eb50b6d936c474f5bc2974c059f6432222af4de4 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 22 Mar 2018 12:50:45 +0100 +Subject: [PATCH] Fix linux/fs.h and sys/mount.h collisions + +* (kernel-headers) linux/fs.h and (glibc) sys/mount.h contains MS_* constants + and because it's without #ifdefs you cannot include the both files together + in the same code + +* (systemd) src/basic/missing.h contains another copy of MS_* constants + +The patch removes local systemd MS_* fallbacks, cleanup fs.h and +mount.h include. + +Signed-off-by: Karel Zak +--- + src/basic/missing.h | 40 ---------------------------------------- + src/core/load-fragment.c | 1 - + src/shared/bus-unit-util.c | 2 ++ + 3 files changed, 2 insertions(+), 41 deletions(-) + +diff --git a/src/basic/missing.h b/src/basic/missing.h +index 567aea8da9c..6802dd27c7b 100644 +--- a/src/basic/missing.h ++++ b/src/basic/missing.h +@@ -524,46 +524,6 @@ struct btrfs_ioctl_quota_ctl_args { + #define OCFS2_SUPER_MAGIC 0x7461636f + #endif + +-#ifndef MS_MOVE +-#define MS_MOVE 8192 +-#endif +- +-#ifndef MS_REC +-#define MS_REC 16384 +-#endif +- +-#ifndef MS_PRIVATE +-#define MS_PRIVATE (1<<18) +-#endif +- +-#ifndef MS_REC +-#define MS_REC (1<<19) +-#endif +- +-#ifndef MS_SHARED +-#define MS_SHARED (1<<20) +-#endif +- +-#ifndef MS_RELATIME +-#define MS_RELATIME (1<<21) +-#endif +- +-#ifndef MS_KERNMOUNT +-#define MS_KERNMOUNT (1<<22) +-#endif +- +-#ifndef MS_I_VERSION +-#define MS_I_VERSION (1<<23) +-#endif +- +-#ifndef MS_STRICTATIME +-#define MS_STRICTATIME (1<<24) +-#endif +- +-#ifndef MS_LAZYTIME +-#define MS_LAZYTIME (1<<25) +-#endif +- + #ifndef SCM_SECURITY + #define SCM_SECURITY 0x03 + #endif +diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c +index 94605ab0d02..49f8a8c6da1 100644 +--- a/src/core/load-fragment.c ++++ b/src/core/load-fragment.c +@@ -21,7 +21,6 @@ + + #include + #include +-#include + #include + #if HAVE_SECCOMP + #include +diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c +index 23e05daf48c..6e7ea10e714 100644 +--- a/src/shared/bus-unit-util.c ++++ b/src/shared/bus-unit-util.c +@@ -52,6 +52,8 @@ + #include "utf8.h" + #include "util.h" + ++#include ++ + int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) { + assert(message); + assert(u); diff --git a/systemd.spec b/systemd.spec index bcaa4e0..63ed484 100644 --- a/systemd.spec +++ b/systemd.spec @@ -26,7 +26,7 @@ Summary(pl.UTF-8): systemd - zarządca systemu i usług dla Linuksa Name: systemd # Verify ChangeLog and NEWS when updating (since there are incompatible/breaking changes very often) Version: 235 -Release: 6 +Release: 7 Epoch: 1 License: GPL v2+ (udev), LGPL v2.1+ (the rest) Group: Base @@ -64,7 +64,7 @@ Patch3: tmpfiles-not-fatal.patch Patch4: udev-ploop-rules.patch Patch5: udevadm-in-sbin.patch Patch6: net-rename-revert.patch - +Patch7: %{name}-glibc.patch Patch8: proc-hidepid.patch Patch9: %{name}-configfs.patch Patch10: pld-boot_efi_mount.patch @@ -628,7 +628,7 @@ Uzupełnianie parametrów w zsh dla poleceń udev. %patch5 -p1 # rejected upstream (do not disable!) %patch6 -p1 - +%patch7 -p1 %patch8 -p1 %patch9 -p1 %patch10 -p1