From: Thomas Petazzoni Date: Wed, 12 Feb 2014 22:13:00 +0000 (+0100) Subject: systemd: fix build with uClibc toolchains X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=55ad3cfd3f9809f4a1f0210fe7c7110d147c54f6;p=buildroot.git systemd: fix build with uClibc toolchains Currently, the build of systemd is broken with the internal toolchain backend, because we have uClibc patches that add support for execvpe(), but we also have a patch for systemd that adds execvpe(), which was added when the internal uClibc didn't support execvpe(). However, simply dropping the patch is not a solution, as it would break the build of systemd with any other uClibc than the ones built with Buildroot. For example, a Crosstool-NG uClibc toolchain would fail. Beyond this execvpe() problem, there are also other problems that prevented systemd from being built with unpatched uClibc. This patch does the following: * Add sequence numbers of systemd patches. * Regenerate them to avoid fuzz. * Improve the uClibc compatibility patch so that it: - Detects whether execvpe() is available or not, and if not available provide an implementation. - Detects if dup3() is available or not, and if not available provide an implementation. - Detects if MSG_CMSG_CLOEXEC is defined or not, and if not, define it to the appropriate value. This has been tested with uClibc internal toolchain, uClibc external toolchain built with Buildroot, uClibc external toolchain built with Crosstool-NG, and glibc external toolchain. Fixes bug #6776. Fixes: http://autobuild.buildroot.org/results/591/591c6055430da334bd1e46e7d01497add45da837/build-end.log http://autobuild.buildroot.org/results/e58/e5851939d2837d4e35a4c1d9ca6df3c93ed5a34b/build-end.log http://autobuild.buildroot.org/results/92e/92e4c40c69a3feb4046b2fe5a0d8c69d5a44a157/build-end.log Signed-off-by: Thomas Petazzoni Signed-off-by: Peter Korsgaard --- diff --git a/package/systemd/systemd-01-fix-getty-unit.patch b/package/systemd/systemd-01-fix-getty-unit.patch new file mode 100644 index 0000000000..9008e434b4 --- /dev/null +++ b/package/systemd/systemd-01-fix-getty-unit.patch @@ -0,0 +1,34 @@ +Prefer getty to agetty in console setup systemd units + +Signed-off-by: Maxime Ripard +--- + units/getty@.service.m4 | 2 +- + units/serial-getty@.service.m4 | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +Index: b/units/getty@.service.m4 +=================================================================== +--- a/units/getty@.service.m4 ++++ b/units/getty@.service.m4 +@@ -35,7 +35,7 @@ + + [Service] + Environment=TERM=linux +-ExecStart=-/sbin/agetty %I 38400 ++ExecStart=-/sbin/getty -L %I 115200 vt100 + Restart=always + RestartSec=0 + UtmpIdentifier=%I +Index: b/units/serial-getty@.service.m4 +=================================================================== +--- a/units/serial-getty@.service.m4 ++++ b/units/serial-getty@.service.m4 +@@ -35,7 +35,7 @@ + + [Service] + Environment=TERM=vt100 +-ExecStart=-/sbin/agetty -s %I 115200,38400,9600 ++ExecStart=-/sbin/getty -L %I 115200 vt100 + Restart=always + RestartSec=0 + UtmpIdentifier=%I diff --git a/package/systemd/systemd-02-fix-page-size.patch b/package/systemd/systemd-02-fix-page-size.patch new file mode 100644 index 0000000000..a8b351aa6f --- /dev/null +++ b/package/systemd/systemd-02-fix-page-size.patch @@ -0,0 +1,43 @@ +commit 7264278fbbdc1dc6c30fedc902d1337594aa6ff6 +Author: Lennart Poettering +Date: Wed Mar 21 23:47:44 2012 +0100 + + journal: PAGE_SIZE is not known on ppc and other archs + + Let's use NAME_MAX, as suggested by Dan Walsh + +Index: b/src/journal/journald.c +=================================================================== +--- a/src/journal/journald.c ++++ b/src/journal/journald.c +@@ -29,7 +29,6 @@ + #include + #include + #include +-#include + + #include + #include +@@ -2141,10 +2140,20 @@ + size_t label_len = 0; + union { + struct cmsghdr cmsghdr; ++ ++ /* We use NAME_MAX space for the ++ * SELinux label here. The kernel ++ * currently enforces no limit, but ++ * according to suggestions from the ++ * SELinux people this will change and ++ * it will probably be identical to ++ * NAME_MAX. For now we use that, but ++ * this should be updated one day when ++ * the final limit is known.*/ + uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) + + CMSG_SPACE(sizeof(struct timeval)) + +- CMSG_SPACE(sizeof(int)) + +- CMSG_SPACE(PAGE_SIZE)]; /* selinux label */ ++ CMSG_SPACE(sizeof(int)) + /* fd */ ++ CMSG_SPACE(NAME_MAX)]; /* selinux label */ + } control; + ssize_t n; + int v; diff --git a/package/systemd/systemd-03-uclibc-fix.patch b/package/systemd/systemd-03-uclibc-fix.patch new file mode 100644 index 0000000000..f3b41c1a64 --- /dev/null +++ b/package/systemd/systemd-03-uclibc-fix.patch @@ -0,0 +1,84 @@ +[PATCH] fix build with uClibc + +Based on OE patch from Khem Raj: + +http://cgit.openembedded.org/meta-openembedded/tree/meta-oe/recipes-core/systemd/systemd/paper-over-mkostemp.patch + +But extended to also cover execvpe (OE carries a patch adding execvpe +support to uClibc). + +Signed-off-by: Peter Korsgaard +--- + src/journal/journal-file.c | 2 ++ + src/macro.h | 15 +++++++++++++++ + 2 files changed, 17 insertions(+) + +Index: b/src/macro.h +=================================================================== +--- a/src/macro.h ++++ b/src/macro.h +@@ -28,6 +28,33 @@ + #include + #include + ++#ifdef __UCLIBC__ ++/* uclibc does not implement mkostemp GNU extension */ ++#define mkostemp(x,y) mkstemp(x) ++/* uclibc may not define MSG_CMSG_CLOEXEC */ ++#if defined HAVE_DECL_MSG_CMSG_CLOEXEC && !HAVE_DECL_MSG_CMSG_CLOEXEC ++#define MSG_CMSG_CLOEXEC 0x40000000 ++#endif ++/* uclibc does not implement execvpe GNU extension */ ++#ifndef HAVE_EXECVPE ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif ++#include ++static inline int execvpe(const char *file, char *const argv[], ++ char *const envp[]) ++{ ++ environ = (char **)envp; ++ return execvp(file, argv); ++} ++#endif /* HAVE_EXECVPE */ ++#ifndef HAVE_DUP3 ++#include ++static inline int dup3(int oldfd, int newfd, int flags) { ++ return syscall(__NR_dup3, oldfd, newfd, flags); ++} ++#endif /* HAVE_DUP3 */ ++#endif /* __UCLIBC__ */ + #define _printf_attr_(a,b) __attribute__ ((format (printf, a, b))) + #define _sentinel_ __attribute__ ((sentinel)) + #define _noreturn_ __attribute__((noreturn)) +Index: b/src/journal/journal-file.c +=================================================================== +--- a/src/journal/journal-file.c ++++ b/src/journal/journal-file.c +@@ -229,11 +229,13 @@ + } + } + ++#ifndef __UCLIBC__ + /* Note that the glibc fallocate() fallback is very + inefficient, hence we try to minimize the allocation area + as we can. */ + if (posix_fallocate(f->fd, old_size, new_size - old_size) < 0) + return -errno; ++#endif + + if (fstat(f->fd, &f->last_stat) < 0) + return -errno; +Index: b/configure.ac +=================================================================== +--- a/configure.ac ++++ b/configure.ac +@@ -111,6 +111,8 @@ + + AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])]) + AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])]) ++AC_CHECK_FUNCS([execvpe dup3]) ++AC_CHECK_DECLS([MSG_CMSG_CLOEXEC], [], [], [#include ]) + + save_LIBS="$LIBS" + LIBS= diff --git a/package/systemd/systemd-fix-getty-unit.patch b/package/systemd/systemd-fix-getty-unit.patch deleted file mode 100644 index 6df54b1325..0000000000 --- a/package/systemd/systemd-fix-getty-unit.patch +++ /dev/null @@ -1,34 +0,0 @@ -Prefer getty to agetty in console setup systemd units - -Signed-off-by: Maxime Ripard ---- - units/getty@.service.m4 | 2 +- - units/serial-getty@.service.m4 | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -Index: systemd-37/units/getty@.service.m4 -=================================================================== ---- systemd-37.orig/units/getty@.service.m4 -+++ systemd-37/units/getty@.service.m4 -@@ -32,7 +32,7 @@ - - [Service] - Environment=TERM=linux --ExecStart=-/sbin/agetty %I 38400 -+ExecStart=-/sbin/getty -L %I 115200 vt100 - Restart=always - RestartSec=0 - UtmpIdentifier=%I -Index: systemd-37/units/serial-getty@.service.m4 -=================================================================== ---- systemd-37.orig/units/serial-getty@.service.m4 -+++ systemd-37/units/serial-getty@.service.m4 -@@ -32,7 +32,7 @@ - - [Service] - Environment=TERM=vt100 --ExecStart=-/sbin/agetty -s %I 115200,38400,9600 -+ExecStart=-/sbin/getty -L %I 115200 vt100 - Restart=always - RestartSec=0 - UtmpIdentifier=%I diff --git a/package/systemd/systemd-fix-page-size.patch b/package/systemd/systemd-fix-page-size.patch deleted file mode 100644 index 241ceb8c0b..0000000000 --- a/package/systemd/systemd-fix-page-size.patch +++ /dev/null @@ -1,43 +0,0 @@ -commit 7264278fbbdc1dc6c30fedc902d1337594aa6ff6 -Author: Lennart Poettering -Date: Wed Mar 21 23:47:44 2012 +0100 - - journal: PAGE_SIZE is not known on ppc and other archs - - Let's use NAME_MAX, as suggested by Dan Walsh - -diff --git a/src/journal/journald.c b/src/journal/journald.c -index d27cb60..87390bd 100644 ---- a/src/journal/journald.c -+++ b/src/journal/journald.c -@@ -29,7 +29,6 @@ - #include - #include - #include --#include - - #include - #include -@@ -2149,10 +2148,20 @@ static int process_event(Server *s, struct epoll_event *ev) { - size_t label_len = 0; - union { - struct cmsghdr cmsghdr; -+ -+ /* We use NAME_MAX space for the -+ * SELinux label here. The kernel -+ * currently enforces no limit, but -+ * according to suggestions from the -+ * SELinux people this will change and -+ * it will probably be identical to -+ * NAME_MAX. For now we use that, but -+ * this should be updated one day when -+ * the final limit is known.*/ - uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) + - CMSG_SPACE(sizeof(struct timeval)) + -- CMSG_SPACE(sizeof(int)) + -- CMSG_SPACE(PAGE_SIZE)]; /* selinux label */ -+ CMSG_SPACE(sizeof(int)) + /* fd */ -+ CMSG_SPACE(NAME_MAX)]; /* selinux label */ - } control; - ssize_t n; - int v; diff --git a/package/systemd/systemd-uclibc-fix.patch b/package/systemd/systemd-uclibc-fix.patch deleted file mode 100644 index 9a208450ad..0000000000 --- a/package/systemd/systemd-uclibc-fix.patch +++ /dev/null @@ -1,59 +0,0 @@ -[PATCH] fix build with uClibc - -Based on OE patch from Khem Raj: - -http://cgit.openembedded.org/meta-openembedded/tree/meta-oe/recipes-core/systemd/systemd/paper-over-mkostemp.patch - -But extended to also cover execvpe (OE carries a patch adding execvpe -support to uClibc). - -Signed-off-by: Peter Korsgaard ---- - src/journal/journal-file.c | 2 ++ - src/macro.h | 15 +++++++++++++++ - 2 files changed, 17 insertions(+) - -Index: systemd-44/src/macro.h -=================================================================== ---- systemd-44.orig/src/macro.h -+++ systemd-44/src/macro.h -@@ -28,6 +28,21 @@ - #include - #include - -+#ifdef __UCLIBC__ -+/* uclibc does not implement mkostemp GNU extension */ -+#define mkostemp(x,y) mkstemp(x) -+/* uclibc does not implement execvpe GNU extension */ -+#ifndef _GNU_SOURCE -+#define _GNU_SOURCE -+#endif -+#include -+static inline int execvpe(const char *file, char *const argv[], -+ char *const envp[]) -+{ -+ environ = (char **)envp; -+ return execvp(file, argv); -+} -+#endif - #define _printf_attr_(a,b) __attribute__ ((format (printf, a, b))) - #define _sentinel_ __attribute__ ((sentinel)) - #define _noreturn_ __attribute__((noreturn)) -Index: systemd-44/src/journal/journal-file.c -=================================================================== ---- systemd-44.orig/src/journal/journal-file.c -+++ systemd-44/src/journal/journal-file.c -@@ -229,11 +229,13 @@ - } - } - -+#ifndef __UCLIBC__ - /* Note that the glibc fallocate() fallback is very - inefficient, hence we try to minimize the allocation area - as we can. */ - if (posix_fallocate(f->fd, old_size, new_size - old_size) < 0) - return -errno; -+#endif - - if (fstat(f->fd, &f->last_stat) < 0) - return -errno; diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk index a5dc8e5914..bd901019ac 100644 --- a/package/systemd/systemd.mk +++ b/package/systemd/systemd.mk @@ -22,6 +22,8 @@ ifeq ($(BR2_PACKAGE_BUSYBOX),y) SYSTEMD_DEPENDENCIES += busybox endif +SYSTEMD_AUTORECONF = YES + SYSTEMD_CONF_OPT += \ --with-distro=other \ --disable-selinux \