This commit is contained in:
Liam Wilson 2024-03-08 15:55:50 -05:00 committed by GitHub
commit db1b7517d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 249 additions and 12 deletions

View file

@ -59,7 +59,9 @@ if match ${ARCH} riscv64; then
HAVE_LONG_LONG=1
fi
if match x${TCC_BOOTSTRAP_ALT} xTrue; then
else
${MES} --no-auto-compile -e main ${BINDIR}/mescc.scm -- \
-S \
-o tcc.s \
@ -94,6 +96,8 @@ chmod 755 ${BINDIR}/tcc-mes
# test tcc-mes
tcc-mes -version
fi
# Recompile the mes C library
cd ../${MES_PKG}
@ -102,12 +106,19 @@ 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/wait4.c linux/${MES_ARCH}-mes-${MES_LIBC_SUFFIX}/_exit.c linux/${MES_ARCH}-mes-${MES_LIBC_SUFFIX}/syscall.c linux/${MES_ARCH}-mes-${MES_LIBC_SUFFIX}/_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 ${MES_ARCH}-mes-${MES_LIBC_SUFFIX}/setjmp.c
cd ..
if match x${TCC_BOOTSTRAP_ALT} xTrue; then
# Recompile libc: crt{1,n,i}, libtcc.a, libc.a
tcc-boot0 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crt1.o lib/linux/${MES_ARCH}-mes-${MES_LIBC_SUFFIX}/crt1.c
else
# crt1.o
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crt1.o lib/linux/${MES_ARCH}-mes-${MES_LIBC_SUFFIX}/crt1.c
catm ${LIBDIR}/crtn.o
catm ${LIBDIR}/crti.o
if match ${ARCH} x86; then
fi
if match ${ARCH}${TCC_BOOTSTRAP_ALT} x86False; then
# crtn.o
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crtn.o lib/linux/${MES_ARCH}-mes-gcc/crtn.c
@ -115,6 +126,14 @@ if match ${ARCH} x86; then
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crti.o lib/linux/${MES_ARCH}-mes-gcc/crti.c
fi
if match ${ARCH}${TCC_BOOTSTRAP_ALT} x86True; then
tcc-boot0 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crtn.o lib/linux/${MES_ARCH}-mes-gcc/crtn.c
tcc-boot0 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crti.o lib/linux/${MES_ARCH}-mes-gcc/crti.c
fi
if match x${TCC_BOOTSTRAP_ALT} xTrue; then
tcc-boot0 -c -D HAVE_CONFIG_H=1 -D HAVE_LONG_LONG=1 -D HAVE_FLOAT=1 -I include -I include/linux/${MES_ARCH} -o libtcc1.o lib/libtcc1.c
else
# libc+gcc.a
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o unified-libc.o unified-libc.c
tcc-mes -ar cr ${LIBDIR}/libc.a unified-libc.o
@ -122,19 +141,70 @@ tcc-mes -ar cr ${LIBDIR}/libc.a unified-libc.o
# libtcc1.a
mkdir ${LIBDIR}/tcc
tcc-mes -c -D HAVE_CONFIG_H=1 -D HAVE_LONG_LONG=1 -D HAVE_FLOAT=1 -I include -I include/linux/${MES_ARCH} -o libtcc1.o lib/libtcc1.c
fi
if match ${ARCH} riscv64; then
IS_RISCV64=True
tcc-mes -c -D HAVE_CONFIG_H=1 -D HAVE_LONG_LONG=1 -D HAVE_FLOAT=1 -I include -I include/linux/${MES_ARCH} -o lib-arm64.o ../${TCC_PKG}/lib/lib-arm64.c
tcc-mes -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o lib-arm64.o
else
IS_RISCV64=False
fi
if match x${IS_RISCV64}${TCC_BOOTSTRAP_ALT} xFalseFalse; then
tcc-mes -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o
fi
if match x${TCC_BOOTSTRAP_ALT} xTrue; then
tcc-boot0 -c -D__linux__ -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -I /usr/include/mes/ -o unified-libc.o unified-libc.c
else
# libgetopt.a
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} lib/posix/getopt.c
tcc-mes -ar cr ${LIBDIR}/libgetopt.a getopt.o
fi
cd ../${TCC_PKG}
if match x${TCC_BOOTSTRAP_ALT} xTrue; then
mkdir /usr/lib/mes/tcc/
# boot1
tcc-boot0 \
-nostdinc \
-c \
-o tcc-boot1.o \
-D __linux__ \
-D BOOTSTRAP=1 \
-D HAVE_FLOAT=1 \
-D HAVE_BITFIELD=1 \
-D HAVE_LONG_LONG=0 \
-D HAVE_SETJMP=1 \
-I /usr/include/mes/ \
-I . \
-I ${PREFIX}/include \
-D TCC_TARGET_${TCC_TARGET_ARCH}=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 TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCCBOOT=1 \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.26\" \
-D ONE_SOURCE=1 \
tcc.c
tcc-boot0 -static -nostdlib /usr/lib/mes/crt1.o ../mes-0.25/unified-libc.o ../mes-0.25/libtcc1.o tcc-boot1.o -o tcc-boot0-new
#replace tcc-boot0 with full one
cp tcc-boot0-new ${BINDIR}/tcc-boot0
else
# boot0 (ref comments here for all boot*)
# compile
tcc-mes \
@ -167,6 +237,8 @@ tcc-mes \
tcc.c
# Install
cp tcc-boot0 ${BINDIR}/
fi
chmod 755 ${BINDIR}/tcc-boot0
cd ../${MES_PKG}
# Recompile libc: crt{1,n,i}, libtcc.a, libc.a
@ -292,6 +364,56 @@ tcc-boot2 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o unifi
tcc-boot2 -ar cr ${LIBDIR}/libc.a unified-libc.o
cd ../${TCC_PKG}
# rebuild tcc-boot2 with itself
# LJW FIXME find a neater way to repeat this step (maybe a separate kaem script)
tcc-boot2 \
-g \
-v \
-static \
-o tcc-boot2 \
-D BOOTSTRAP=1 \
-D HAVE_BITFIELD=1 \
-D HAVE_FLOAT=1 \
-D HAVE_LONG_LONG=1 \
-D HAVE_SETJMP=1 \
-I . \
-I ${PREFIX}/include/mes \
-D TCC_TARGET_${TCC_TARGET_ARCH}=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 TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCCBOOT=1 \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.26\" \
-D ONE_SOURCE=1 \
-L . \
tcc.c
cp tcc-boot2 ${BINDIR}
chmod 755 ${BINDIR}/tcc-boot2
cd ../${MES_PKG}
tcc-boot2 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crt1.o lib/linux/${MES_ARCH}-mes-${MES_LIBC_SUFFIX}/crt1.c
if match ${ARCH} x86; then
tcc-boot2 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crtn.o lib/linux/${MES_ARCH}-mes-gcc/crtn.c
tcc-boot2 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crti.o lib/linux/${MES_ARCH}-mes-gcc/crti.c
fi
tcc-boot2 -c -D HAVE_CONFIG_H=1 -D HAVE_LONG_LONG=1 -D HAVE_FLOAT=1 -I include -I include/linux/${MES_ARCH} -o libtcc1.o lib/libtcc1.c
if match ${ARCH} riscv64; then
tcc-boot2 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o lib-arm64.o ../${TCC_PKG}/lib/lib-arm64.c
tcc-boot2 -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o lib-arm64.o
else
tcc-boot2 -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o
fi
tcc-boot2 -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o unified-libc.o unified-libc.c
tcc-boot2 -ar cr ${LIBDIR}/libc.a unified-libc.o
cd ../${TCC_PKG}
# Test boot2
tcc-boot2 -version
@ -312,10 +434,8 @@ cd ../..
# Checksums
if match x${UPDATE_CHECKSUMS} xTrue; then
# LJW FIXME is this a bug? should it say pkg and ARCH?
sha256sum -o ${pkg}.checksums \
/usr/bin/tcc-mes \
/usr/bin/tcc-boot0 \
/usr/bin/tcc-boot1 \
/usr/bin/tcc \
/usr/lib/mes/libc.a \
/usr/lib/mes/libgetopt.a \
@ -328,3 +448,18 @@ if match x${UPDATE_CHECKSUMS} xTrue; then
else
sha256sum -c ${pkg}.${ARCH}.checksums
fi
# Check extra hashes when doing mes build
if match x${UPDATE_CHECKSUMS}${TCC_BOOTSTRAP_ALT} xTrueFalse; then
# LJW FIXME is this a bug? should it say pkg and ARCH?
sha256sum -o ${pkg}_mes.checksums \
/usr/bin/tcc-mes \
/usr/bin/tcc-boot0 \
/usr/bin/tcc-boot1
cp ${pkg}_mes.checksums ${SRCDIR}
fi
if match x${UPDATE_CHECKSUMS}${TCC_BOOTSTRAP_ALT} xFalseFalse; then
sha256sum -c ${pkg}_mes.${ARCH}.checksums
fi

View file

@ -1,6 +1,3 @@
22c74eec2ee1694247fae2958979c2326bab41ecbf5ba279b38417f63bf8892d /usr/bin/tcc-mes
4aff7e61488c03322a682a086405831aa4d99681b2761ddc8b0a76888395a11b /usr/bin/tcc-boot0
9973b5e730c0b9d65aa0ad2332a51adbb247546478d2e86697bba6de4f2f03fc /usr/bin/tcc-boot1
5b5b131cc6bb7f62b11bc99092a1e48c2975af00c7d22fb52de5f561dbdc749a /usr/bin/tcc
93fbb5473bfaf2abaf6598a21dd5f0ac3c6237bfa15bc0c85328608233de55bc /usr/lib/mes/libc.a
98e2d2d543a113c82c8de39f32d4d43b1fe7f3159c5956c5e3224e7f4162601f /usr/lib/mes/libgetopt.a

View file

@ -1,6 +1,3 @@
48f0ac2f1fb8002a6a6958557732b83778f744de3e09085987d65c6981a57ab3 /usr/bin/tcc-mes
b758fff28f3d03b057b0414eb92da0c46e22bc8e9da29af33fbe65b01047d25d /usr/bin/tcc-boot0
56e267e3031f548ea155d61a97fc3e6e8fff277159d7ae3273820a8c0f4582a0 /usr/bin/tcc-boot1
3404d1e8f61be09c1caeba03dcf99abae8881a485fe13160e6bb5fe44538d378 /usr/bin/tcc
3bfd10dfe347c4fb40fbf5f2f705cd806c77e0f80cf4ad1ecfd4beddada2937c /usr/lib/mes/libc.a
12c07ae103e7e3b390150a79e5c600d88de14e9bb73a066f6342582729ef5a3f /usr/lib/mes/libgetopt.a

View file

@ -0,0 +1,3 @@
22c74eec2ee1694247fae2958979c2326bab41ecbf5ba279b38417f63bf8892d /usr/bin/tcc-mes
4aff7e61488c03322a682a086405831aa4d99681b2761ddc8b0a76888395a11b /usr/bin/tcc-boot0
9973b5e730c0b9d65aa0ad2332a51adbb247546478d2e86697bba6de4f2f03fc /usr/bin/tcc-boot1

View file

@ -0,0 +1,3 @@
48f0ac2f1fb8002a6a6958557732b83778f744de3e09085987d65c6981a57ab3 /usr/bin/tcc-mes
b758fff28f3d03b057b0414eb92da0c46e22bc8e9da29af33fbe65b01047d25d /usr/bin/tcc-boot0
56e267e3031f548ea155d61a97fc3e6e8fff277159d7ae3273820a8c0f4582a0 /usr/bin/tcc-boot1