Remove the notion of "sys*"

- This idea originates from very early in the project and was, at the
  time, a very easy way to categorise things.
- Now, it doesn't really make much sense - it is fairly arbitary, often
  occuring when there is a change in kernel, but not from builder-hex0
  to fiwix, and sysb is in reality completely unnecessary.
- In short, the sys* stuff is a bit of a mess that makes the project
  more difficult to understand.
- This puts everything down into one folder and has a manifest file that
  is used to generate the build scripts on the fly rather than using
  coded scripts.
- This is created in the "seed" stage.

stage0-posix -- (calls) --> seed -- (generates) --> main steps

Alongside this change there are a variety of other smaller fixups to the
general structure of the live-bootstrap rootfs.

- Creating a rootfs has become much simpler and is defined as code in
  go.sh. The new structure, for an about-to-be booted system, is

/
-- /steps (direct copy of steps/)
-- /distfiles (direct copy of distfiles/)
-- all files from seed/*
-- all files from seed/stage0-posix/*

- There is no longer such a thing as /usr/include/musl, this didn't
  really make any sense, as musl is the final libc used. Rather, to
  separate musl and mes, we have /usr/include/mes, which is much easier
  to work with.
- This also makes mes easier to blow away later.
- A few things that weren't properly in packages have been changed;
  checksum-transcriber, simple-patch, kexec-fiwix have all been given
  fully qualified package names.
- Highly breaking change, scripts now exist in their package directory
  but NOT WITH THE packagename.sh. Rather, they use pass1.sh, pass2.sh,
  etc. This avoids manual definition of passes.
  - Ditto with patches; default directory is patches, but then any patch
    series specific to a pass are named patches-passX.
This commit is contained in:
fosslinux 2023-11-07 10:51:23 +11:00
parent 0907cfd073
commit 6ed2e09f3a
546 changed files with 700 additions and 1299 deletions

View file

@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2020 Timo Teräs <timo.teras@iki.fi>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
extern void __stack_chk_fail(void);
void __attribute__((visibility ("hidden"))) __stack_chk_fail_local(void) { __stack_chk_fail(); }

View file

@ -0,0 +1 @@
/usr/lib/i386-unknown-linux-musl

View file

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2022 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: GPL-3.0-or-later

33
steps/musl-1.2.4/pass1.sh Executable file
View file

@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_get() {
# Before the last pass the tar file is moved before
# the linux build removes all distfiles to save space.
if [ -e "../${pkg}.tar.gz" ]; then
mkdir "${DISTFILES}"
mv "../${pkg}.tar.gz" "${DISTFILES}"
else
default
fi
}
src_configure() {
CC=gcc ./configure \
--host=i386-unknown-linux-musl \
--disable-shared \
--prefix="${PREFIX}" \
--libdir="${LIBDIR}" \
--includedir="${PREFIX}/include/"
# configure script creates this file
if test -f /dev/null; then
rm /dev/null
mknod -m 666 /dev/null c 1 3
fi
}
src_compile() {
make "${MAKEJOBS}" CROSS_COMPILE=
}

1
steps/musl-1.2.4/pass2.sh Symbolic link
View file

@ -0,0 +1 @@
pass1.sh

46
steps/musl-1.2.4/pass3.sh Executable file
View file

@ -0,0 +1,46 @@
# SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_configure() {
./configure \
--host=i386-unknown-linux-musl \
--prefix="${PREFIX}" \
--libdir="${LIBDIR}" \
--includedir="${PREFIX}/include/"
}
src_compile() {
make "${MAKEJOBS}" CROSS_COMPILE=
}
src_install() {
default
# Make dynamic linker symlink relative in ${PREFIX}/lib
rm "${DESTDIR}/lib/ld-musl-i386.so.1"
rmdir "${DESTDIR}/lib"
mkdir -p "${DESTDIR}${PREFIX}/lib"
ln -sr "${DESTDIR}${LIBDIR}/libc.so" "${DESTDIR}${PREFIX}/lib/ld-musl-i386.so.1"
# Make startup objects available in /usr/lib
# Expected by GCC 10+
for i in crt1.o crti.o crtn.o Scrt1.o rcrt1.o; do
ln -sr "${DESTDIR}${LIBDIR}/${i}" "${DESTDIR}${PREFIX}/lib/${i}"
done
# Add symlink for ldd
mkdir -p "${DESTDIR}${PREFIX}/bin"
ln -s ../lib/ld-musl-i386.so.1 "${DESTDIR}${PREFIX}/bin/ldd"
# Add library search path configurtion
mkdir -p "${DESTDIR}/etc"
cp ld-musl-i386.path "${DESTDIR}/etc"
}
src_postprocess() {
# Stripping libc can cause some strange brokenness
:
}

View file

View file

@ -0,0 +1 @@
patches-pass2

View file

@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com>
# SPDX-License-Identifier: MIT
diff -r -u musl-1.2.3.orig/arch/i386/pthread_arch.h musl-1.2.3/arch/i386/pthread_arch.h
--- arch/i386/pthread_arch.h 2022-04-07 17:12:40.000000000 +0000
+++ arch/i386/pthread_arch.h 2023-04-07 12:07:07.929132587 +0000
@@ -1,8 +1,7 @@
+extern uintptr_t g_pthread;
static inline uintptr_t __get_tp()
{
- uintptr_t tp;
- __asm__ ("movl %%gs:0,%0" : "=r" (tp) );
- return tp;
+ return g_pthread;
}
#define MC_PC gregs[REG_EIP]
diff -r -u musl-1.2.3.orig/arch/i386/syscall_arch.h musl-1.2.3/arch/i386/syscall_arch.h
--- arch/i386/syscall_arch.h 2022-04-07 17:12:40.000000000 +0000
+++ arch/i386/syscall_arch.h 2022-12-20 17:28:21.734839560 +0000
@@ -1,3 +1,4 @@
+#define SYSCALL_NO_TLS 1
#define __SYSCALL_LL_E(x) \
((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
((union { long long ll; long l[2]; }){ .ll = x }).l[1]
diff -r -u musl-1.2.3.orig/src/env/__init_tls.c musl-1.2.3/src/env/__init_tls.c
--- src/env/__init_tls.c 2022-04-07 17:12:40.000000000 +0000
+++ src/env/__init_tls.c 2023-04-07 12:07:38.677133193 +0000
@@ -10,20 +10,19 @@
#include "syscall.h"
volatile int __thread_list_lock;
+uintptr_t g_pthread;
int __init_tp(void *p)
{
pthread_t td = p;
td->self = td;
- int r = __set_thread_area(TP_ADJ(p));
- if (r < 0) return -1;
- if (!r) libc.can_do_threads = 1;
td->detach_state = DT_JOINABLE;
td->tid = __syscall(SYS_set_tid_address, &__thread_list_lock);
td->locale = &libc.global_locale;
td->robust_list.head = &td->robust_list.head;
td->sysinfo = __sysinfo;
td->next = td->prev = td;
+ g_pthread = (uintptr_t) td;
return 0;
}

View file

@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2023 Richard Masters <grick23@gmail.com>
# SPDX-License-Identifier: MIT
--- src/process/posix_spawn.c 2022-04-07 17:12:40.000000000 +0000
+++ src/process/posix_spawn.c 2023-04-07 12:01:57.217126467 +0000
@@ -190,8 +190,11 @@
goto fail;
}
- pid = __clone(child, stack+sizeof stack,
- CLONE_VM|CLONE_VFORK|SIGCHLD, &args);
+ pid = fork();
+ if (pid == 0) {
+ _exit(child(&args));
+ }
+
close(args.p[1]);
UNLOCK(__abort_lock);

1
steps/musl-1.2.4/sources Normal file
View file

@ -0,0 +1 @@
https://musl.libc.org/releases/musl-1.2.4.tar.gz 7a35eae33d5372a7c0da1188de798726f68825513b7ae3ebe97aaaa52114f039