build: Resurrect make seed.

* build-aux/GNUmakefile.in (seed): Resurrect.
* build-aux/build-x86_64-mes.sh: Build from seed.
This commit is contained in:
Jan Nieuwenhuizen 2018-09-30 12:15:11 +02:00
parent 7a8a2fc517
commit 5484e0ffdf
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
10 changed files with 96 additions and 185 deletions

2
.gitignore vendored
View file

@ -35,6 +35,8 @@
*.stderr
*.stdout
*.x86-out
*.x86_64-mes-E
*.x86_64-mes-S
*.x86_64-mes-gcc-o
*.x86_64-mes-gcc-out
*.x86_64-mes-gcc-stdout

View file

@ -150,12 +150,18 @@ uninstall:
seed: all-go gcc mes-gcc mes-tcc
cd $(MES_SEED) && git reset --hard HEAD
MES=$(GUILE) GUILE=$(GUILE) SEED=1 ${srcdest}build-aux/build-mes.sh
$(MAKE) MES=guile MES_SEED= SEED=1 mes
cp -v lib/x86-mes/*.S $(MES_SEED)/x86-mes
cp -v src/mes.S $(MES_SEED)/x86-mes
$(MAKE) MES=guile MES_SEED= SEED=1 x86_64-mes
cp -v lib/x86_64-mes/*.S $(MES_SEED)/x86_64-mes
cp -v src/mes.x86_64-mes-S $(MES_SEED)/x86_64-mes/mes.S
MES=$(GUILE) GUILE=$(GUILE) SEED=1 MES_SEED= ${srcdest}build-aux/build-mes.sh
cd $(MES_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
MES=$(GUILE) GUILE=$(GUILE) SEED=1 ${srcdest}build-aux/build-mes.sh
cp lib/x86-mes/elf32-header.hex2\
lib/x86-mes/x86.M1\
lib/x86-mes/libc+tcc.S\
cd $(MES_SEED) && MES_PREFIX=$(PWD) arch=x86_64-mes ./refresh.sh
MES=$(GUILE) GUILE=$(GUILE) SEED=1 ${srcdest}build-aux/build-x86_64-mes.sh
cp lib/x86-mes/libc+tcc.S\
lib/x86-mes/libc.S\
lib/x86-mes/crt1.S\
lib/x86-mes/libgetopt.S\

View file

@ -122,10 +122,6 @@ trace "TEST lib/x86-mes/exit-42.mes-out" echo lib/x86-mes/exit-42.mes-out
{ set +e; lib/x86-mes/exit-42.mes-out; r=$?; set -e; }
[ $r != 42 ] && echo " => $r" && exit 1
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crt0
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crti
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crtn
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc+tcc
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc+gnu

View file

@ -60,50 +60,50 @@ trace "TEST lib/x86_64-mes/exit-42.x86_64-out" echo lib/x86_64-mes/exit-42
{ set +e; lib/x86_64-mes/exit-42.x86_64-out; r=$?; set -e; }
[ $r != 42 ] && echo " => $r" && exit 1
# if [ -d "$MES_SEED" ]; then
# mkdir -p lib/x86_64-mes
# trace "M1 crt1.S" $M1\
# $M1FLAGS\
# -f ${srcdest}lib/x86_64-mes/x86_64.M1\
# -f $MES_SEED/x86_64-mes/crt1.S\
# -o lib/x86_64-mes/crt1.o
# trace "M1 libc.S" $M1\
# $M1FLAGS\
# -f ${srcdest}lib/x86_64-mes/x86_64.M1\
# -f $MES_SEED/x86_64-mes/libc.S\
# -o lib/x86_64-mes/libc.o
# trace "M1 mes.S" $M1\
# --LittleEndian\
# --Architecture 2\
# -f ${srcdest}lib/x86_64-mes/x86_64.M1\
# -f $MES_SEED/x86_64-mes/mes.S\
# -o src/mes.o
# trace "BLOOD_ELF mes.S" $BLOOD_ELF\
# -f ${srcdest}lib/x86_64-mes/x86_64.M1\
# -f $MES_SEED/x86_64-mes/mes.S\
# -f $MES_SEED/x86_64-mes/libc.S\
# -o src/mes.S.blood-elf
# trace "M1 mes.blood-elf" $M1\
# --LittleEndian\
# --Architecture 2\
# -f src/mes.S.blood-elf\
# -o src/mes.o.blood-elf
# trace "HEX2 mes.o" $HEX2\
# $HEX2FLAGS\
# -f ${srcdest}lib/x86_64-mes/elf64-header.hex2\
# -f lib/x86_64-mes/crt1.o\
# -f lib/x86_64-mes/libc.o\
# -f src/mes.o\
# -f src/mes.o.blood-elf\
# --exec_enable\
# -o src/mes.seed-out
# cp src/mes.seed-out src/mes
# trace "M1 libc+tcc.S" $M1\
# $M1FLAGS\
# -f ${srcdest}lib/x86_64-mes/x86_64.M1\
# -f $MES_SEED/x86_64-mes/libc+tcc.S\
# -o lib/x86_64-mes/libc+tcc.o
# fi
if [ -d "$MES_SEED" ]; then
mkdir -p lib/x86_64-mes
trace "M1 crt1.S" $M1\
$M1FLAGS\
-f ${srcdest}lib/x86_64-mes/x86_64.M1\
-f $MES_SEED/x86_64-mes/crt1.S\
-o lib/x86_64-mes/crt1.o
trace "M1 libc.S" $M1\
$M1FLAGS\
-f ${srcdest}lib/x86_64-mes/x86_64.M1\
-f $MES_SEED/x86_64-mes/libc.S\
-o lib/x86_64-mes/libc.o
trace "M1 mes.S" $M1\
--LittleEndian\
--Architecture 2\
-f ${srcdest}lib/x86_64-mes/x86_64.M1\
-f $MES_SEED/x86_64-mes/mes.S\
-o src/mes.o
trace "BLOOD_ELF mes.S" $BLOOD_ELF\
-f ${srcdest}lib/x86_64-mes/x86_64.M1\
-f $MES_SEED/x86_64-mes/mes.S\
-f $MES_SEED/x86_64-mes/libc.S\
-o src/mes.S.blood-elf
trace "M1 mes.blood-elf" $M1\
--LittleEndian\
--Architecture 2\
-f src/mes.S.blood-elf\
-o src/mes.o.blood-elf
trace "HEX2 mes.o" $HEX2\
$HEX2FLAGS\
-f ${srcdest}lib/x86_64-mes/elf64-header.hex2\
-f lib/x86_64-mes/crt1.o\
-f lib/x86_64-mes/libc.o\
-f src/mes.o\
-f src/mes.o.blood-elf\
--exec_enable\
-o src/mes.seed-out
cp src/mes.seed-out src/mes
trace "M1 libc+tcc.S" $M1\
$M1FLAGS\
-f ${srcdest}lib/x86_64-mes/x86_64.M1\
-f $MES_SEED/x86_64-mes/libc+tcc.S\
-o lib/x86_64-mes/libc+tcc.o
fi
PREPROCESS=1
@ -114,39 +114,35 @@ if [ ! -d "$MES_SEED" ] \
MES_ARENA=100000000
fi
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/linux/x86_64-mes/crt1
MES_ARENA=100000000
MES_LIBS='-l none' PREPROCESS= bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/x86_64-mes/exit-42
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/linux/x86_64-mes/crt1
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libc-mini
MES64_LIBS='-l c-mini' PREPROCESS= bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/x86_64-mes/exit-42
trace "TEST lib/x86_64-mes/exit-42.x86_64-mes-out" echo lib/x86_64-mes/exit-42.x86_64-mes-out
{ set +e; lib/x86_64-mes/exit-42.x86_64-mes-out; r=$?; set -e; }
[ $r != 42 ] && echo " => $r" && exit 1
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libc-mini
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libc
# ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/linux/x86_64-mes/crt0
# ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/linux/x86_64-mes/crti
# ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/linux/x86_64-mes/crtn
# ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libc+tcc
# ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libc+gnu
# ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libgetopt
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libc+tcc
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libc+gnu
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-x86_64-mes.sh lib/libgetopt
# [ -n "$SEED" ] && exit 0
[ -n "$SEED" ] && exit 0
# MES_ARENA=${MES_ARENA-100000000}
# trace "MSNARF gc.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/gc.c
# trace "MSNARF lib.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/lib.c
# trace "MSNARF math.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/math.c
# trace "MSNARF mes.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/mes.c
# trace "MSNARF posix.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/posix.c
# trace "MSNARF reader.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/reader.c
# trace "MSNARF vector.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/vector.c
MES_ARENA=${MES_ARENA-100000000}
trace "MSNARF gc.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/gc.c
trace "MSNARF lib.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/lib.c
trace "MSNARF math.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/math.c
trace "MSNARF mes.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/mes.c
trace "MSNARF posix.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/posix.c
trace "MSNARF reader.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/reader.c
trace "MSNARF vector.c" ./pre-inst-env bash ${srcdest}build-aux/mes-snarf.scm --mes src/vector.c
# echo MES_ARENA=$MES_ARENA
# bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/main
echo MES_ARENA=$MES_ARENA
bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/main
MES_LIBS='-l none' bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/main
@ -154,12 +150,11 @@ trace "TEST scaffold/main.x86_64-mes-out" echo scaffold/main.x86_64-mes-ou
{ set +e; scaffold/main.x86_64-mes-out; r=$?; set -e; }
[ $r != 42 ] && echo " => $r" && exit 1
# MES_LIBS='-l mini' bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/hello
# MES_LIBS='-l mini' bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/argv
# bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/malloc
# ##sh ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/micro-mes
# ##sh ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/tiny-mes
# # bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/mini-mes
# bash ${srcdest}build-aux/cc-x86_64-mes.sh src/mes
# cp src/mes.mes-out src/mes
true
MES64_LIBS='-l c-mini' bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/hello
MES64_LIBS='-l c-mini' bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/argv
bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/malloc
##sh ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/micro-mes
##sh ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/tiny-mes
# bash ${srcdest}build-aux/cc-x86_64-mes.sh scaffold/mini-mes
bash ${srcdest}build-aux/cc-x86_64-mes.sh src/mes
cp src/mes.x86_64-mes-out src/mes

View file

@ -48,15 +48,15 @@ fi
mkdir -p $d
if [ -n "$PREPROCESS" ]; then
trace "CPP.mes64 $c.c" ./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES64_CFLAGS -E -o "$o.E" "${srcdest}$c".c
trace "CC.mes64 $c.E" ./pre-inst-env bash $MESCC $MES64_CFLAGS -S "$o".E
trace "AS.mes64 $c.S" ./pre-inst-env bash $MESCC $MES64_CFLAGS -c -o "$o".${p}o "$o".S
trace "CPP.mes64 $c.c" ./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES64_CFLAGS -E -o "$o.${p}E" "${srcdest}$c".c
trace "CC.mes64 $c.E" ./pre-inst-env bash $MESCC $MES64_CFLAGS -S -o "$o".${p}S "$o".${p}E
trace "AS.mes64 $c.S" ./pre-inst-env bash $MESCC $MES64_CFLAGS -c -o "$o".${p}o "$o".${p}S
if [ -z "$NOLINK" ]; then
trace "LD.mes64 $c.o" ./pre-inst-env bash $MESCC $MES64_CFLAGS -o "$o".${p}out "$o".${p}o $MES_LIBS
fi
elif [ -n "$COMPILE" ]; then
trace "CC.mes64 $c.c" trace "MESCC $c.c" ./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES64_CFLAGS -S -o "$o.S" "${srcdest}$c".c
trace "AS.mes64 $c.S" ./pre-inst-env bash $MESCC $MES64_CFLAGS -c -o "$o".${p}o "$o".S
trace "CC.mes64 $c.c" trace "MESCC $c.c" ./pre-inst-env bash $MESCC $MES_CPPFLAGS $MES64_CFLAGS -S -o "$o".${p}S "${srcdest}$c".c
trace "AS.mes64 $c.S" ./pre-inst-env bash $MESCC $MES64_CFLAGS -c -o "$o".${p}o "$o".${p}S
if [ -z "$NOLINK" ]; then
trace "LD.mes64 $c.o" ./pre-inst-env bash $MESCC $MES64_CFLAGS -o "$o".${p}out "$o".${p}o $MES_LIBS
fi

View file

@ -1,57 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
// no clue what crt0.o is and why gcc-2.6.3 needs it
// instead of calling main, it seems to call either _main or ___main,
// let's try _main first
char **environ = 0;
int _main (int argc, char *argv[]);
int
_start ()
{
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !4");
asm ("movzbl_(%eax),%eax");
asm ("add____$i8,%eax !3");
asm ("shl____$i8,%eax !0x02");
asm ("add____%ebp,%eax");
asm ("mov____%eax,0x32 &environ");
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !8");
asm ("push___%eax");
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !4");
asm ("movzbl_(%eax),%eax");
asm ("push___%eax");
_main ();
asm ("mov____%eax,%ebx");
asm ("mov____$i32,%eax %1");
asm ("int____$0x80");
asm ("hlt");
}

View file

@ -1,19 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -1,19 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -180,6 +180,7 @@ DEFINE setg___%dil 400f9fc7
DEFINE setge__%al 0f9dc0
DEFINE setge__%dil 400f9dc7
DEFINE setl___%al 0f9cc0
DEFINE setl___%dil 400f9cc7
DEFINE setle__%al 0f9ec0
DEFINE setle__%dil 400f9ec7
DEFINE setne__%al 0f95c0

View file

@ -286,12 +286,18 @@
(define (.c? o) (or (string-suffix? ".c" o)
(string-suffix? ".M2" o)))
(define (.E? o) (string-suffix? ".E" o))
(define (.E? o) (or (string-suffix? ".E" o)
(string-suffix? ".mes-E" o)
(string-suffix? ".x86-mes-E" o)
(string-suffix? ".x86_64-mes-E" o)))
(define (.S? o) (or (string-suffix? ".S" o)
(string-suffix? ".mes-S" o)
(string-suffix? ".x86-mes-S" o)
(string-suffix? ".x86_64-mes-S" o)
(string-suffix? "S" o)
(string-suffix? ".M1" o)))
(define (.o? o) (or (string-suffix? ".o" o)
(string-suffix? ".mes-o" o)
(string-suffix? "o" o)
(string-suffix? ".x86-mes-o" o)
(string-suffix? ".x86_64-mes-o" o)
(string-suffix? ".hex2" o)))