diff --git a/__fixdfdi.c b/__fixdfdi.c new file mode 100644 index 0000000..8ad8777 --- /dev/null +++ b/__fixdfdi.c @@ -0,0 +1,6 @@ +long long __fixdfdi (double a1) +{ + long long ret; int s; + ret = __fixunsdfdi((s = a1 >= 0) ? a1 : -a1); + return s ? ret : -ret; +} diff --git a/boot.sh b/boot.sh index f95210c..1ab4148 100755 --- a/boot.sh +++ b/boot.sh @@ -55,7 +55,7 @@ if [ "$PROGRAM_PREFIX" = "boot0-" ]; then -D TCC_MES_LIBC=1 "} LIBTCC1=-ltcc1 - LIBTCC1= + #LIBTCC1= elif [ "$PROGRAM_PREFIX" = "boot1-" ]; then BOOT_CPPFLAGS=${BOOT_CPPFLAGS-" -D BOOTSTRAP=1 @@ -66,7 +66,7 @@ elif [ "$PROGRAM_PREFIX" = "boot1-" ]; then -D TCC_MES_LIBC=1 "} LIBTCC1=-ltcc1 - LIBTCC1= + #LIBTCC1= elif [ "$PROGRAM_PREFIX" = "boot2-" ]; then BOOT_CPPFLAGS=${BOOT_CPPFLAGS-" -D BOOTSTRAP=1 @@ -78,7 +78,7 @@ elif [ "$PROGRAM_PREFIX" = "boot2-" ]; then -D TCC_MES_LIBC=1 "} LIBTCC1=-ltcc1 - LIBTCC1= + #LIBTCC1= elif [ "$PROGRAM_PREFIX" = "boot3-" ]; then BOOT_CPPFLAGS=${BOOT_CPPFLAGS-" -D BOOTSTRAP=1 @@ -90,7 +90,7 @@ elif [ "$PROGRAM_PREFIX" = "boot3-" ]; then -D TCC_MES_LIBC=1 "} LIBTCC1=-ltcc1 - LIBTCC1= + #LIBTCC1= else BOOT_CPPFLAGS=${BOOT_CPPFLAGS-" -D BOOTSTRAP=1 @@ -102,7 +102,7 @@ else -D TCC_MES_LIBC=1 "} LIBTCC1=-ltcc1 - LIBTCC1= + #LIBTCC1= fi echo $TCC\ diff --git a/build-x86.sh b/build-x86.sh index 4185876..ea84b7e 100755 --- a/build-x86.sh +++ b/build-x86.sh @@ -67,3 +67,5 @@ $CC -g -o i686-unknown-linux-gnu-tcc\ tcc.c\ libtcc1.a\ libc.a + +./i686-unknown-linux-gnu-tcc -c __fixdfdi.c diff --git a/build.sh b/build.sh index c64656b..5169497 100755 --- a/build.sh +++ b/build.sh @@ -18,12 +18,12 @@ verbose= if test "$V" = 1; then MESCCFLAGS="$MESCCFLAGS -v" elif test "$V" = 2; then - MESCCFLAGS="$MESCCFLAGS -vv" + MESCCFLAGS="$MESCCFLAGS -v -v" fi unset CPATH C_INCLUDE_PATH LIBRARY_PATH -prefix=${prefix-/usr/local} -mescc=${mescc-$(command -v mescc)} +prefix=${prefix-./usr} +MESCC=${MESCC-$(command -v mescc)} GUIX=${GUIX-$(command -v guix||:)} CC=${mescc-mescc} @@ -47,7 +47,7 @@ export interpreter mkdir -p $prefix/lib if test "$V" = 2; then - sh $mescc --help + sh $MESCC --help fi if [ -n "$ONE_SOURCE" ]; then @@ -86,6 +86,7 @@ $MESCC\ $files\ -l c+tcc +host=x86-linux host=${host-$($CC -dumpmachine 2>/dev/null)} if test -z "$host$host_type"; then mes_cpu=${arch-$(get_machine || uname -m)} @@ -125,44 +126,47 @@ REBUILD_LIBC=${REBUILD_LIBC-t} if [ -n "$REBUILD_LIBC" ]; then for i in 1 i n; do rm -f crt$i.o; - cp -f $MES_PREFIX/lib/crt$i.c . - ##cp -f $MES_PREFIX/gcc-lib/x86-mes/crt$i.c . + ##cp -f $MES_PREFIX/lib/crt$i.c . + cp -f $MES_PREFIX/gcc-lib/x86-mes/crt$i.c . $CC $CPPFLAGS $CFLAGS -static -nostdlib -nostdinc -c crt$i.c done rm -f libc.a - cp -f ${MES_PREFIX}/lib/libc+gnu.c libc.c - ## cp -f ${MES_PREFIX}/gcc-lib/x86-mes/libc+gnu.c libc.c + ##cp -f ${MES_PREFIX}/lib/libc+gnu.c libc.c + cp -f ${MES_PREFIX}/gcc-lib/x86-mes/libc+gnu.c libc.c $CC -c $CPPFLAGS $CFLAGS libc.c $AR cr libc.a libc.o rm -f libtcc1.a - cp -f ${MES_PREFIX}/lib/libtcc1.c . - ## cp -f ${MES_PREFIX}/gcc-lib/x86-mes/libtcc1.c . + ##cp -f ${MES_PREFIX}/lib/libtcc1.c . + cp -f ${MES_PREFIX}/gcc-lib/x86-mes/libtcc1.c . $CC -c $CPPFLAGS $CFLAGS libtcc1.c $AR cr libtcc1.a libtcc1.o rm -f libgetopt.a - cp -f ${MES_PREFIX}/lib/libgetopt.c . - ## cp -f ${MES_PREFIX}/gcc-lib/x86-mes/libgetopt.c . + ##cp -f ${MES_PREFIX}/lib/libgetopt.c . + cp -f ${MES_PREFIX}/gcc-lib/x86-mes/libgetopt.c . $CC -c $CPPFLAGS $CFLAGS libgetopt.c $AR cr libgetopt.a libgetopt.o else - cp -f $MES_PREFIX/lib/crt1.o . - cp -f $MES_PREFIX/lib/crti.o . - cp -f $MES_PREFIX/lib/crtn.o . - cp -f $MES_PREFIX/lib/libc+gnu.a . - cp -f $MES_PREFIX/lib/libtcc1.a . + # cp -f $MES_PREFIX/lib/crt1.o . + # cp -f $MES_PREFIX/lib/crti.o . + # cp -f $MES_PREFIX/lib/crtn.o . + # cp -f $MES_PREFIX/lib/libc+gnu.a . + # cp -f $MES_PREFIX/lib/libtcc1.a . - ## cp -f $MES_PREFIX/gcc-lib/libc+gnu.a libc.a - ## cp -f $MES_PREFIX/gcc-lib/libtcc1.a . - ## cp -f $MES_PREFIX/gcc-lib/crt1.o . - ## cp -f $MES_PREFIX/gcc-lib/crti.o . - ## cp -f $MES_PREFIX/gcc-lib/crtn.o . + cp -f $MES_PREFIX/gcc-lib/libc+gnu.a libc.a + cp -f $MES_PREFIX/gcc-lib/libtcc1.a . + cp -f $MES_PREFIX/gcc-lib/crt1.o . + cp -f $MES_PREFIX/gcc-lib/crti.o . + cp -f $MES_PREFIX/gcc-lib/crtn.o . fi -sh boot.sh +mkdir -p usr/lib/tcc +cp -f libtcc1.a usr/lib/tcc + +TCC=./mes-tcc sh boot.sh TCC=./boot0-tcc sh boot.sh TCC=./boot1-tcc sh boot.sh TCC=./boot2-tcc sh boot.sh @@ -175,8 +179,8 @@ AR='./tcc -ar' if true; then for i in 1 i n; do rm -f crt$i.o; - cp -f $MES_PREFIX/lib/crt$i.c . - ##cp -f $MES_PREFIX/gcc-lib/x86-mes/crt$i.c . + ##cp -f $MES_PREFIX/lib/crt$i.c . + cp -f $MES_PREFIX/gcc-lib/x86-mes/crt$i.c . $CC $CPPFLAGS $CFLAGS -static -nostdlib -nostdinc -c crt$i.c done @@ -197,4 +201,6 @@ if true; then cp -f libgetopt.a $prefix/lib fi +./tcc -c __fixdfdi.c + echo "build.sh: done" diff --git a/check.sh b/check.sh index 39148cb..ab7d054 100755 --- a/check.sh +++ b/check.sh @@ -5,7 +5,7 @@ MES=${MES-mes} MESCC=${MESCC-mescc} MES_PREFIX=${MES_PREFIX-../mes} -MES_SOURCE=${MES_SOURCE-../mes-source} +MES_SOURCE=${MES_SOURCE-mes-source} tests=" lib/tests/scaffold/t.c diff --git a/doit b/doit index 571b0c0..be1d555 100755 --- a/doit +++ b/doit @@ -15,18 +15,19 @@ export PREFIX export PREPROCESS PREFIX=usr -HEX2=../mescc-tools/bin/hex2 -M1=../mescc-tools/bin/M1 -BLOOD_ELF=../mescc-tools/bin/blood-elf +HEX2=${HEX2-hex2} +M1=${M1-M1} +BLOOD_ELF=${BLOOD_ELF-blood-elf} MES=${MES-../mes/src/mes} MES_ARENA=70000000 MES_MAX_ARENA=70000000 export MES_ARENA MES_MAX_ARENA MES=guile -#MES=${MES-../mes/src/mes.gcc} -#MES=${MES-../mes/src/mes.mlibc-gcc} -MESCC=${MESCC-../mes/pre-inst-env mescc} +MES=${MES-mes-source/bin/mes} +MESCC=${MESCC-mes-source/pre-inst-env mescc} +export MES +export MESCC #GUILE_LOAD_PATH=/home/janneke/src/nyacc/module:$GUILE_LOAD_PATH GUILE_LOAD_PATH=nyacc diff --git a/tcc.h b/tcc.h index 212cd38..779dd34 100644 --- a/tcc.h +++ b/tcc.h @@ -21,6 +21,11 @@ #ifndef _TCC_H #define _TCC_H +#if BOOTSTRAP +typedef long long int64_t; +typedef unsigned long long uint64_t; +#endif + #define _GNU_SOURCE #include "config.h" diff --git a/test.sh b/test.sh index bb68bc8..ced1c7b 100755 --- a/test.sh +++ b/test.sh @@ -2,7 +2,7 @@ set -ex -TCC=${TCC-./mes-tcc} +TCC=${TCC-./tcc} MESCC=${MESCC-mescc} MES_PREFIX=${MES_PREFIX-../mes} MES_PREFIX=${MES_PREFIX-${MESCC%/*}} @@ -35,7 +35,9 @@ if [ -x ./i686-unknown-linux-gnu-tcc ]; then -static\ -o "$b".mes-gcc-out\ -L .\ - "$b".mes-gcc-o &> 1.link + "$b".mes-gcc-o\ + __fixdfdi.o -ltcc1\ + &> 1.link set +e "$b".mes-gcc-out arg1 arg2 arg3 arg4 arg5 > "$b".mes-gcc-stdout m=$? @@ -67,7 +69,9 @@ $TCC\ -I $MES_PREFIX/include\ -I $MES_PREFIX/scaffold/tests\ -I $MES_PREFIX/scaffold/tinycc\ - "$t" &> 2.link + "$t"\ + __fixdfdi.o -ltcc1\ + &> 2.link set +e "$b".mes-out arg1 arg2 arg3 arg4 arg5 > "$b".mes-stdout m=$?