Commit Graph

2293 Commits

Author SHA1 Message Date
W. J. van der Laan fce3422465 lib: Add _sys_call_5 for Linux RISC-V64.
* include/linux/syscall.h (_sys_call5): Declare 5-argument syscall needed
for SYS_renameat2, currently only used on RISC-V64.
* lib/linux/riscv64-mes-gcc/syscall.c (__sys_call5, _sys_call5):
Implement it.
2023-02-12 19:42:31 +01:00
W. J. van der Laan 49dbc763da lib: Linux riscv64-mes-gcc support.
* lib/linux/riscv64-mes-gcc/_exit.c,
lib/linux/riscv64-mes-gcc/_write.c,
lib/linux/riscv64-mes-gcc/crt1.c,
lib/linux/riscv64-mes-gcc/syscall-internal.c,
lib/linux/riscv64-mes-gcc/syscall.c: New files to make it possible
to compile mes for riscv64-mes-gcc.
2023-02-12 19:42:31 +01:00
W. J. van der Laan 23679dc023 lib: Base riscv64-mes-gcc support (dummy setjmp).
* lib/riscv64-mes-gcc/setjmp.c: New file.
(setjmp, longjmp): Add dummy implementations. Implementing these for gcc
would be very involved, and does not seem necessary to get mescc to
work.
2023-02-12 19:42:31 +01:00
W. J. van der Laan 70d4724b28 DRAFT lib: Add RISC-V64 Linux syscall numbers header.
XXX TODO: What is the rationale behind usage of xxxAT syscalls?

* include/linux/riscv64/syscall.h: New file: list relevant syscall
number constants.
2023-02-12 19:42:31 +01:00
W. J. van der Laan a65fc1e456 lib: Make Linux scaffold work for RISC-V64.
* lib/linux/riscv64-mes-gcc/exit-42.S,
lib/linux/riscv64-mes-gcc/hello-mes.S,
lib/linux/riscv64-mes/elf64-0exit-42.hex2,
lib/linux/riscv64-mes/elf64-0header.hex2,
lib/linux/riscv64-mes/elf64-0hello-mes.hex2,
lib/linux/riscv64-mes/elf64-body-exit-42.hex2,
lib/linux/riscv64-mes/elf64-body-hello-mes.hex2,
lib/linux/riscv64-mes/elf64-footer-single-main.hex2,
lib/linux/riscv64-mes/elf64-header.hex2: New files.  Makes basic
scaffold pass on RISC-V64.
2023-02-12 19:42:31 +01:00
W. J. van der Laan d19876e0e4 mes: Add RISC-V architecture detection.
* src/mes.c: Add ifdefs to detect when compiled on riscv32 or riscv64
architectures.
2023-02-12 19:42:31 +01:00
W. J. van der Laan 165ce66957 configure: Recognize RISC-V architectures.
* configure (main): Classify "riscv64" as 64 bit, allow "redhat" OS
(somewhat tangential, but important for Fedora RISC-V), allow
"riscv32-linux-mes" and "riscv64-linux-mes" as system.
2023-02-12 19:42:31 +01:00
W. J. van der Laan 4502a86ab0 mescc: Add r0-cmp-r1 instruction.
This instruction is used to compare two registers and set the flags
accordingly. In current architectures this is the same as r0-r1, but for
RISCV it will be different.  RISC-V does not have condition flags so
(until a better solution) we are going to emulate them there.

* module/mescc/armv4/as.scm (armv4:instructions): Add r0-cmp-r1 as alias
of r0-r1.
* module/mescc/i386/as.scm: Same.
* module/mescc/x86_64/as.scm: Same.
* module/mescc/compile.scm (expr->register): Make use of the new
r0-cmp-r1 instruction.
2023-02-12 19:42:31 +01:00
Jan (janneke) Nieuwenhuizen 11bc725590 WIP ARM: Use mes-style crt1.M1. 2023-02-12 19:42:31 +01:00
Jan (janneke) Nieuwenhuizen b619993975 syscall 2023-02-12 19:42:31 +01:00
Jan (janneke) Nieuwenhuizen 3acbc2d68a WIP syscalls...
So..., does RISC-V64 actually have the old interface too?
2023-02-12 19:42:31 +01:00
Jan (janneke) Nieuwenhuizen 5291f5917b squash! DRAFT x86_64: build: Cater for M2-Planet. 2023-02-12 19:42:31 +01:00
Jan (janneke) Nieuwenhuizen b68437b0ce DRAFT x86_64: build: Cater for M2-Planet.
XXX scaffold tests run,
  * MES_DEBUG=3 bin/mes-m2 segfaults in gc_init.

* kaem.run: Define __<cpu>__.
* kaem.x86_64,
lib/linux/x86_64-mes-m2/_exit.c,
lib/linux/x86_64-mes-m2/_write.c,
lib/linux/x86_64-mes-m2/crt1.M1,
lib/linux/x86_64-mes-m2/crt1.c,
lib/linux/x86_64-mes-m2/syscall.c,
lib/m2/x86_64/ELF-x86_64.hex2,
lib/m2/x86_64/x86_64_defs.M1: New files.
* build-aux/build.sh.in: Also allow kaem build for X86_64.
* include/mes/lib-mini.h[__M2__ && __x86_64__](M2_PTR_SIZE): Define as
8.
* include/mes/mes.h[__M2__ && __x86_64__](M2_CELL_SIZE): Define as 24.
* lib/x86_64-mes/x86_64.M1 (add____$i8,%rbp, mov____%rdi,%rbp): New
defines.
2023-02-12 19:42:31 +01:00
Jan (janneke) Nieuwenhuizen 05d1087741 DRAFT lib: stat: Use SYS_stat64 for 32bit platforms.
* include/linux/arm/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/linux/x86/syscall.h (SYS_stat64, SYS_lstat64,
SYS_fstat64)[__SIZEOF_LONG_LONG__ == 8]:
New defines.
(SYS_stat, SYS_lstat, SYS_fstat)[__SIZEOF_LONG_LONG__ == 8]: Redefine them.
* include/sys/stat.h (struct stat): Move definition to...
* include/linux/arm/kernel-stat.h,
include/linux/m2/kernel-stat.h,
include/linux/x86/kernel-stat.h,
include/linux/x86_64/kernel-stat.h: These new files.
* include/gnu/x86/kernel-stat.h: New file.
* configure (main): Copy <srcdest>include/<kernel>/<arch>/*.h to
include/.
* configure.sh: Likewise.
* .gitignore: Ignore them.  Add copyright header.
* build-aux/GNUmakefile.in (X86_ARCH_HEADERS, ARCH_HEADERS): New
variables.
(build): Use them.
(include/arch/%.h, arch-dir): New targets.
* build-aux/bootstrap.sh.in (AM_CPPFLAGS): Replace
<srcdest>include/<kernel>/<cpu> with built ../include.
* build-aux/build.sh.in (AM_CPPFLAGS): Likewise.
* build-aux/install.sh.in: Also install built include.
2023-02-12 19:27:10 +01:00
Jan (janneke) Nieuwenhuizen fe3e3fcb10 DRAFT lib/m2: time: Fix segfault by allocating timeval struct.
Suggested by Meghan Denny <hello@nektro.net>.

* lib/m2/time.c (__tv): New global variable.
(time): Use it to allocate timeval struct.
2023-01-24 08:14:38 +01:00
Jan (janneke) Nieuwenhuizen 1c81749672 mescc: Fix Guile warnings.
* module/mescc/mescc.scm (GUILE-with-output-to-file): Remove.n
(with-output-to-file): Rename to...
(with-output-to-file*): ...this.
(mescc:preprocess, mescc:compile, infos->hex2): Update callers.
2023-01-08 10:18:46 +01:00
Jan (janneke) Nieuwenhuizen ab7203c1d6 doc: Use HTTPS.
* COPYING: Replace by new version (which uses HTTPS).
* HACKING,
README,
doc/fdl-1.3.texi,
doc/mes.texi: Use HTTPS.
2023-01-08 10:18:45 +01:00
Jan (janneke) Nieuwenhuizen 9ef3077213 doc: Update `HACKING'.
* HACKING (SETUP): Update arm triplet.
2023-01-08 10:18:44 +01:00
Jan (janneke) Nieuwenhuizen a156fb08b2
core: Move M2_PTR_SIZE, M2_CELL_SIZE to include file.
* lib/posix/getenv.c (M2_PTR_SIZE),
lib/posix/setenv.c (M2_PTR_SIZE): Move definition...
* include/mes/lib-mini.h (M2_PTR_SIZE): ...here.
* src/gc.c (M2_CELL_SIZE),
src/symbol.c (M2_CELL_SIZE),
src/test/gc.c (M2_CELL_SIZE),
src/vector.c (M2_CELL_SIZE): Move definition...
* include/mes/mes.h (M2_CELL_SIZE): ...here.
2022-05-07 10:50:06 +02:00
Jan (janneke) Nieuwenhuizen 97be538621
scaffold: Remove obsolete malloc.
* scaffold/lib/stdlib/malloc.c: Remove.
2022-05-07 08:45:06 +02:00
Jan (janneke) Nieuwenhuizen 327074e7ff
time.c: include sys/time for gettimeofday.
* lib/linux/time.c: Include <sys/time.h>.
2022-05-05 23:26:46 +02:00
Jan (janneke) Nieuwenhuizen 209ee8da2e
linux/read.c remove extra mes.h include. 2022-05-05 23:26:28 +02:00
Jan (janneke) Nieuwenhuizen 03fefbf816
lib: linux: Add wait4.
* lib/linux/waitpid.c (waitpid): Factor-out wait4 call to...
* lib/linux/wait4.c: ...new file here.
* include/sys/wait.h (wait4): Add prototype.  Include sys/resource.h.
* include/sys/resource.h (struct rusage): Remove gratuitous "int" for
M2-Planet.
* build-aux/configure-lib.sh (libc_SOURCES): Add it.
* kaem.run,
simple.make (M2_SOURCES),
simple.sh: Likewise.  Also add resource.h.
2022-05-04 15:56:07 +02:00
Jan (janneke) Nieuwenhuizen e3085fd899
lib: linux/time: Remove SYS_time specialization.
* lib/linux/time.c (time)[SYS_time]: Remove specialization.
[!SYS_time && !SYS_gettimeofday]: Remove fallback.
2022-05-04 14:14:51 +02:00
Jan (janneke) Nieuwenhuizen ccac40e503
kaem: Add kaem.arm and kaem.x86.
* kaem.arm,
kaem.x86: New files.
2022-05-03 23:35:41 +02:00
Jan (janneke) Nieuwenhuizen 11d024e097
kaem.run: Remove --bootstrap-mode.
* include/linux/arm/syscall.h,
include/linux/x86/syscall.h,
include/mes/constants.h: Remove CONSTANTs.
* include/sys/types.h (EOF): Change to 0xffffffff,
reps. 0xffffffffffffffff for M2-Planet.
* lib/m2/open.c: Move to...
* lib/linux/open.c: ...here.  Update to make gcc-compatible.
* scaffold/argv.kaem: Update accordingly.
* lib/linux/lseek.c (_leek, lseek): Suport M2-Planet.
* lib/linux/_open3.c (_open3): Fix cast.
* lib/linux/waitpid.c (waitpid): Suport M2-Planet.
* lib/m2/getcwd.c (PATH_MAX): Remove CONSTANT.
* lib/m2/isatty.c (TCGETS): Remove CONSTANT.
* lib/mes/ntoab.c: Support M2-Planet.
* lib/posix/getcwd.c (__getcwd_buf): Remove.
* lib/posix/getenv.c (M2_PTR_SIZE)[__M2__]: Update to #define.
* lib/posix/setenv.c: Likewise.
* lib/stub/__raise.c (SIGABRT): Remove CONSTANT.
* src/core.c (error): Use __M2__ instead of __M2_PLANET__.
* src/gc.c (M2_CELL_SIZE)[__M2__]: Update to #define.  Support
non-bootstrap-mode.
* src/posix.c: Likewise.
* src/symbol.c: Likewise.
* src/vector.c: Likewise.
* kaem.run: Remove --botstrap-mode.  Update source list accordingly.
* simple.make (M2_PLANET_FLAGS): Remove --bootstrap-mode.
* simple.make (M2_SOURCES, M2_PLANET_INCLUDES): Update source list
accordingly.
2022-05-03 14:45:55 +02:00
Jan (janneke) Nieuwenhuizen 00a6a13ec7
lib: posix/open: Support M2-Planet.
* lib/posix/open.c (open)[__M2__]: New function.
2022-05-03 18:05:38 +02:00
Jan (janneke) Nieuwenhuizen cf6fc2650d
lib: linux/_open3: Support M2-Planet.
* lib/linux/_open3.c (_open3): Use function casting.  Also call
__ungetc_init.
* lib/stub/__buffered_read.c: New file.
2022-05-03 18:03:49 +02:00
Jan (janneke) Nieuwenhuizen e5c34953e0
kaem: read: Remove --bootstrap-mode.
* include/mes/lib.h[__M2__](__call_at_exit,abtod,dtoab,ultoa,
* include/sys/types.h[__M2__]: Fall back to unsigned instead of using
unsigned long.
* include/stdio.h[__M2__](fprintf, fscanf, printf, snprintf, sprintf,
sscanf): Hide prototypes.
* lib/stdlib/exit.c (exit)[__M2__]: Hide call to __call_at_exit.
* lib/linux/read.c (read)[__M2__]: Hide debugging.
* lib/linux/malloc.c (malloc)[__M2__]: Hide alignment.
__mesabi_umod, __mesabi_udiv, __mesabi_uldiv): Hide prototypes.
* scaffold/argv.kaem: Use them together with lib/mes/lib-mini.h instead of
lib/mes/* specializations.  Remove --bootstrap-mode from M2-Planet call.
2022-05-03 12:54:22 +02:00
Jan (janneke) Nieuwenhuizen a3645b58d0
kaem: argv: Remove --bootstrap-mode.
* scaffold/argv.kaem: Use lib/mes/lib-mini.h instead of lib/m2/lib.h.
Remove --bootstrap-mode from M2-Planet call.
2022-05-03 12:53:35 +02:00
Jan (janneke) Nieuwenhuizen a22fa48faa
kaem: hello: Remove --bootstrap-mode.
* include/mes/lib-mini.h: Remove M2 bootstrap constants.
[__M2__](size_t): Fall-back to unsigned instead of unsigned long.
* scaffold/hello.kaem: Use it instead of lib/m2/lib.h.  Remove
--bootstrap-mode from M2-Planet call.
2022-05-03 12:44:00 +02:00
Jan (janneke) Nieuwenhuizen ff75d79ef6
kaem: main: Remove --bootstrap-mode.
* scaffold/main.kaem: Remove --bootstrap-mode from M2-Planet call.
2022-05-03 12:41:59 +02:00
Jan (janneke) Nieuwenhuizen 627b3089c9
simple.sh: Resurrect.
* simple.sh: Add src/globals.c, lib/stub/__raise.c.  Use
lib/linux/malloc.c instead of lib/stdlib/malloc.c.
2022-05-03 23:06:41 +02:00
Jan (janneke) Nieuwenhuizen eefc0326ed
simple.make: Resurrect.
* simple.make (M2_PLANET_FLAGS): Add --bootstrap-mode.
(M2_SOURCES): Use lib/mes/mini-write.c instead of lib/mes/write.c
2022-05-03 22:51:21 +02:00
Jan (janneke) Nieuwenhuizen 4988839b27
lib: linux/read: Fix compile warnings.
* lib/linux/read.c (read): Cast filedes, buffer to long.
2022-05-03 23:05:47 +02:00
Jan (janneke) Nieuwenhuizen daf6a016fd
lib: mes/write: Rename from mes/mini-write.c
* lib/mes/mini-write.c: Move to...
* lib/mes/write.c: ...here.
* build-aux/configure-lib.sh,
kaem.run,
scaffold/argv.kaem,
scaffold/global-array.kaem,
scaffold/hello.kaem,
scaffold/local-array.kaem,
scaffold/local-static-array.kaem,
scaffold/read.kaem,
simple.make,
simple.sh: Update accordingly.
2022-05-03 22:40:47 +02:00
Jan (janneke) Nieuwenhuizen eae64ef43b
build: Cater for colliding basename in C sources.
This is a follow-up to commit
    f785f8d560
    build: Fix --with-bootstrap build.

* build-aux/cc.sh: Retain directory name in object file name.
* build-aux/bootstrap.sh.in: Likewise.  Compile crt1.c from local
directory.
* build-aux/build-lib.sh: Likewise.
* build-aux/build.sh.in: Remove globals.o hack.
2022-05-21 15:10:46 +02:00
Jan (janneke) Nieuwenhuizen 2fec4f0e8e
guix: m2-planet: Update to 1.10.0.
* guix/git/mes.scm (m2-planet): Update to 1.10.0.
2022-05-03 09:24:23 +02:00
Gabriel Wicki 28705c96bd
core: Simplify math expressions.
* src/gc.c (gc_up_arena): Use division instead of shift.
(gc_flip): Simplify (free-news) * 1.5.
2022-05-10 22:23:40 +02:00
Ekaitz decc72a4f8
doc: Fix typos.
* doc/mes.texi (Invoking mescc): Fix typo.
* module/mescc.scm (parse-opts): Likewise.
2022-09-22 11:14:34 +02:00
Ekaitz 6e1ed36c51
mescc: Add X86_64 assembly defines for TinyCC compilation.
* lib/x86_64-mes/x86_64.M1 ( mov____%si,(%rdi), mov____%sil,(%rdi),
mov____(%rax),%si, mov____(%rax),%sil): New defines.
2022-09-21 09:43:43 +02:00
Jan (janneke) Nieuwenhuizen 0b6dd7edb6
build: When courageous, do build libgetopt and libtcc1.
* build-aux/build-lib.sh: Move building of libc+gnu and courageous exit
down.
2022-10-18 07:34:27 +02:00
Jan (janneke) Nieuwenhuizen e99775d060
build: Support bootstrap build without kaem/M2-Planet.
* configure.sh (M2_PLANET): Typo.  Allow check to fail.
(KAEM): Allow check to fail.
2022-10-17 13:10:48 +02:00
Jan (janneke) Nieuwenhuizen 3fd5df98a1
guix: mes: Update to 0.24.1.
* guix/git/mes.scm (mes)[source]: Update to 0.24.1.
2022-10-16 10:14:43 +02:00
Jan (janneke) Nieuwenhuizen 550ef59cf0
doc: Enlarge guix graph bootstrap image.
* doc/mes.texi (The Mes Bootstrap Process): Use 6in width.
2022-10-16 11:06:37 +02:00
Jan (janneke) Nieuwenhuizen 678b23a2ca
doc: Typo.
* doc/announce/ANNOUNCE-0.24.1: Typo.
2022-10-16 10:09:26 +02:00
Jan (janneke) Nieuwenhuizen 343ac812ca
doc: Typo.
* doc/announce/ANNOUNCE-0.24.1 (Subject): Typo.
2022-10-16 10:04:48 +02:00
Jan (janneke) Nieuwenhuizen d6e3d26478
doc: Post-release update.
* doc/announce/ANNOUNCE-0.24.1 (Subject): Update Add gen-announce
checksums by running `make sum-announce'.
* build-aux/GNUmakefile.in (--previous-version): Update to 0.24.1.
2022-10-16 09:57:43 +02:00
Jan (janneke) Nieuwenhuizen 62fbe42c5c
guix: mes: Update to 0.24.1.
* guix/git/mes.scm (mes)[source]: Update to 0.24.1.
2022-10-16 09:56:31 +02:00
Jan (janneke) Nieuwenhuizen e37e564ae3
build: Release 0.24.1.
* configure (VERSION): Bump to 0.24.1.
* configure.sh (VERSION): Likewise.
2022-10-15 09:52:04 +02:00