Skip to content

add alternative tcc bootstrap path #407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 53 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
89a83bc
add tcc_bootstrap_alt-0.1 source and kaem build script
cosinusoidally Jan 10, 2024
b4068aa
temp abort after 0.9.27 build
cosinusoidally Jan 10, 2024
3312625
start adding option to run tcc_bootstrap_alt
cosinusoidally Jan 10, 2024
1f9971d
more TCC_BOOTSTRAP_ALT config
cosinusoidally Jan 10, 2024
fd096b7
test alt bootstrap path via github ci
cosinusoidally Jan 10, 2024
a8df00f
fix kaem name
cosinusoidally Jan 10, 2024
6c6ab74
update pass1.kaem
cosinusoidally Jan 10, 2024
e1738d9
re-enable mes-0.25
cosinusoidally Jan 10, 2024
dc96cc9
skip parts of mes-0.25/pass1.kaem if TCC_BOOTSTRAP_ALT is True
cosinusoidally Jan 10, 2024
37421bd
tweak conditional
cosinusoidally Jan 10, 2024
e22a43a
seems to be some issue with nesting conditionals
cosinusoidally Jan 10, 2024
4d2537c
conditional tweak
cosinusoidally Jan 10, 2024
977290a
start adapting tcc-0.9.26/pass1.kaem to optionally run tcc_bootstrap_alt
cosinusoidally Jan 10, 2024
ddefe9f
more changes
cosinusoidally Jan 10, 2024
a2dd788
update include directory
cosinusoidally Jan 10, 2024
46efeb6
fix env vars
cosinusoidally Jan 10, 2024
a9fb381
try to fix includes
cosinusoidally Jan 10, 2024
2f158fc
more include fixing
cosinusoidally Jan 10, 2024
33be2c0
do not check checksums for tcc-0.9.26 when using tcc_bootstrap_alt
cosinusoidally Jan 10, 2024
64e3659
Revert "temp abort after 0.9.27 build"
cosinusoidally Jan 10, 2024
876e0ed
Revert "Revert "temp abort after 0.9.27 build""
cosinusoidally Jan 10, 2024
a336874
test non-tcc_bootstrap_alt path
cosinusoidally Jan 10, 2024
c16e1fd
Revert "test non-tcc_bootstrap_alt path"
cosinusoidally Jan 11, 2024
4889044
allow run past tcc-0.9.27 to test full run
cosinusoidally Jan 11, 2024
520656e
test mes bootstrap path to make sure it's not broken
cosinusoidally Jan 11, 2024
949d5b8
try checking tcc-0.9.26 checksums even when using the TCC_BOOTSTRAP_A…
cosinusoidally Jan 11, 2024
b19dff9
Revert "test mes bootstrap path to make sure it's not broken"
cosinusoidally Jan 11, 2024
9623db5
add dummy tcc-mes
cosinusoidally Jan 11, 2024
3c840e6
test rebuilding tcc-boot2 with itself
cosinusoidally Jan 12, 2024
e8c0b99
rebuild tcc-boot0 with itself
cosinusoidally Jan 12, 2024
4514358
rebuilt tcc-boot0 again
cosinusoidally Jan 12, 2024
b8d11bf
missing cd
cosinusoidally Jan 12, 2024
d2c5f8b
another missing cd
cosinusoidally Jan 12, 2024
f4eda66
revert tcc-boot0 rebuilds
cosinusoidally Jan 12, 2024
be89270
test mes mode again
cosinusoidally Jan 12, 2024
7ac17b5
Revert "test mes mode again"
cosinusoidally Jan 12, 2024
dcb0134
Merge branch 'master' into tcc_bootstrap_alt-refactor-improve
cosinusoidally Jan 12, 2024
ba4c8b4
start splitting tcc-0.9.26 hashes
cosinusoidally Jan 12, 2024
a87e0b0
dummy tcc-mes file no longer needed
cosinusoidally Jan 12, 2024
f6e4b5b
check sha256sum for tcc_bootstrap_alt-0.1 outpit artifact
cosinusoidally Jan 12, 2024
3880069
document potential bug
cosinusoidally Jan 12, 2024
94877fd
change to correct dir
cosinusoidally Jan 12, 2024
1009ea6
check extra sha sums for tcc-mes
cosinusoidally Jan 13, 2024
8346a2b
split riscv tcc-0.9.26 hashes to match with x86
cosinusoidally Jan 13, 2024
6446c09
add alt_pass1 to ci
cosinusoidally Jan 13, 2024
f67113d
restore other arch support
cosinusoidally Jan 13, 2024
c986229
fix typo
cosinusoidally Jan 13, 2024
9721596
Merge branch 'master' into builder-hex0-issue
cosinusoidally Jan 21, 2024
a411c6e
Merge branch 'master' into builder-hex0-issue
cosinusoidally Jan 24, 2024
c4add47
move to tcc_bootstrap_alt-0.2
cosinusoidally Jan 24, 2024
b851f55
bump 0.2
cosinusoidally Jan 24, 2024
e9dda80
Merge branch 'master' into builder-hex0-issue
cosinusoidally Feb 2, 2024
c766b60
try and fix some UPDATE_CHECKSUMS
cosinusoidally Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/bwrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,52 @@ on:
- master

jobs:
alt_pass1:
name: Alt Run up to Linux build under bubblewrap
runs-on: ubuntu-latest
steps:
- name: Install bubblewrap
run: sudo apt install bubblewrap
- name: Checkout repo
uses: actions/checkout@v3
with:
submodules: recursive
# There is a strange bug(?) in nongnu, when you clone a git repository
# against a commit != HEAD with depth=1, it errors out.
fetch-depth: 0
- name: Query cache for sources
id: cache
uses: actions/cache/restore@v3
with:
path: |
distfiles
key: cache-${{ hashFiles('steps/*/sources') }}
- name: Get sources
if: steps.cache.outputs.cache-hit != 'true'
run: ./download-distfiles.sh
- name: Cache sources
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: |
distfiles
key: cache-${{ hashFiles('steps/*/sources') }}
- name: Run bootstrap
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass1 --tcc_bootstrap_alt
- name: Archive created packages
if: failure() # archive failed builds progress
uses: actions/upload-artifact@v3
with:
name: alt_packages
path: target/external/repo/**
- name: Tar alt_pass1 image
run: tar -cf alt_pass1_image.tar target
- name: Archive alt_pass1_image
uses: actions/upload-artifact@v3
with:
name: internal_alt_pass1_image
path: alt_pass1_image.tar

pass1:
name: Run up to Linux build under bubblewrap
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions rootfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def create_configuration_file(args):
config.write("DISK=sda1\n")
config.write("KERNEL_BOOTSTRAP=False\n")
config.write(f"BUILD_KERNELS={args.update_checksums or args.build_kernels}\n")
config.write(f"TCC_BOOTSTRAP_ALT={args.tcc_bootstrap_alt}\n")

# pylint: disable=too-many-statements,too-many-branches
def main():
Expand Down Expand Up @@ -109,6 +110,9 @@ def main():

parser.add_argument("-b", "--bare-metal", help="Build images for bare metal",
action="store_true")
parser.add_argument("--tcc_bootstrap_alt",
help="Use tcc_bootstrap_alt.",
action="store_true")

args = parser.parse_args()

Expand Down
1 change: 1 addition & 0 deletions steps/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
build: checksum-transcriber-1.0
build: simple-patch-1.0
build: mes-0.25
build: tcc_bootstrap_alt-0.2 ( TCC_BOOTSTRAP_ALT == True )
build: tcc-0.9.26
build: tcc-0.9.27
define: BUILD_FIWIX = ( KERNEL_BOOTSTRAP == True || BUILD_KERNELS == True )
Expand Down
12 changes: 10 additions & 2 deletions steps/mes-0.25/pass1.kaem
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ rm mes/module/mes/psyntax.pp mes/module/mes/psyntax.pp.header
cp mes/module/srfi/srfi-9-struct.mes mes/module/srfi/srfi-9.mes
cp mes/module/srfi/srfi-9/gnu-struct.mes mes/module/srfi/srfi-9/gnu.mes

if match x${TCC_BOOTSTRAP_ALT} xFalse; then
# Build mes-m2
kaem --verbose --strict --file kaem.${MES_ARCH}
cp bin/mes-m2 ${BINDIR}/mes-m2
Expand Down Expand Up @@ -265,10 +266,14 @@ mescc lib/linux/stat.c
catm ${LIBDIR}/${MES_ARCH}-mes/libc+tcc.a ${LIBDIR}/${MES_ARCH}-mes/libc.a islower.o isupper.o tolower.o toupper.o abtod.o dtoab.o search-path.o execvp.o fclose.o fdopen.o ferror.o fflush.o fopen.o fprintf.o fread.o fseek.o ftell.o fwrite.o printf.o remove.o snprintf.o sprintf.o sscanf.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o vsscanf.o abort.o calloc.o qsort.o strtod.o strtof.o strtol.o strtold.o strtoll.o strtoul.o strtoull.o memmem.o strcat.o strchr.o strlwr.o strncpy.o strrchr.o strstr.o strupr.o sigaction.o ldexp.o mprotect.o localtime.o sigemptyset.o setjmp.o close.o rmdir.o stat.o
catm ${LIBDIR}/${MES_ARCH}-mes/libc+tcc.s ${LIBDIR}/${MES_ARCH}-mes/libc.s islower.s isupper.s tolower.s toupper.s abtod.s dtoab.s search-path.s execvp.s fclose.s fdopen.s ferror.s fflush.s fopen.s fprintf.s fread.s fseek.s ftell.s fwrite.s printf.s remove.s snprintf.s sprintf.s sscanf.s vfprintf.s vprintf.s vsnprintf.s vsprintf.s vsscanf.s abort.s calloc.s qsort.s strtod.s strtof.s strtol.s strtold.s strtoll.s strtoul.s strtoull.s memmem.s strcat.s strchr.s strlwr.s strncpy.s strrchr.s strstr.s strupr.s sigaction.s ldexp.s mprotect.s localtime.s sigemptyset.s setjmp.s close.s rmdir.s stat.s

fi

# Make directories
mkdir ${PREFIX}/lib/linux ${INCDIR}/mes ${INCDIR}/sys ${INCDIR}/linux ${INCDIR}/arch
mkdir ${PREFIX}/lib/${MES_ARCH}-mes ${PREFIX}/lib/linux/${MES_ARCH}-mes ${INCDIR}/linux/${MES_ARCH}

if match x${TCC_BOOTSTRAP_ALT} xFalse; then

# Install libraries
cp ${LIBDIR}/${MES_ARCH}-mes/libc.a ${PREFIX}/lib/${MES_ARCH}-mes/
cp ${LIBDIR}/${MES_ARCH}-mes/libc+tcc.a ${PREFIX}/lib/${MES_ARCH}-mes/
Expand All @@ -282,6 +287,8 @@ cp ${LIBDIR}/${MES_ARCH}-mes/crt1.s ${PREFIX}/lib/${MES_ARCH}-mes/
cp ${LIBDIR}/linux/${MES_ARCH}-mes/elf${ARCH_BITS}-footer-single-main.hex2 ${PREFIX}/lib/linux/${MES_ARCH}-mes/
cp ${LIBDIR}/linux/${MES_ARCH}-mes/elf${ARCH_BITS}-header.hex2 ${PREFIX}/lib/linux/${MES_ARCH}-mes/

fi

# Install header files
cp include/alloca.h ${INCDIR}/alloca.h
cp include/argz.h ${INCDIR}/argz.h
Expand Down Expand Up @@ -356,7 +363,7 @@ cp include/sys/wait.h ${INCDIR}/sys/wait.h
cd ../..

# Checksums
if match x${UPDATE_CHECKSUMS} xTrue; then
if match x${UPDATE_CHECKSUMS}${TCC_BOOTSTRAP_ALT} xTrueFalse; then
sha256sum -o ${pkg}.${ARCH}.checksums \
/usr/bin/mes \
/usr/bin/mes-m2 \
Expand All @@ -374,6 +381,7 @@ if match x${UPDATE_CHECKSUMS} xTrue; then
/usr/lib/linux/${MES_ARCH}-mes/elf${ARCH_BITS}-footer-single-main.hex2

cp ${pkg}.${ARCH}.checksums ${SRCDIR}
else
fi
if match x${UPDATE_CHECKSUMS}${TCC_BOOTSTRAP_ALT} xFalseFalse; then
sha256sum -c ${pkg}.${ARCH}.checksums
fi
143 changes: 139 additions & 4 deletions steps/tcc-0.9.26/pass1.kaem
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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 \
Expand Down Expand Up @@ -97,6 +99,8 @@ chmod 755 ${BINDIR}/tcc-mes
# test tcc-mes
tcc-mes -version

fi

# Recompile the mes C library
cd ../${MES_PKG}

Expand All @@ -105,39 +109,105 @@ 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

# crti.o
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

# 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 \
Expand Down Expand Up @@ -170,6 +240,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
Expand Down Expand Up @@ -295,6 +367,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

Expand All @@ -315,10 +437,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 \
Expand All @@ -331,3 +451,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
3 changes: 0 additions & 3 deletions steps/tcc-0.9.26/tcc-0.9.26.riscv64.checksums
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions steps/tcc-0.9.26/tcc-0.9.26.x86.checksums
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions steps/tcc-0.9.26/tcc-0.9.26_mes.riscv64.checksums
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
22c74eec2ee1694247fae2958979c2326bab41ecbf5ba279b38417f63bf8892d /usr/bin/tcc-mes
4aff7e61488c03322a682a086405831aa4d99681b2761ddc8b0a76888395a11b /usr/bin/tcc-boot0
9973b5e730c0b9d65aa0ad2332a51adbb247546478d2e86697bba6de4f2f03fc /usr/bin/tcc-boot1
3 changes: 3 additions & 0 deletions steps/tcc-0.9.26/tcc-0.9.26_mes.x86.checksums
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
48f0ac2f1fb8002a6a6958557732b83778f744de3e09085987d65c6981a57ab3 /usr/bin/tcc-mes
b758fff28f3d03b057b0414eb92da0c46e22bc8e9da29af33fbe65b01047d25d /usr/bin/tcc-boot0
56e267e3031f548ea155d61a97fc3e6e8fff277159d7ae3273820a8c0f4582a0 /usr/bin/tcc-boot1
Loading