aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-02-17 03:53:22 -0600
committerRob Landley <rob@landley.net>2020-02-17 03:53:22 -0600
commit3300fa568738c0dde6e0a5c389f8a084746a44a9 (patch)
tree713edc7ddf0370d0d9fdb3a52d2f79ff35da3bd5 /scripts
parentf40ea28c36c429b5ba9cce3bf48285a818fd7fbf (diff)
downloadtoybox-3300fa568738c0dde6e0a5c389f8a084746a44a9.tar.gz
Fix musl-cross-make nommu build (at least for sh2eb).
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mcm-buildall.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/scripts/mcm-buildall.sh b/scripts/mcm-buildall.sh
index 6e36c7c4..e82ce2d5 100755
--- a/scripts/mcm-buildall.sh
+++ b/scripts/mcm-buildall.sh
@@ -127,6 +127,94 @@ make_tuple()
done
}
+# Packages detect nommu via the absence of fork(). Musl provides a broken fork()
+# on nommu builds that always returns -ENOSYS at runtime. Rip it out.
+# (Currently only for superh/jcore.)
+fix_nommu()
+{
+ # Rich won't merge this
+ sed -i 's/--enable-fdpic$/& --enable-twoprocess/' litecross/Makefile
+
+ PP=patches/musl-"$(sed -n 's/MUSL_VER[ \t]*=[ \t]*//p' Makefile)"
+ mkdir -p "$PP" &&
+ cat > "$PP"/0001-nommu.patch << 'EOF'
+--- a/include/features.h
++++ b/include/features.h
+@@ -3,2 +3,4 @@
+
++#define __MUSL__ 1
++
+ #if defined(_ALL_SOURCE) && !defined(_GNU_SOURCE)
+--- a/src/legacy/daemon.c
++++ b/src/legacy/daemon.c
+@@ -17,3 +17,3 @@
+
+- switch(fork()) {
++ switch(vfork()) {
+ case 0: break;
+@@ -25,3 +25,3 @@
+
+- switch(fork()) {
++ switch(vfork()) {
+ case 0: break;
+--- a/src/misc/forkpty.c
++++ b/src/misc/forkpty.c
+@@ -8,2 +8,3 @@
+
++#ifndef __SH_FDPIC__
+ int forkpty(int *pm, char *name, const struct termios *tio, const struct winsize *ws)
+@@ -57,1 +58,2 @@
+ }
++#endif
+--- a/src/misc/wordexp.c
++++ b/src/misc/wordexp.c
+@@ -25,2 +25,3 @@
+
++#ifndef __SH_FDPIC__
+ static int do_wordexp(const char *s, wordexp_t *we, int flags)
+@@ -177,2 +178,3 @@
+ }
++#endif
+
+--- a/src/process/fork.c
++++ b/src/process/fork.c
+@@ -7,2 +7,3 @@
+
++#ifndef __SH_FDPIC__
+ static void dummy(int x)
+@@ -37,1 +38,2 @@
+ }
++#endif
+--- a/Makefile
++++ b/Makefile
+@@ -100,3 +100,3 @@
+ cp $< $@
+- sed -n -e s/__NR_/SYS_/p < $< >> $@
++ sed -e s/__NR_/SYS_/ < $< >> $@
+
+--- a/arch/sh/bits/syscall.h.in
++++ b/arch/sh/bits/syscall.h.in
+@@ -2,3 +2,5 @@
+ #define __NR_exit 1
++#ifndef __SH_FDPIC__
+ #define __NR_fork 2
++#endif
+ #define __NR_read 3
+EOF
+
+ # I won't sign the FSF's copyright assignment
+ tee $(for i in patches/gcc-*; do echo $i/099-vfork.patch; done) > /dev/null << 'EOF'
+--- gcc-8.3.0/fixincludes/procopen.c 2005-08-14 19:50:43.000000000 -0500
++++ gcc-bak/fixincludes/procopen.c 2020-02-06 23:27:15.408071708 -0600
+@@ -116,3 +116,3 @@
+ */
+- ch_id = fork ();
++ ch_id = vfork ();
+ switch (ch_id)
+EOF
+}
+
+fix_nommu || exit 1
mkdir -p "$OUTPUT"/log
# Make bootstrap compiler (no $TYPE, dynamically linked against host libc)