summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2020-02-14 10:00:07 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-02-15 10:26:42 +0000
commitb629da1df8125d1a671fec6ebd59813050a3099c (patch)
treeb2c31b21b5ea82e5e4712e4f93a1b1cc37f0bae7 /meta/recipes-core/busybox
parent717ba0a25669f469c7698399a79ad21661324edc (diff)
downloadpoky-b629da1df8125d1a671fec6ebd59813050a3099c.tar.gz
busybox: Backport patches to support removal of __NR_clock_gettime
This helps compiling with musl on 32bit arches now that musl has switched to 64bit time_t (From OE-Core rev: 8c3a220a91f90202233765a3b4eb1697c8be18f7) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/busybox')
-rw-r--r--meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch120
-rw-r--r--meta/recipes-core/busybox/busybox/0001-date-Use-64-prefix-syscall-if-we-have-to.patch53
-rw-r--r--meta/recipes-core/busybox/busybox/0001-time-Use-64-prefix-syscall-if-we-have-to.patch43
-rw-r--r--meta/recipes-core/busybox/busybox/0003-runsv-Use-64-prefix-syscall-if-we-have-to.patch46
-rw-r--r--meta/recipes-core/busybox/busybox_1.31.1.bb4
5 files changed, 266 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch b/meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch
new file mode 100644
index 0000000000..0c7f9b8132
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch
@@ -0,0 +1,120 @@
1From be5a505d771a77c640acc35ceaa470c80e62f954 Mon Sep 17 00:00:00 2001
2From: Denys Vlasenko <vda.linux@googlemail.com>
3Date: Thu, 24 Oct 2019 16:26:55 +0200
4Subject: [PATCH] Remove syscall wrappers around clock_gettime, closes 12091
5
612091 "Direct use of __NR_clock_gettime is not time64-safe".
7
8function old new delta
9runsv_main 1698 1712 +14
10startservice 378 383 +5
11get_mono 31 25 -6
12date_main 932 926 -6
13gettimeofday_ns 17 - -17
14------------------------------------------------------------------------------
15(add/remove: 0/1 grow/shrink: 2/2 up/down: 19/-29) Total: -10 bytes
16
17Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=be5a505d771a77c640acc35ceaa470c80e62f954]
18Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
19---
20 Makefile.flags | 6 ++++--
21 coreutils/date.c | 16 +++-------------
22 libbb/time.c | 11 +----------
23 runit/runsv.c | 11 +----------
24 4 files changed, 9 insertions(+), 35 deletions(-)
25
26--- a/Makefile.flags
27+++ b/Makefile.flags
28@@ -129,10 +129,12 @@ endif
29 # fall back to using a temp file:
30 CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >crypttest.c; $(CC) $(CFLAGS) -lcrypt -o /dev/null crypttest.c >/dev/null 2>&1 && echo "y"; rm crypttest.c)
31 ifeq ($(CRYPT_AVAILABLE),y)
32-LDLIBS += m crypt
33+LDLIBS += m rt crypt
34 else
35-LDLIBS += m
36+LDLIBS += m rt
37 endif
38+# libm may be needed for dc, awk, ntpd
39+# librt may be needed for clock_gettime()
40
41 # libpam may use libpthread, libdl and/or libaudit.
42 # On some platforms that requires an explicit -lpthread, -ldl, -laudit.
43--- a/coreutils/date.c
44+++ b/coreutils/date.c
45@@ -33,10 +33,9 @@
46 //config: Enable option (-I) to output an ISO-8601 compliant
47 //config: date/time string.
48 //config:
49-//config:# defaults to "no": stat's nanosecond field is a bit non-portable
50 //config:config FEATURE_DATE_NANO
51 //config: bool "Support %[num]N nanosecond format specifier"
52-//config: default n # syscall(__NR_clock_gettime) or syscall(__NR_clock_gettime64)
53+//config: default n # stat's nanosecond field is a bit non-portable
54 //config: depends on DATE
55 //config: select PLATFORM_LINUX
56 //config: help
57@@ -271,17 +270,8 @@ int date_main(int argc UNUSED_PARAM, cha
58 */
59 #endif
60 } else {
61-#if ENABLE_FEATURE_DATE_NANO && defined(__NR_clock_gettime)
62- /* libc has incredibly messy way of doing this,
63- * typically requiring -lrt. We just skip all this mess */
64- syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
65-#elif ENABLE_FEATURE_DATE_NANO && __TIMESIZE == 64
66- /* Let's only support the 64 suffix syscalls for 64-bit time_t.
67- * This simplifies the code for us as we don't need to convert
68- * between 64-bit and 32-bit. We also don't have a way to
69- * report overflow errors here.
70- */
71- syscall(__NR_clock_gettime64, CLOCK_REALTIME, &ts);
72+#if ENABLE_FEATURE_DATE_NANO
73+ clock_gettime(CLOCK_REALTIME, &ts);
74 #else
75 time(&ts.tv_sec);
76 #endif
77--- a/libbb/time.c
78+++ b/libbb/time.c
79@@ -253,18 +253,9 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS(
80 #define CLOCK_MONOTONIC 1
81 #endif
82
83-/* libc has incredibly messy way of doing this,
84- * typically requiring -lrt. We just skip all this mess */
85 static void get_mono(struct timespec *ts)
86 {
87-#if defined(__NR_clock_gettime)
88- if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
89-#elif __TIMESIZE == 64
90- if (syscall(__NR_clock_gettime64, CLOCK_MONOTONIC, ts))
91-#else
92-# error "We currently don't support architectures without " \
93- "the __NR_clock_gettime syscall and 32-bit time_t"
94-#endif
95+ if (clock_gettime(CLOCK_MONOTONIC, ts))
96 bb_error_msg_and_die("clock_gettime(MONOTONIC) failed");
97 }
98 unsigned long long FAST_FUNC monotonic_ns(void)
99--- a/runit/runsv.c
100+++ b/runit/runsv.c
101@@ -51,18 +51,9 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAG
102 #if ENABLE_MONOTONIC_SYSCALL
103 #include <sys/syscall.h>
104
105-/* libc has incredibly messy way of doing this,
106- * typically requiring -lrt. We just skip all this mess */
107 static void gettimeofday_ns(struct timespec *ts)
108 {
109-#if defined(__NR_clock_gettime)
110- syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
111-#elif __TIMESIZE == 64
112- syscall(__NR_clock_gettime64, CLOCK_REALTIME, ts);
113-#else
114-# error "We currently don't support architectures without " \
115- "the __NR_clock_gettime syscall and 32-bit time_t"
116-#endif
117+ clock_gettime(CLOCK_REALTIME, ts);
118 }
119 #else
120 static void gettimeofday_ns(struct timespec *ts)
diff --git a/meta/recipes-core/busybox/busybox/0001-date-Use-64-prefix-syscall-if-we-have-to.patch b/meta/recipes-core/busybox/busybox/0001-date-Use-64-prefix-syscall-if-we-have-to.patch
new file mode 100644
index 0000000000..944526b7ca
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-date-Use-64-prefix-syscall-if-we-have-to.patch
@@ -0,0 +1,53 @@
1From b7b7452f292f03eefafa6fd1da9bcfc933dee15a Mon Sep 17 00:00:00 2001
2From: Alistair Francis <alistair.francis@wdc.com>
3Date: Wed, 18 Sep 2019 09:28:49 -0700
4Subject: [PATCH] date: Use 64 prefix syscall if we have to
5
6Some 32-bit architectures no longer have the 32-bit time_t syscalls.
7Instead they have suffixed syscalls that returns a 64-bit time_t. If
8the architecture doesn't have the non-suffixed syscall and is using a
964-bit time_t let's use the suffixed syscall instead.
10
11This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
12headers.
13
14If an architecture only supports the suffixed syscalls, but is still
15using a 32-bit time_t fall back to the libc call.
16
17Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=b7b7452f292f03eefafa6fd1da9bcfc933dee15a]
18Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
19Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
20---
21 coreutils/date.c | 11 +++++++++--
22 1 file changed, 9 insertions(+), 2 deletions(-)
23
24--- a/coreutils/date.c
25+++ b/coreutils/date.c
26@@ -36,7 +36,7 @@
27 //config:# defaults to "no": stat's nanosecond field is a bit non-portable
28 //config:config FEATURE_DATE_NANO
29 //config: bool "Support %[num]N nanosecond format specifier"
30-//config: default n # syscall(__NR_clock_gettime)
31+//config: default n # syscall(__NR_clock_gettime) or syscall(__NR_clock_gettime64)
32 //config: depends on DATE
33 //config: select PLATFORM_LINUX
34 //config: help
35@@ -271,10 +271,17 @@ int date_main(int argc UNUSED_PARAM, cha
36 */
37 #endif
38 } else {
39-#if ENABLE_FEATURE_DATE_NANO
40+#if ENABLE_FEATURE_DATE_NANO && defined(__NR_clock_gettime)
41 /* libc has incredibly messy way of doing this,
42 * typically requiring -lrt. We just skip all this mess */
43 syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
44+#elif ENABLE_FEATURE_DATE_NANO && __TIMESIZE == 64
45+ /* Let's only support the 64 suffix syscalls for 64-bit time_t.
46+ * This simplifies the code for us as we don't need to convert
47+ * between 64-bit and 32-bit. We also don't have a way to
48+ * report overflow errors here.
49+ */
50+ syscall(__NR_clock_gettime64, CLOCK_REALTIME, &ts);
51 #else
52 time(&ts.tv_sec);
53 #endif
diff --git a/meta/recipes-core/busybox/busybox/0001-time-Use-64-prefix-syscall-if-we-have-to.patch b/meta/recipes-core/busybox/busybox/0001-time-Use-64-prefix-syscall-if-we-have-to.patch
new file mode 100644
index 0000000000..58a6c0d8a0
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-time-Use-64-prefix-syscall-if-we-have-to.patch
@@ -0,0 +1,43 @@
1From 902d3992922fc8db8495d5fb30a4581711b60c62 Mon Sep 17 00:00:00 2001
2From: Alistair Francis <alistair.francis@wdc.com>
3Date: Wed, 18 Sep 2019 09:28:50 -0700
4Subject: [PATCH] time: Use 64 prefix syscall if we have to
5
6Some 32-bit architectures no longer have the 32-bit time_t syscalls.
7Instead they have suffixed syscalls that returns a 64-bit time_t. If
8the architecture doesn't have the non-suffixed syscall and is using a
964-bit time_t let's use the suffixed syscall instead.
10
11This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
12headers.
13
14If an architecture only supports the suffixed syscalls, but is still
15using a 32-bit time_t report a compilation error. This avoids us have to
16deal with converting between 64-bit and 32-bit values. There are
17currently no architectures where this is the case.
18
19Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=902d3992922fc8db8495d5fb30a4581711b60c62]
20Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
21Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
22---
23 libbb/time.c | 7 +++++++
24 1 file changed, 7 insertions(+)
25
26--- a/libbb/time.c
27+++ b/libbb/time.c
28@@ -257,7 +257,14 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS(
29 * typically requiring -lrt. We just skip all this mess */
30 static void get_mono(struct timespec *ts)
31 {
32- if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
33+#if defined(__NR_clock_gettime)
34+ if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
35+#elif __TIMESIZE == 64
36+ if (syscall(__NR_clock_gettime64, CLOCK_MONOTONIC, ts))
37+#else
38+# error "We currently don't support architectures without " \
39+ "the __NR_clock_gettime syscall and 32-bit time_t"
40+#endif
41 bb_error_msg_and_die("clock_gettime(MONOTONIC) failed");
42 }
43 unsigned long long FAST_FUNC monotonic_ns(void)
diff --git a/meta/recipes-core/busybox/busybox/0003-runsv-Use-64-prefix-syscall-if-we-have-to.patch b/meta/recipes-core/busybox/busybox/0003-runsv-Use-64-prefix-syscall-if-we-have-to.patch
new file mode 100644
index 0000000000..4760570441
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0003-runsv-Use-64-prefix-syscall-if-we-have-to.patch
@@ -0,0 +1,46 @@
1From 8c7419649d6e6fda8fa7d0e863084c78ac728628 Mon Sep 17 00:00:00 2001
2From: Alistair Francis <alistair.francis@wdc.com>
3Date: Wed, 28 Aug 2019 10:54:15 -0700
4Subject: [PATCH 3/3] runsv: Use 64 prefix syscall if we have to
5
6Some 32-bit architectures no longer have the 32-bit time_t syscalls.
7Instead they have suffixed syscalls that returns a 64-bit time_t. If
8the architecture doesn't have the non-suffixed syscall and is using a
964-bit time_t let's use the suffixed syscall instead.
10
11This fixes build issues when building for RISC-V 32-bit with 5.1+ kernel
12headers.
13
14If an architecture only supports the suffixed syscalls, but is still
15using a 32-bit time_t report a compilation error. This avoids us have to
16deal with converting between 64-bit and 32-bit values. There are
17currently no architectures where this is the case.
18
19Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
20Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=ad27d44ebe950335616f37e36863469dc181b455]
21---
22 runit/runsv.c | 7 +++++++
23 1 file changed, 7 insertions(+)
24
25diff --git a/runit/runsv.c b/runit/runsv.c
26index ccc762d78..737909b0e 100644
27--- a/runit/runsv.c
28+++ b/runit/runsv.c
29@@ -55,7 +55,14 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * typically requiring -lrt. We just skip all this mess */
31 static void gettimeofday_ns(struct timespec *ts)
32 {
33+#if defined(__NR_clock_gettime)
34 syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
35+#elif __TIMESIZE == 64
36+ syscall(__NR_clock_gettime64, CLOCK_REALTIME, ts);
37+#else
38+# error "We currently don't support architectures without " \
39+ "the __NR_clock_gettime syscall and 32-bit time_t"
40+#endif
41 }
42 #else
43 static void gettimeofday_ns(struct timespec *ts)
44--
452.22.0
46
diff --git a/meta/recipes-core/busybox/busybox_1.31.1.bb b/meta/recipes-core/busybox/busybox_1.31.1.bb
index 1d0102eb2b..ec5b580442 100644
--- a/meta/recipes-core/busybox/busybox_1.31.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.31.1.bb
@@ -42,6 +42,10 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
42 file://0001-testsuite-check-uudecode-before-using-it.patch \ 42 file://0001-testsuite-check-uudecode-before-using-it.patch \
43 file://0001-testsuite-use-www.example.org-for-wget-test-cases.patch \ 43 file://0001-testsuite-use-www.example.org-for-wget-test-cases.patch \
44 file://0001-du-l-works-fix-to-use-145-instead-of-144.patch \ 44 file://0001-du-l-works-fix-to-use-145-instead-of-144.patch \
45 file://0001-date-Use-64-prefix-syscall-if-we-have-to.patch \
46 file://0001-time-Use-64-prefix-syscall-if-we-have-to.patch \
47 file://0003-runsv-Use-64-prefix-syscall-if-we-have-to.patch \
48 file://0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch \
45 file://0001-Remove-stime-function-calls.patch \ 49 file://0001-Remove-stime-function-calls.patch \
46" 50"
47SRC_URI_append_libc-musl = " file://musl.cfg " 51SRC_URI_append_libc-musl = " file://musl.cfg "