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

86
steps/tcc-0.9.27/pass1.kaem Executable file
View file

@ -0,0 +1,86 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
#
# SPDX-License-Identifier: GPL-3.0-or-later
set -ex
# Check tarball checksums
checksum-transcriber sources
sha256sum -c sources.SHA256SUM
# Extract
mkdir build src
cd src
unbz2 --file ${DISTFILES}/${pkg}.tar.bz2 --output ${pkg}.tar
ungz --file ${DISTFILES}/${MES_PKG}.tar.gz --output ${MES_PKG}.tar
cd ..
cd build
untar --file ../src/${pkg}.tar
simple-patch tcc-0.9.27/tcctools.c \
../simple-patches/remove-fileopen.before ../simple-patches/remove-fileopen.after
simple-patch tcc-0.9.27/tcctools.c \
../simple-patches/addback-fileopen.before ../simple-patches/addback-fileopen.after
simple-patch tcc-0.9.27/tccelf.c \
../simple-patches/fiwix-paddr.before ../simple-patches/fiwix-paddr.after
# Fix SIGSEGV while building lwext4
simple-patch tcc-0.9.27/tccelf.c \
../simple-patches/check-reloc-null.before ../simple-patches/check-reloc-null.after
untar --non-strict --file ../src/${MES_PKG}.tar
cd ${pkg}
# Create config.h
catm config.h
# Compile
tcc-0.9.26 \
-v \
-static \
-o ${BINDIR}/tcc \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\"${LIBDIR}/tcc\" \
-D CONFIG_TCC_CRTPREFIX=\"${LIBDIR}\" \
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
-D CONFIG_TCC_LIBPATHS=\"${LIBDIR}:${LIBDIR}/tcc\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${PREFIX}/include/mes\" \
-D TCC_LIBGCC=\"${LIBDIR}/libc.a\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
tcc.c
# Recompile the mes C library
cd ../${MES_PKG}
# Create unified libc file
cd lib
catm ../unified-libc.c ctype/isalnum.c ctype/isalpha.c ctype/isascii.c ctype/iscntrl.c ctype/isdigit.c ctype/isgraph.c ctype/islower.c ctype/isnumber.c ctype/isprint.c ctype/ispunct.c ctype/isspace.c ctype/isupper.c ctype/isxdigit.c ctype/tolower.c ctype/toupper.c dirent/closedir.c dirent/__getdirentries.c dirent/opendir.c dirent/readdir.c linux/access.c linux/brk.c linux/chdir.c linux/chmod.c linux/clock_gettime.c linux/close.c linux/dup2.c linux/dup.c linux/execve.c linux/fcntl.c linux/fork.c linux/fsync.c linux/fstat.c linux/_getcwd.c linux/getdents.c linux/getegid.c linux/geteuid.c linux/getgid.c linux/getpid.c linux/getppid.c linux/getrusage.c linux/gettimeofday.c linux/getuid.c linux/ioctl.c linux/ioctl3.c linux/kill.c linux/link.c linux/lseek.c linux/lstat.c linux/malloc.c linux/mkdir.c linux/mknod.c linux/nanosleep.c linux/_open3.c linux/pipe.c linux/_read.c linux/readlink.c linux/rename.c linux/rmdir.c linux/setgid.c linux/settimer.c linux/setuid.c linux/signal.c linux/sigprogmask.c linux/symlink.c linux/stat.c linux/time.c linux/unlink.c linux/waitpid.c linux/x86-mes-gcc/_exit.c linux/x86-mes-gcc/syscall.c linux/x86-mes-gcc/_write.c math/ceil.c math/fabs.c math/floor.c mes/abtod.c mes/abtol.c mes/__assert_fail.c mes/assert_msg.c mes/__buffered_read.c mes/__init_io.c mes/cast.c mes/dtoab.c mes/eputc.c mes/eputs.c mes/fdgetc.c mes/fdgets.c mes/fdputc.c mes/fdputs.c mes/fdungetc.c mes/globals.c mes/itoa.c mes/ltoab.c mes/ltoa.c mes/__mes_debug.c mes/mes_open.c mes/ntoab.c mes/oputc.c mes/oputs.c mes/search-path.c mes/ultoa.c mes/utoa.c posix/alarm.c posix/buffered-read.c posix/execl.c posix/execlp.c posix/execv.c posix/execvp.c posix/getcwd.c posix/getenv.c posix/isatty.c posix/mktemp.c posix/open.c posix/raise.c posix/sbrk.c posix/setenv.c posix/sleep.c posix/unsetenv.c posix/wait.c posix/write.c stdio/clearerr.c stdio/fclose.c stdio/fdopen.c stdio/feof.c stdio/ferror.c stdio/fflush.c stdio/fgetc.c stdio/fgets.c stdio/fileno.c stdio/fopen.c stdio/fprintf.c stdio/fputc.c stdio/fputs.c stdio/fread.c stdio/freopen.c stdio/fscanf.c stdio/fseek.c stdio/ftell.c stdio/fwrite.c stdio/getc.c stdio/getchar.c stdio/perror.c stdio/printf.c stdio/putc.c stdio/putchar.c stdio/remove.c stdio/snprintf.c stdio/sprintf.c stdio/sscanf.c stdio/ungetc.c stdio/vfprintf.c stdio/vfscanf.c stdio/vprintf.c stdio/vsnprintf.c stdio/vsprintf.c stdio/vsscanf.c stdlib/abort.c stdlib/abs.c stdlib/alloca.c stdlib/atexit.c stdlib/atof.c stdlib/atoi.c stdlib/atol.c stdlib/calloc.c stdlib/__exit.c stdlib/exit.c stdlib/free.c stdlib/mbstowcs.c stdlib/puts.c stdlib/qsort.c stdlib/realloc.c stdlib/strtod.c stdlib/strtof.c stdlib/strtol.c stdlib/strtold.c stdlib/strtoll.c stdlib/strtoul.c stdlib/strtoull.c string/bcmp.c string/bcopy.c string/bzero.c string/index.c string/memchr.c string/memcmp.c string/memcpy.c string/memmem.c string/memmove.c string/memset.c string/rindex.c string/strcat.c string/strchr.c string/strcmp.c string/strcpy.c string/strcspn.c string/strdup.c string/strerror.c string/strlen.c string/strlwr.c string/strncat.c string/strncmp.c string/strncpy.c string/strpbrk.c string/strrchr.c string/strspn.c string/strstr.c string/strupr.c stub/atan2.c stub/bsearch.c stub/chown.c stub/__cleanup.c stub/cos.c stub/ctime.c stub/exp.c stub/fpurge.c stub/freadahead.c stub/frexp.c stub/getgrgid.c stub/getgrnam.c stub/getlogin.c stub/getpgid.c stub/getpgrp.c stub/getpwnam.c stub/getpwuid.c stub/gmtime.c stub/ldexp.c stub/localtime.c stub/log.c stub/mktime.c stub/modf.c stub/mprotect.c stub/pclose.c stub/popen.c stub/pow.c stub/rand.c stub/rewind.c stub/setbuf.c stub/setgrent.c stub/setlocale.c stub/setvbuf.c stub/sigaction.c stub/sigaddset.c stub/sigblock.c stub/sigdelset.c stub/sigemptyset.c stub/sigsetmask.c stub/sin.c stub/sys_siglist.c stub/system.c stub/sqrt.c stub/strftime.c stub/times.c stub/ttyname.c stub/umask.c stub/utime.c x86-mes-gcc/setjmp.c
cd ..
# Recompile libc: crt{1,n,i}, libtcc.a, libc.a
tcc -c -D HAVE_CONFIG_H=1 -I include -I include/linux/x86 -o ${LIBDIR}/crt1.o lib/linux/x86-mes-gcc/crt1.c
tcc -c -D HAVE_CONFIG_H=1 -I include -I include/linux/x86 -o ${LIBDIR}/crtn.o lib/linux/x86-mes-gcc/crtn.c
tcc -c -D HAVE_CONFIG_H=1 -I include -I include/linux/x86 -o ${LIBDIR}/crti.o lib/linux/x86-mes-gcc/crti.c
tcc -c -D HAVE_CONFIG_H=1 -D HAVE_LONG_LONG_STUB=1 -I include -I include/linux/x86 lib/libtcc1.c
tcc -c -D TCC_TARGET_I386=1 ../${pkg}/lib/libtcc1.c
tcc -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o
tcc -c -D HAVE_CONFIG_H=1 -I include -I include/linux/x86 -o unified-libc.o unified-libc.c
tcc -ar cr ${LIBDIR}/libc.a unified-libc.o
cd ../..
# Test
tcc -version
# Checksums
if match x${UPDATE_CHECKSUMS} xTrue; then
sha256sum -o ${pkg}.checksums \
/usr/bin/tcc
cp ${pkg}.checksums ${SRCDIR}
else
sha256sum -c ${pkg}.checksums
fi

39
steps/tcc-0.9.27/pass2.sh Executable file
View file

@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: 2021-2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2022-23 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
default
touch config.h
}
src_compile() {
# We have to compile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting when built with mes
tcc-0.9.26 \
-v \
-static \
-o tcc \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\""${LIBDIR}/tcc"\" \
-D CONFIG_TCC_CRTPREFIX=\""${LIBDIR}"\" \
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
-D CONFIG_TCC_LIBPATHS=\""${LIBDIR}:${LIBDIR}/tcc"\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\""${PREFIX}/include/mes"\" \
-D TCC_LIBGCC=\""${LIBDIR}/libc.a"\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
tcc.c
# libtcc1.a
tcc-0.9.26 -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
tcc-0.9.26 -ar cr libtcc1.a libtcc1.o
}
src_install() {
install -D libtcc1.a "${DESTDIR}${LIBDIR}/tcc/libtcc1.a"
install -D tcc "${DESTDIR}${PREFIX}/bin/tcc"
}

47
steps/tcc-0.9.27/pass3.sh Executable file
View file

@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: 2021-2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2022-23 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
default
touch config.h
}
src_compile() {
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
# but when linked with musl it is.
ln -sf "${PREFIX}/lib/mes/tcc/libtcc1.a" ./libtcc1.a
for TCC in tcc-0.9.26 ./tcc-musl; do
"${TCC}" \
-v \
-static \
-o tcc-musl \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\""${LIBDIR}/tcc"\" \
-D CONFIG_TCC_CRTPREFIX=\""${LIBDIR}"\" \
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
-D CONFIG_TCC_LIBPATHS=\""${LIBDIR}:${LIBDIR}/tcc"\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\""${PREFIX}/include"\" \
-D TCC_LIBGCC=\""${LIBDIR}/libc.a"\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-B . \
tcc.c
# libtcc1.a
rm -f libtcc1.a
${TCC} -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
${TCC} -ar cr libtcc1.a libtcc1.o
done
}
src_install() {
install -D tcc-musl "${DESTDIR}${PREFIX}/bin/tcc-musl"
ln -s tcc-musl "${DESTDIR}${PREFIX}/bin/tcc"
install -D libtcc1.a "${DESTDIR}${LIBDIR}/tcc/libtcc1.a"
}

38
steps/tcc-0.9.27/pass4.sh Executable file
View file

@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2021-2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021-23 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
default
touch config.h
}
src_compile() {
tcc-musl \
-v \
-static \
-o tcc-musl \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\""${LIBDIR}/tcc"\" \
-D CONFIG_TCC_CRTPREFIX=\""${LIBDIR}"\" \
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
-D CONFIG_TCC_LIBPATHS=\""${LIBDIR}:${LIBDIR}/tcc"\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\""${PREFIX}/include"\" \
-D TCC_LIBGCC=\""${LIBDIR}/libc.a"\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
tcc.c
# libtcc1.a
tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
tcc-musl -ar cr libtcc1.a libtcc1.o
}
src_install() {
install -D tcc-musl "${DESTDIR}${PREFIX}/bin/tcc-musl"
install -D -m 644 libtcc1.a "${DESTDIR}${LIBDIR}/libtcc1.a"
}

39
steps/tcc-0.9.27/pass5.sh Executable file
View file

@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: 2021-2022 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021-23 fosslinux <fosslinux@aussies.space>
#
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
default
touch config.h
}
src_compile() {
tcc-musl \
-v \
-static \
-o tcc-musl \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\""${LIBDIR}/tcc"\" \
-D CONFIG_TCC_CRTPREFIX=\""${LIBDIR}"\" \
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
-D CONFIG_TCC_LIBPATHS=\""${LIBDIR}:${LIBDIR}/tcc"\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\""${PREFIX}/include"\" \
-D TCC_LIBGCC=\""${LIBDIR}/libc.a"\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-I "${PREFIX}/include" \
tcc.c
# libtcc1.a
tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
ar cr libtcc1.a libtcc1.o
}
src_install() {
install -D tcc-musl "${DESTDIR}${PREFIX}/bin/tcc-musl"
install -D -m 644 libtcc1.a "${DESTDIR}${LIBDIR}/libtcc1.a"
}

View file

@ -0,0 +1 @@
../patches/ignore-static-inside-array.patch

View file

@ -0,0 +1 @@
../patches/static-link.patch

View file

@ -0,0 +1,19 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: LGPL-2.0-or-later
Ignore duplicate symbols. Due to poor support for weak symbols in tcc-ar
we had to patch musl to replace weak symbols with strong symbols
--- tccelf.c 2021-02-02 17:41:08.662247892 +0000
+++ tccelf.c 2021-02-02 23:21:49.652080201 +0000
@@ -552,8 +552,9 @@
#if 0
printf("new_bind=%x new_shndx=%x new_vis=%x old_bind=%x old_shndx=%x old_vis=%x\n",
sym_bind, shndx, new_vis, esym_bind, esym->st_shndx, esym_vis);
-#endif
tcc_error_noabort("'%s' defined twice", name);
+#endif
+ goto do_patch;
}
} else {
do_patch:

View file

@ -0,0 +1,59 @@
SPDX-FileCopyrightText: 2018 Petr Skocik <pskocik@gmail.com>
SPDX-License-Identifier: LGPL-2.0-or-later
From ef668aae1ee2b8bc904c50a13bf58df613b2f0b0 Mon Sep 17 00:00:00 2001
From: Petr Skocik <pskocik@gmail.com>
Date: Fri, 23 Mar 2018 13:19:58 +0100
Subject: [PATCH 1/1] Don't fail on const/restrict/static/* inside []
This patch makes tcc ignore them.
Normally (as per the C standard), They should
be only applicable inside parameter arrays
and affect (const/restrict) the pointer the
array gets converted to.
[matz: fix formatting, add volatile handling, add testcase,
add comment about above deficiency]
---
tccgen.c | 19 +++++++++++++++++--
tests/tests2/100_c99array-decls.c | 34 ++++++++++++++++++++++++++++++++++
tests/tests2/100_c99array-decls.expect | 0
3 files changed, 51 insertions(+), 2 deletions(-)
create mode 100644 tests/tests2/100_c99array-decls.c
create mode 100644 tests/tests2/100_c99array-decls.expect
diff --git tccgen.c tccgen.c
index 7ed89ac..6ef40e4 100644
--- tccgen.c
+++ tccgen.c
@@ -4335,8 +4335,23 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
int saved_nocode_wanted = nocode_wanted;
/* array definition */
next();
- if (tok == TOK_RESTRICT1)
- next();
+ while (1) {
+ /* XXX The optional type-quals and static should only be accepted
+ in parameter decls. The '*' as well, and then even only
+ in prototypes (not function defs). */
+ switch (tok) {
+ case TOK_RESTRICT1: case TOK_RESTRICT2: case TOK_RESTRICT3:
+ case TOK_CONST1:
+ case TOK_VOLATILE1:
+ case TOK_STATIC:
+ case '*':
+ next();
+ continue;
+ default:
+ break;
+ }
+ break;
+ }
n = -1;
t1 = 0;
if (tok != ']') {
--
2.11.4.GIT

View file

@ -0,0 +1,17 @@
SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
SPDX-License-Identifier: LGPL-2.0-or-later
static linking is the only typing of linking mes libc supports, so default to
it.
--- libtcc.c 2021-01-14 08:25:30.774995301 +1100
+++ libtcc.c 2021-01-14 08:26:37.594417450 +1100
@@ -734,6 +734,7 @@
++nb_states;
s->alacarte_link = 1;
+ s->static_link = 1;
s->nocommon = 1;
s->warn_implicit_function_declaration = 1;
s->ms_extensions = 1;

View file

@ -0,0 +1,7 @@
if ((fh = fopen(argv[i_lib], "wb")) == NULL)
{
fprintf(stderr, "tcc: ar: can't open file %s \n", argv[i_lib]);
goto the_end;
}
// write header

View file

@ -0,0 +1 @@
// write header

View file

@ -0,0 +1,6 @@
static void fill_local_got_entries(TCCState *s1)
{
ElfW_Rel *rel;
if (!s1->got->reloc)
return;
for_each_elem(s1->got->reloc, 0, rel, ElfW_Rel) {

View file

@ -0,0 +1,4 @@
static void fill_local_got_entries(TCCState *s1)
{
ElfW_Rel *rel;
for_each_elem(s1->got->reloc, 0, rel, ElfW_Rel) {

View file

@ -0,0 +1,3 @@
ph->p_paddr = ph->p_vaddr;
if (ph->p_paddr >= 0xC0000000)
ph->p_paddr = ph->p_paddr - 0xC0000000;

View file

@ -0,0 +1 @@
ph->p_paddr = ph->p_vaddr;

View file

@ -0,0 +1,2 @@
if (ret == 1)
return ar_usage(ret);

View file

@ -0,0 +1,8 @@
if (ret == 1)
return ar_usage(ret);
if ((fh = fopen(argv[i_lib], "wb")) == NULL)
{
fprintf(stderr, "tcc: ar: can't open file %s \n", argv[i_lib]);
goto the_end;
}

1
steps/tcc-0.9.27/sources Normal file
View file

@ -0,0 +1 @@
https://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27.tar.bz2 de23af78fca90ce32dff2dd45b3432b2334740bb9bb7b05bf60fdbfc396ceb9c

View file

@ -0,0 +1 @@
428251dc2b2de01b9cfe27b3bfd5c8fdc170e442027361e7070f3bc41841a4b7 /usr/bin/tcc