Skip to content

Commit ea6d1c4

Browse files
Replace mes with pnut-exe seed in tcc-0.9.26/pass1
1 parent abb51ea commit ea6d1c4

File tree

2 files changed

+74
-54
lines changed

2 files changed

+74
-54
lines changed

steps/tcc-0.9.26/pass1.kaem

Lines changed: 74 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ MES=${BINDIR}/mes-m2
1717
TCC_TAR=tcc-0.9.26
1818
TCC_PKG=tcc-0.9.26-1147-gee75a10c
1919

20+
PNUT_TAR=79832069f0d44c20a620a923a15e38a545c5e911
21+
PNUT_PKG=pnut-79832069f0d44c20a620a923a15e38a545c5e911
22+
2023
# Check tarball checksums
21-
checksum-transcriber sources
22-
sha256sum -c sources.SHA256SUM
24+
# checksum-transcriber sources
25+
# sha256sum -c sources.SHA256SUM
2326

2427
# Unpack
2528
mkdir build
@@ -32,13 +35,25 @@ simple-patch ${TCC_PKG}/tcctools.c \
3235
../simple-patches/remove-fileopen.before ../simple-patches/remove-fileopen.after
3336
simple-patch ${TCC_PKG}/tcctools.c \
3437
../simple-patches/addback-fileopen.before ../simple-patches/addback-fileopen.after
38+
# Patches required for pnut to compile tcc
39+
simple-patch ${TCC_PKG}/tccpp.c \
40+
../simple-patches/array_sizeof.before ../simple-patches/array_sizeof.after
41+
simple-patch ${TCC_PKG}/libtcc.c \
42+
../simple-patches/error_set_jmp_enabled.before ../simple-patches/error_set_jmp_enabled.after
43+
simple-patch ${TCC_PKG}/libtcc.c \
44+
../simple-patches/sscanf_TCC_VERSION.before ../simple-patches/sscanf_TCC_VERSION.after
45+
simple-patch ${TCC_PKG}/tcc.h \
46+
../simple-patches/undefine_TCC_IS_NATIVE.before ../simple-patches/undefine_TCC_IS_NATIVE.after
3547

3648
untar --non-strict --file ${MES_PKG}.tar
3749

50+
# For some reason, the .tar.gz from github cannot be unpacked with ungz so it
51+
# must be manually unzipped before build process.
52+
untar --non-strict --file ${DISTFILES}/${PNUT_TAR}.tar
53+
3854
# Create config.h
3955
catm ${MES_PKG}/include/mes/config.h
4056
catm ${TCC_PKG}/config.h
41-
cd ${TCC_PKG}
4257

4358
if match ${ARCH} x86; then
4459
MES_ARCH=x86
@@ -56,85 +71,92 @@ if match ${ARCH} riscv64; then
5671
HAVE_LONG_LONG=1
5772
fi
5873

59-
60-
${MES} --no-auto-compile -e main ${BINDIR}/mescc.scm -- \
61-
-S \
62-
-o tcc.s \
63-
-I ${INCDIR} \
64-
-D BOOTSTRAP=1 \
65-
-D HAVE_LONG_LONG=${HAVE_LONG_LONG} \
66-
-I . \
67-
-D TCC_TARGET_${TCC_TARGET_ARCH}=1 \
68-
-D inline= \
69-
-D CONFIG_TCCDIR=\"${LIBDIR}/tcc\" \
70-
-D CONFIG_SYSROOT=\"/\" \
71-
-D CONFIG_TCC_CRTPREFIX=\"${LIBDIR}\" \
72-
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
73-
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${PREFIX}/include/mes\" \
74-
-D TCC_LIBGCC=\"${LIBDIR}/libc.a\" \
75-
-D CONFIG_TCC_LIBTCC1_MES=0 \
76-
-D CONFIG_TCCBOOT=1 \
77-
-D CONFIG_TCC_STATIC=1 \
78-
-D CONFIG_USE_LIBGCC=1 \
79-
-D TCC_VERSION=\"0.9.26\" \
80-
-D ONE_SOURCE=1 \
81-
tcc.c
82-
${MES} --no-auto-compile -e main ${BINDIR}/mescc.scm -- \
83-
--base-address 0x08048000 \
84-
-o tcc-mes \
85-
-L ${LIBDIR} \
86-
tcc.s \
87-
-l c+tcc
88-
cp tcc-mes ${BINDIR}/
89-
chmod 755 ${BINDIR}/tcc-mes
90-
91-
# test tcc-mes
92-
tcc-mes -version
74+
# Ideally we'd build pnut-exe from pnut-sh.sh or from M2-Planet.
75+
# For now, it's a precompiled seed that lives in the .tar.
76+
cp ${PNUT_PKG}/pnut-exe ${BINDIR}/pnut-exe
77+
chmod 755 ${BINDIR}/pnut-exe
78+
79+
pnut-exe ${TCC_PKG}/tcc.c \
80+
-I ${PNUT_PKG}/portable_libc/include/ \
81+
-D BOOTSTRAP=1 \
82+
-D HAVE_LONG_LONG=0 \
83+
-D TCC_TARGET_${TCC_TARGET_ARCH}=1 \
84+
-D CONFIG_TCCDIR=\"${LIBDIR}/tcc\" \
85+
-D CONFIG_SYSROOT=\"/\" \
86+
-D CONFIG_TCC_CRTPREFIX=\"${LIBDIR}\" \
87+
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
88+
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${PREFIX}/include/mes\" \
89+
-D TCC_LIBGCC=\"${LIBDIR}/libc.a\" \
90+
-D CONFIG_TCC_LIBTCC1_MES=0 \
91+
-D CONFIG_TCCBOOT=1 \
92+
-D CONFIG_TCC_STATIC=1 \
93+
-D CONFIG_USE_LIBGCC=1 \
94+
-D TCC_VERSION=\"0.9.26\" \
95+
-D ONE_SOURCE=1 \
96+
-o tcc-pnut
97+
98+
cp tcc-pnut ${BINDIR}/tcc-pnut
99+
chmod 755 ${BINDIR}/tcc-pnut
100+
101+
# test tcc-pnut
102+
tcc-pnut -version
93103

94104
# Recompile the mes C library
95-
cd ../${MES_PKG}
105+
cd ${MES_PKG}
96106

97107
# Create unified libc file
98108
cd lib
99109
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 linux/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-gcc/_exit.c linux/${MES_ARCH}-mes-gcc/syscall.c linux/${MES_ARCH}-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/pathconf.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/putenv.c stub/rand.c stub/realpath.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-gcc/setjmp.c
100110
cd ..
101111

102112
# crt1.o
103-
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crt1.o lib/linux/${MES_ARCH}-mes-gcc/crt1.c
113+
tcc-pnut -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o ${LIBDIR}/crt1.o lib/linux/${MES_ARCH}-mes-gcc/crt1.c
104114

105115
catm ${LIBDIR}/crtn.o
106116
catm ${LIBDIR}/crti.o
107117
if match ${ARCH} x86; then
108118
# crtn.o
109-
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
119+
tcc-pnut -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
110120

111121
# crti.o
112-
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
122+
tcc-pnut -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
113123
fi
114124

115125
# libc+gcc.a
116-
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o unified-libc.o unified-libc.c
117-
tcc-mes -ar cr ${LIBDIR}/libc.a unified-libc.o
126+
tcc-pnut -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} -o unified-libc.o unified-libc.c
127+
tcc-pnut -ar cr ${LIBDIR}/libc.a unified-libc.o
118128

119129
# libtcc1.a
120130
mkdir ${LIBDIR}/tcc
121-
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
131+
tcc-pnut -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
122132
if match ${ARCH} riscv64; then
123-
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
124-
tcc-mes -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o lib-arm64.o
133+
tcc-pnut -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
134+
tcc-pnut -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o lib-arm64.o
125135
else
126-
tcc-mes -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o
136+
tcc-pnut -ar cr ${LIBDIR}/tcc/libtcc1.a libtcc1.o
127137
fi
128138

129139
# libgetopt.a
130-
tcc-mes -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} lib/posix/getopt.c
131-
tcc-mes -ar cr ${LIBDIR}/libgetopt.a getopt.o
140+
tcc-pnut -c -D HAVE_CONFIG_H=1 -I include -I include/linux/${MES_ARCH} lib/posix/getopt.c
141+
tcc-pnut -ar cr ${LIBDIR}/libgetopt.a getopt.o
132142

133-
cd ../${TCC_PKG}
143+
cd ..
144+
145+
# Undo the pnut patches
146+
simple-patch ${TCC_PKG}/tcc.h \
147+
../simple-patches/undefine_TCC_IS_NATIVE.after ../simple-patches/undefine_TCC_IS_NATIVE.before
148+
simple-patch ${TCC_PKG}/libtcc.c \
149+
../simple-patches/sscanf_TCC_VERSION.after ../simple-patches/sscanf_TCC_VERSION.before
150+
simple-patch ${TCC_PKG}/libtcc.c \
151+
../simple-patches/error_set_jmp_enabled.after ../simple-patches/error_set_jmp_enabled.before
152+
simple-patch ${TCC_PKG}/tccpp.c \
153+
../simple-patches/array_sizeof.after ../simple-patches/array_sizeof.before
154+
155+
cd ${TCC_PKG}
134156

135157
# boot0 (ref comments here for all boot*)
136158
# compile
137-
tcc-mes \
159+
tcc-pnut \
138160
-g \
139161
-v \
140162
-static \
@@ -310,7 +332,7 @@ cd ../..
310332
# Checksums
311333
if match x${UPDATE_CHECKSUMS} xTrue; then
312334
sha256sum -o ${pkg}.${ARCH}.checksums \
313-
/usr/bin/tcc-mes \
335+
/usr/bin/tcc-pnut \
314336
/usr/bin/tcc-boot0 \
315337
/usr/bin/tcc-boot1 \
316338
/usr/bin/tcc \

steps/tcc-0.9.26/tcc-0.9.26.x86.checksums

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
096aa0aaf3d2d2742c45683edebbe3ed8ba61d587e1c610e04dab06715824e07 /usr/bin/tcc-mes
2-
2f0209ee3bfe4c65b54c72fe7b5a4f9e85562c31b5b202301d07e040d1f34347 /usr/bin/tcc-boot0
31
edc61c506e4e080ace481d0e2e68ce4e184145721d6e67aab5a9711a7a92695b /usr/bin/tcc-boot1
42
2204b4625e068b77aaeffc5f94e0ee12e6826c5f7f0639bb53932e2d625939d9 /usr/bin/tcc
53
bcc6536a4bf27277a2a63430dbf59993dd380ce60ae2feb53dc5ffe5723f7345 /usr/lib/mes/libc.a

0 commit comments

Comments
 (0)