build: Use arch-dir.

* lib/x86-mes: Move from stage0.
* build-aux/build-cc.sh: Create libraries in lib/gcc.  Update users.
* build-aux/build-mes.sh: Create libraries in lib/x86-mes.  Update users.
* build-aux/build-mes-gcc.sh: Rename from build-mlibc.sh.  Create
  libraries in lib/x86-mes-gcc.  Update callers.
* build-aux/cc-mes-gcc.sh: Rename from cc-mlibc.sh.  Update callers.
This commit is contained in:
Jan Nieuwenhuizen 2018-05-29 20:07:46 +02:00
parent 9f90960392
commit 272b522962
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
37 changed files with 233 additions and 363 deletions

34
.gitignore vendored
View file

@ -1,35 +1,32 @@
*-
*.blood-elf-M1
*.blood-elf-hex2
*.go
*~
.#*
*.0-M1
*.0-guile
*.0-hex2
*.E
*.S
*.o
*.blood-elf
*.blood-elf-M1
*.blood-elf-hex2
*.gcc
*.gcc-o
*.gcc-out
*.go
*.guile
*.log
*.gcc-o
*.mes-gcc
*.mes-gcc-o
*.mes-gcc-out
*.mes-gcc-out
*.mes-gcc-stdout
*.mes-o
*.mes-out
*.mes-stdout
*.mini-M1
*.mini-guile
*.mini-hex2
*.mlibc-gcc
*.mlibc-o
*.mlibc-out
*.mlibc-stdout
*.o
*.seed-out
*.stderr
*.stdout
*.tcc-guile
!/stage0/*
!/stage0/*.c
/stage0/exit-42.*
/src/*.h
/src/*.i
@ -39,11 +36,6 @@
/.store
/.tarball-version
/ChangeLog
/a.out
*.gcc-out
*.mes-out
*.mlibc-out
*.seed-out
#keep this: bootstrap
#/mes.mes

View file

@ -14,8 +14,8 @@ all:
cc:
build-aux/build-cc.sh
mlibc:
build-aux/build-mlibc.sh
mes-gcc:
build-aux/build-mes-gcc.sh
mes:
build-aux/build-mes.sh
@ -43,7 +43,7 @@ seed: all-go
MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
cd $(MES_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
MES=$(GUILE) GUILE=$(GUILE) SEED=1 build-aux/build-mes.sh
build-aux/build-mlibc.sh
build-aux/build-mes-gcc.sh
cd $(TINYCC_SEED) && MES_PREFIX=$(PWD) ./refresh.sh
define HELP_TOP
@ -53,7 +53,7 @@ Targets:
all update everything
all-go update .go files
cc update src/mes.gcc-out
mlibc update src/mes.mlibc-out
mes-gcc update src/mes.mes-gcc-out
mes update src/mes
check run unit tests
clean run git clean -dfx

View file

@ -50,4 +50,5 @@ build-aux/mes-snarf.scm src/posix.c
build-aux/mes-snarf.scm src/reader.c
build-aux/mes-snarf.scm src/vector.c
ARCHDIR=1 NOLINK=1 sh build-aux/cc.sh lib/libmes
sh build-aux/cc.sh src/mes

View file

@ -62,17 +62,17 @@ C32FLAGS=${C32FLAGS-"
-nostdlib
"}
NOLINK=1 sh build-aux/cc-mlibc.sh lib/crt1
NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc-mini-gcc
NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc-gcc
NOLINK=1 sh build-aux/cc-mlibc.sh lib/libc+tcc-gcc
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/crt1
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc-mini
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc+tcc
sh build-aux/cc-mlibc.sh scaffold/main
sh build-aux/cc-mlibc.sh scaffold/hello
sh build-aux/cc-mlibc.sh scaffold/argv
sh build-aux/cc-mlibc.sh scaffold/malloc
sh build-aux/cc-mlibc.sh scaffold/micro-mes
sh build-aux/cc-mlibc.sh scaffold/tiny-mes
sh build-aux/cc-mlibc.sh scaffold/mini-mes
sh build-aux/cc-mes-gcc.sh scaffold/main
sh build-aux/cc-mes-gcc.sh scaffold/hello
sh build-aux/cc-mes-gcc.sh scaffold/argv
sh build-aux/cc-mes-gcc.sh scaffold/malloc
sh build-aux/cc-mes-gcc.sh scaffold/micro-mes
sh build-aux/cc-mes-gcc.sh scaffold/tiny-mes
sh build-aux/cc-mes-gcc.sh scaffold/mini-mes
sh build-aux/cc-mlibc.sh src/mes
sh build-aux/cc-mes-gcc.sh src/mes

View file

@ -55,24 +55,24 @@ HEX2FLAGS=${HEX2FLAGS-"
if [ -d "$MES_SEED" ]; then
$M1\
$M1FLAGS\
-f stage0/x86.M1\
-f $MES_SEED/crt1.M1\
-o lib/crt1.o
-f lib/x86-mes/x86.M1\
-f $MES_SEED/x86-mes/crt1.S\
-o lib/x86-mes/crt1.o
$M1\
$M1FLAGS\
-f stage0/x86.M1\
-f $MES_SEED/libc-mes.M1\
-o lib/libc-mes.o
-f lib/x86-mes/x86.M1\
-f $MES_SEED/x86-mes/libc.S\
-o lib/x86-mes/libc.o
$M1\
--LittleEndian\
--Architecture=1\
-f stage0/x86.M1\
-f $MES_SEED/mes.M1\
-f lib/x86-mes/x86.M1\
-f $MES_SEED/x86-mes/mes.S\
-o src/mes.o
$BLOOD_ELF\
-f stage0/x86.M1\
-f $MES_SEED/mes.M1\
-f $MES_SEED/libc-mes.M1\
-f lib/x86-mes/x86.M1\
-f $MES_SEED/x86-mes/mes.S\
-f $MES_SEED/x86-mes/libc.S\
-o src/mes.S.blood-elf
$M1\
--LittleEndian\
@ -81,9 +81,9 @@ if [ -d "$MES_SEED" ]; then
-o src/mes.o.blood-elf
$HEX2\
$HEX2FLAGS\
-f stage0/elf32-header.hex2\
-f lib/crt1.o\
-f lib/libc-mes.o\
-f lib/x86-mes/elf32-header.hex2\
-f lib/x86-mes/crt1.o\
-f lib/x86-mes/libc.o\
-f src/mes.o\
-f src/mes.o.blood-elf\
--exec_enable\
@ -91,25 +91,20 @@ if [ -d "$MES_SEED" ]; then
cp src/mes.seed-out src/mes
$M1\
$M1FLAGS\
-f stage0/x86.M1\
-f $MES_SEED/libc+tcc-mes.M1\
-o lib/libc+tcc-mes.o
-f lib/x86-mes/x86.M1\
-f $MES_SEED/x86-mes/libc+tcc.S\
-o lib/x86-mes/libc+tcc.o
fi
PREPROCESS=1
NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini-mes
NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mes
NOLINK=1 sh build-aux/cc-mes.sh lib/libc+tcc-mes
cp lib/crt1.mes-o lib/crt1.o
cp lib/libc-mini-mes.mes-o lib/libc-mini-mes.o
cp lib/libc-mes.mes-o lib/libc-mes.o
cp lib/libc+tcc-mes.mes-o lib/libc+tcc-mes.o
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc+tcc
[ -n "$SEED" ] && exit 0
MES_ARENA=${MES_ARENA-30000000}
MES_ARENA=${MES_ARENA-10000000}
sh build-aux/mes-snarf.scm --mes src/gc.c
sh build-aux/mes-snarf.scm --mes src/lib.c
sh build-aux/mes-snarf.scm --mes src/math.c

View file

@ -43,23 +43,35 @@ C32FLAGS=${C32FLAGS-"
-nostdinc
-nostdlib
"}
LIBC=${LIBC-lib/libc}
LIBC=${LIBC-c}
if [ -n "$LIBC" ]; then
CC32LIBS="lib/x86-mes-gcc/lib$LIBC.o"
fi
c=$1
if [ -z "$ARCHDIR" ]; then
o="$c"
p="mes-gcc-"
else
b=${c##*/}
d=${c%/*}
o="$d/x86-mes-gcc/$b"
mkdir -p $d/x86-mes-gcc
fi
$CC32\
-c\
$CPPFLAGS\
$C32FLAGS\
-o "$c".mlibc-o\
-o "$o".${p}o\
"$c".c
if [ -z "$NOLINK" ]; then
$CC32\
$C32FLAGS\
-o "$c".mlibc-out\
lib/crt1.mlibc-o\
"$c".mlibc-o\
$LIBC-gcc.mlibc-o\
-o "$o".${p}out\
lib/x86-mes-gcc/crt1.o\
"$o".${p}o\
$CC32LIBS
fi

View file

@ -52,21 +52,31 @@ c=$1
set -e
if [ -z "$ARCHDIR" ]; then
o="$c"
p="mes-"
else
b=${c##*/}
d=${c%/*}
o="$d/x86-mes/$b"
mkdir -p $d/x86-mes
fi
if [ -n "$PREPROCESS" ]; then
sh $MESCC $MESCCFLAGS $CPPFLAGS -E "$c".c
sh $MESCC $MESCCFLAGS -S "$c".E
sh $MESCC $MESCCFLAGS -c -o "$c".mes-o "$c".S
sh $MESCC $MESCCFLAGS $CPPFLAGS -E -o "$o.E" "$c".c
sh $MESCC $MESCCFLAGS -S "$o".E
sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
if [ -z "$NOLINK" ]; then
sh $MESCC $MESCCFLAGS -o "$c".mes-out "$c".mes-o $MESCCLIBS
sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
fi
elif [ -n "$COMPILE" ]; then
sh $MESCC $MESCCFLAGS $CPPFLAGS -S "$c".c
sh $MESCC $MESCCFLAGS -c -o "$c".mes-o "$c".S
sh $MESCC $MESCCFLAGS $CPPFLAGS -S -o "$o.S" "$c".c
sh $MESCC $MESCCFLAGS -c -o "$o".${p}o "$o".S
if [ -z "$NOLINK" ]; then
sh $MESCC $MESCCFLAGS -o "$c".mes-out "$c".mes-o $MESCCLIBS
sh $MESCC $MESCCFLAGS -o "$o".${p}out "$o".${p}o $MESCCLIBS
fi
elif [ -z "$NOLINK" ]; then
sh $MESCC $MESCCFLAGS $CPPFLAGS -o "$c".mes-out "$c".c $MESCCLIBS
sh $MESCC $MESCCFLAGS $CPPFLAGS -o "$o".${p}out "$c".c $MESCCLIBS
else
sh $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$c".mes-out "$c".c
sh $MESCC $MESCCFLAGS $CPPFLAGS -c -o "$o".${p}out "$c".c
fi

View file

@ -41,18 +41,28 @@ CFLAGS=${CFLAGS-"
c=$1
if [ -z "$ARCHDIR" ]; then
o="$c"
p="gcc-"
else
b=${c##*/}
d=${c%/*}
o="$d/gcc/$b"
mkdir -p $d/gcc
fi
$CC\
-c\
$CPPFLAGS\
$CFLAGS\
-D POSIX=1\
-o "$c".gcc-o\
-o "$o".${p}o\
"$c".c
if [ -z "$NOLINK" ]; then
$CC\
$CFLAGS\
-o "$c".gcc-out\
"$c".gcc-o\
lib/libc-gcc.gcc-o
-o "$o".${p}out\
"$o".${p}o\
lib/gcc/libmes.o
fi

View file

@ -26,7 +26,7 @@ export BLOOD_ELF GUILE HEX2 M1 MES MESCC
export M1FLAGS HEX2FLAGS PREPROCESS
export MES_ARENA MES_PREFIX MES_SEED
export BUILD_DEBUG
export CC32LIBS MESCCLIBS
export LIBC CC32LIBS MESCCLIBS
MES=${MES-src/mes}
MESCC=${MESCC-scripts/mescc}
@ -144,17 +144,15 @@ expect=$(echo $broken | wc -w)
pass=0
fail=0
total=0
MESCCLIBS=
LIBC=libc/libc
for t in $tests; do
if [ -z "${t/[012][0-9]-*/}" ]; then
LIBC="lib/libc-mini"
LIBC=c-mini
MESCCLIBS="-l c-mini"
elif [ -z "${t/8[0-9]-*/}" ]; then
LIBC="lib/libc+tcc"
LIBC=c+tcc
MESCCLIBS="-l c+tcc"
else
LIBC=libc/libc
LIBC=c
MESCCLIBS=
fi
sh build-aux/test.sh "scaffold/tests/$t" &> scaffold/tests/"$t".log
@ -251,6 +249,7 @@ broken="$broken
42_function_pointer
46_grep
49_bracket_evaluation
55_lshift_type
"
#22_floating_point ; float

View file

@ -34,21 +34,21 @@ shift
set -e
rm -f "$t".mlibc-out
rm -f "$t".mes-gcc-out
if [ -n "$CC32" ]; then
sh build-aux/cc-mlibc.sh "$t"
sh build-aux/cc-mes-gcc.sh "$t"
r=0
[ -f "$t".exit ] && r=$(cat "$t".exit)
set +e
"$t".mlibc-out > "$t".mlibc-stdout
"$t".mes-gcc-out > "$t".mes-gcc-stdout
m=$?
cat "$t".mlibc-stdout
cat "$t".mes-gcc-stdout
set -e
[ $m = $r ]
if [ -f "$t".expect ]; then
$DIFF -ub "$t".expect "$t".mlibc-stdout;
$DIFF -ub "$t".expect "$t".mes-gcc-stdout;
fi
fi

View file

@ -34,7 +34,7 @@ CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
MESCC=${MESCC-$(command -v mescc)}
MES_SEED=${MES_SEED-../mes-seed}
GUILE=${GUILE-$(command -v guile)}
MES_ARENA=${MES_ARENA-300000000}
MES_ARENA=${MES_ARENA-100000000}
MES_DEBUG=${MES_DEBUG-1}
PREFIX=${PREFIX-/usr/local}
@ -86,8 +86,8 @@ if [ -n "$CC" ]; then
fi
if [ -n "$CC32" ]; then
sh build-aux/build-mlibc.sh
cp src/mes.mlibc-out src/mes
sh build-aux/build-mes-gcc.sh
cp src/mes.mes-gcc-out src/mes
fi
sh build-aux/build-mes.sh

View file

@ -25,7 +25,7 @@ export BUILD_DEBUG
CC32=${CC32-$(command -v i686-unknown-linux-gnu-gcc)}
GUILE=${GUILE-guile}
MES=${MES-src/mes}
MES_ARENA=${MES_ARENA-300000000}
MES_ARENA=${MES_ARENA-100000000}
PREFIX=
if ! command -v $GUILE > /dev/null; then

View file

@ -18,6 +18,8 @@
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libmes.h>
int test ();
int

View file

@ -17,7 +17,7 @@ mkdir -p $MES_PREFIX/lib
cp scripts/mescc $PREFIX/bin/mescc
mkdir -p $MES_PREFIX
tar -cf- doc guile include lib module scaffold stage0 | tar -xf- -C $MES_PREFIX
tar -cf- doc guile include lib module scaffold | tar -xf- -C $MES_PREFIX
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-2.2}
DATADIR=${MODULEDIR-$PREFIX/share/mes}

View file

@ -29,12 +29,6 @@
#include <sys/time.h>
#include <unistd.h>
#include <libc-gcc.c>
#include <linux+tcc-gcc.c>
#include <libc+tcc.c>
#include <getopt.c>
#include <m4.c>
int errno;
void

View file

@ -29,11 +29,6 @@
#include <sys/time.h>
#include <unistd.h>
#include <libc-mes.c>
#include <linux+tcc-mes.c>
#include <libc+tcc.c>
#include <getopt.c>
int errno;
void

View file

@ -30,6 +30,23 @@
#include <sys/time.h>
#include <unistd.h>
#include <libc.c>
#if __MESC__
#include <linux+tcc-mes.c>
#include <libc+tcc-mes.c>
#include <getopt.c>
#else // !__MESC__
#include <linux+tcc-gcc.c>
#include <libc+tcc-gcc.c>
#include <getopt.c>
#include <m4.c>
#endif // !__MESC__
int
dlclose (void *handle)
{
@ -108,7 +125,10 @@ ftell (FILE *stream)
int
fseek (FILE *stream, long offset, int whence)
{
return lseek ((int)stream, offset, whence);
int pos = lseek ((int)stream, offset, whence);
if (pos >= 0)
return 0;
return -1;
}
int

View file

@ -1,36 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
* 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.
*
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libmes.h>
#include <stdio.h>
#include <libmes.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <linux-mini-gcc.c>
#include <libc-mini.c>
#include <linux-gcc.c>
#include <libmes.c>
#include <libc.c>

View file

@ -1,32 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
* 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.
*
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <libmes.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
void _env ();
#include <linux-mini-mes.c>
#include <libc-mini.c>
#include <linux-mes.c>
#include <libmes.c>
#include <libc.c>

View file

@ -1,22 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
* 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.
*
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux-mini-gcc.c>
#include <libc-mini.c>

View file

@ -1,22 +0,0 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
* 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.
*
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux-mini-mes.c>
#include <libc-mini.c>

View file

@ -47,3 +47,13 @@ puts (char const* s)
write (1, s, i);
return 0;
}
#if __MESC__
#include <linux-mini-mes.c>
#else // !__MESC__
#include <linux-mini-gcc.c>
#endif // !__MESC__

View file

@ -22,15 +22,45 @@
#include <sys/ioctl.h>
#include <stdarg.h>
#include <stdlib.h>
#include <libmes.h>
#include <stdio.h>
#include <libmes.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#if __MESC__
#include <linux-mes.c>
#else // !__MESC__
#include <fcntl.h>
#include <assert.h>
#include <linux-gcc.c>
#endif // !__MESC__
#include <libc-mini.c>
#include <libmes.c>
int g_stdin = 0;
void _env ();
int
eputc (int c)
getchar ()
{
return fdputc (c, STDERR);
return fdgetc (g_stdin);
}
int
putchar (int c)
{
write (STDOUT, (char*)&c, 1);
return 0;
}
int
@ -62,10 +92,6 @@ fopen (char const* file_name, char const* mode)
/* Everything else is a read */
fd = open (file_name, 0, 0);
/* Negative numbers are error codes */
if (fd > 0)
return 0;
return (FILE*)fd;
}

View file

@ -19,6 +19,8 @@
*/
#include <libmes.h>
#include <string.h>
#include <unistd.h>
int
isdigit (int c)
@ -169,13 +171,6 @@ fdputc (int c, int fd)
return 0;
}
int
putchar (int c)
{
write (STDOUT, (char*)&c, 1);
return 0;
}
int
fdputs (char const* s, int fd)
{
@ -192,8 +187,19 @@ fdungetc (int c, int fd)
return c;
}
#if POSIX
#define STDERR 2
int
getchar ()
eputs (char const* s)
{
return fdgetc (g_stdin);
int i = strlen (s);
write (STDERR, s, i);
return 0;
}
#endif
int
eputc (int c)
{
return fdputc (c, STDERR);
}

View file

@ -100,8 +100,6 @@
hex2-file-name))
(define (mescc:link options)
(define (library->hex2 o)
(prefix-file options (string-append "lib/lib" o "-mes.o")))
(let* ((files (option-ref options '() '("a.c")))
(source-files (filter (disjoin .c? .E?) files))
(S-files (filter .S? files))
@ -120,9 +118,9 @@
(list (infos->hex2 options hex2-file-name infos)))))
(libraries (filter-map (multi-opt 'library) options))
(libraries (if (pair? libraries) libraries '("c")))
(hex2-libraries (map library->hex2 libraries))
(hex2-libraries (map (cut find-library options ".o" <>) libraries))
(hex2-files (append hex2-files hex2-libraries))
(S-files (append S-files (map (cut replace-suffix <> ".S") hex2-libraries)))
(S-files (append S-files (map (cut find-library options ".S" <>) libraries)))
(debug-info? (option-ref options 'debug-info #f))
(S-files (cons (replace-suffix input-file-name ".S") S-files))
(elf-footer (and debug-info?
@ -157,7 +155,7 @@
(command `(,M1
"--LittleEndian"
"--Architecture=1"
"-f" ,(prefix-file options "stage0/x86.M1")
"-f" ,(arch-find options "x86.M1")
,@(append-map (cut list "-f" <>) M1-files)
"-o" ,hex2-file-name)))
(when verbose?
@ -170,21 +168,20 @@
(elf-file-name (cond ((option-ref options 'output #f))
(else (replace-suffix input-file-name ""))))
(verbose? (option-ref options 'verbose #f))
(elf-footer (or elf-footer (prefix-file options "stage0/elf32-footer-single-main.hex2")))
(elf-footer (or elf-footer (arch-find options "elf32-footer-single-main.hex2")))
(hex2 (or (getenv "HEX2") "hex2"))
(command `(,hex2
"--LittleEndian"
"--Architecture=1"
"--BaseAddress=0x1000000"
"-f" ,(prefix-file options "stage0/elf32-header.hex2")
"-f" ,(prefix-file options "lib/crt1.o")
"-f" ,(arch-find options "elf32-header.hex2")
"-f" ,(arch-find options "crt1.o")
,@(append-map (cut list "-f" <>) hex2-files)
"-f" ,elf-footer
"--exec_enable"
"-o" ,elf-file-name)))
(when verbose?
(stderr "command=~s\n" command)
(format (current-error-port) "~a\n" (string-join command)))
(stderr "~a\n" (string-join command)))
(and (zero? (apply system* command))
elf-file-name)))
@ -196,7 +193,7 @@
(verbose? (option-ref options 'verbose #f))
(blood-elf (or (getenv "BLOOD_ELF") "blood-elf"))
(command `(,blood-elf
"-f" ,(prefix-file options "stage0/x86.M1")
"-f" ,(arch-find options "x86.M1")
,@(append-map (cut list "-f" <>) M1-files)
"-o" ,M1-blood-elf-footer)))
(when verbose?
@ -211,12 +208,27 @@
(base (if (pair? (cdr parts)) (drop-right parts 1))))
(string-append (string-join base ".") suffix)))
(define (find-library options ext o)
(arch-find options (string-append "lib" o ext)))
(define* (arch-find options file-name)
(let* ((path (cons (prefix-file options "lib")
(filter-map (multi-opt 'library-dir) options)))
(arch-file-name (string-append "x86-mes/" file-name))
(verbose? (option-ref options 'verbose #f)))
(when verbose?
(stderr "arch-find=~s\n" arch-file-name)
(stderr " path=~s\n" path)
(stderr " => ~s\n" (search-path path arch-file-name)))
(search-path path arch-file-name)))
(define (prefix-file options file-name)
(let ((prefix (option-ref options 'prefix "")))
(define (prefix-file o)
(if (string-null? prefix) o (string-append prefix "/" o)))
(prefix-file file-name)))
(define (multi-opt option-name) (lambda (o) (and (eq? (car o) option-name) (cdr o))))
(define (.c? o) (or (string-suffix? ".c" o)

View file

@ -57,16 +57,6 @@ add2 (void *ptab)
struct foo *hash_ident[10];
#if !defined (__TINYC__)
void *
memset (void *s, int c, size_t n)
{
char *p = s;
while (n--) *p++ = c;
return s;
}
#endif
int
test ()
{

View file

@ -24,15 +24,6 @@
#include <stdlib.h>
#include <string.h>
#if !defined ( __TINYC__)
unsigned long long
strtoull (char const *p, char **end, int base)
{
*end = p;
return abtoi (end, base);
}
#endif
int
test ()
{

View file

@ -7,8 +7,10 @@ PREFIX=${PREFIX-@PREFIX@}
if [ "$PREFIX" = @PREFIX""@ -o ! -d "$PREFIX" ]
then
MES_PREFIX=${MES_PREFIX-$(cd $(dirname $0)/.. && pwd)}
export MES_PREFIX
else
MES_PREFIX=${MES_PREFIX-$PREFIX/share/mes}
fi
export MES_PREFIX
mes_p=$(command -v mes)
if [ '(' -z "$mes_p" -a -z "$MES" ')' -o "$MES" = "guile" -o "$MES" = "mes.guile" ]; then
GODIR=${GODIR-@GODIR@}
@ -50,7 +52,10 @@ fi
#:use-module (mescc mescc)
#:export (main))
(define %prefix (if (string-prefix? "@PREFIX" "@PREFIX@") (or (getenv "MES_PREFIX") "") "@PREFIX@"))
(define %prefix (or (getenv "MES_PREFIX")
(if (string-prefix? "@PREFIX" "@PREFIX@")
""
"@PREFIX@/share/mes")))
(define %version (if (string-prefix? "@VERSION" "@VERSION@") "git"
"@VERSION@"))
@ -76,6 +81,7 @@ fi
(debug-info (single-char #\g))
(help (single-char #\h))
(include (single-char #\I) (value #t))
(library-dir (single-char #\L) (value #t))
(library (single-char #\l) (value #t))
(preprocess (single-char #\E))
(output (single-char #\o) (value #t))
@ -99,6 +105,7 @@ Usage: mescc [OPTION]... FILE...
-g add debug info [GDB, objdump] TODO: hex2 footer
-h, --help display this help and exit
-I DIR append DIR to include path
-L DIR append DIR to library path
-l LIBNAME link with LIBNAME
-o FILE write output to FILE
-S preprocess and compile only; do not assemble or link

View file

@ -25,12 +25,8 @@
#include <libmes.h>
//#define MES_MINI 1
#if _POSIX_SOURCE
int ARENA_SIZE = 300000000; // 32b: 4GiB, 64b: 8 GiB
#else
int ARENA_SIZE = 200000; // 32b: 2MiB, 64b: 4 MiB
#endif
int MAX_ARENA_SIZE = 300000000;
int MAX_ARENA_SIZE = 100000000;
int JAM_SIZE = 20000;
int GC_SAFETY = 2000;

View file

@ -1,86 +0,0 @@
;;; -*-scheme-*-
;;; Copyright (C) 2016 Jeremiah Orians
;;; Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; This file is part of stage0.
;;;
;;; stage0 is free software: you an 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.
;;;
;;; stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
;;; elf32.hex3: 32 bit elf header in hex3
;; ELF Header
("*elf-header*"
#X7F #x45 #X4C #x46 ; e_ident[EI_MAG0-3] ELF's magic number
#x01 ; e_ident[EI_CLASS] Indicating 32 bit
#x01 ; e_ident[EI_DATA] Indicating little endianness
#x01 ; e_ident[EI_VERSION] Indicating original elf
#x00 ; e_ident[EI_OSABI] Set at 0 because none cares
#x00 ; e_ident[EI_ABIVERSION] See above
#x00 #x00 #x00 #x00 #x00 #x00 #x00 ; e_ident[EI_PAD]
#x02 #x00 ; e_type Indicating Executable
#x03 #x00 ; e_machine Indicating AMD64
#x01 #x00 #x00 #x00 ; e_version Indicating original elf
#x54 #x80 #x04 #x08 ; e_entry Address of the entry point
#x34 #x00 #x00 #x00 ; e_phoff Address of program header table
#x00 #x00 #x00 #x00 ; e_shoff Address of section header table
#x00 #x00 #x00 #x00 ; e_flags
#x34 #x00 ; e_ehsize Indicating our 52 Byte header
#x20 #x00 ; e_phentsize size of a program header table
#x01 #x00 ; e_phnum number of entries in program table
#x00 #x00 ; e_shentsize size of a section header table
#x00 #x00 ; e_shnum number of entries in section table
#x00 #x00 ; e_shstrndx index of the section names
;; Program Header
#x01 #x00 #x00 #x00 ; p_type
#x00 #x00 #x00 #x00 ; p_offset
#x00 #x80 #x04 #x08 ; p_vaddr
#x00 #x80 #x04 #x08 ; p_physaddr
;; FIXME!
;;#x60 #x00 #x00 #x00 ; p_filesz
;;#x60 #x00 #x00 #x00 ; p_memsz
;#x65 #x01 #x00 #x00 ; p_filesz
;#x65 #x01 #x00 #x00 ; p_memsz
#xff #xff #x00 #x00 ; p_filesz
#xff #xff #x00 #x00 ; p_memsz
#x07 #x00 #x00 #x00 ; p_flags
#x01 #x00 #x00 #x00 ; alignment
;; _start
; exit (42) -- works!
;#xbb #x2a #x00 #x00 #x00 ; mov $42,%ebx
;#xb8 #x01 #x00 #x00 #x00 ; mov $0x1,%eax
;#xcd #x80 ; int $0x80
)
("shstr" 0
#\. #\t #\e #\x #\t 0
#\. #\d #\a #\t #\a 0
#\. #\c #\o #\m #\m #\e #\n #\t 0
#\. #\s #\h #\s #\t #\r #\t #\a #\b 0
#\. #\s #\y #\m #\t #\a #\b 0
#\. #\s #\t #\r #\t #\a #\b 0)