Commit Graph

2385 Commits

Author SHA1 Message Date
W. J. van der Laan 33f23d652b lib: Add RISC-V64 Linux syscall numbers header.
* include/linux/riscv64/syscall.h: New file: list relevant syscall
number constants.
2023-09-12 11:04:10 +02:00
Jan (janneke) Nieuwenhuizen b9647b874c lib: Document syscalls.
* include/linux/SYSCALLS: New file.
2023-09-12 11:04:10 +02:00
W. J. van der Laan 95cfc38772 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-09-12 11:04:10 +02:00
W. J. van der Laan 3752e735d2 core: Add RISC-V architecture detection.
* src/mes.c(mes_environment)[__riscv_xlen == 32]: Set
architecture to riscv32.
[__riscv_xlen == 64]: Set architecture to riscv64.

xlen
2023-09-12 11:04:10 +02:00
W. J. van der Laan 3267daedbf 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-09-12 11:04:10 +02:00
W. J. van der Laan 55b42018db 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-09-12 11:04:10 +02:00
Ekaitz 0b5053e4b7 XXX lib: Make objdump work on binaries in x86-linux.
XXX: do the same for other architectures

* lib/linux/x86-mes/elf32-header.hex2: Fix header sizes for objdump.
2023-09-12 11:04:02 +02:00
Ekaitz 190cafbfb1 XXX lib: Make objdump work on binaries in x86_64-linux.
XXX: do the same for other architectures

* lib/linux/x86_64-mes/elf64-header.hex2: Fix header sizes for objdump.
2023-09-12 11:04:02 +02:00
Janneke Nieuwenhuizen 6117207d72 squash! HACK mescc: Consider truncate after each shift operation.
Instead of truncating on size of first operand, truncate on largest of
default/int or size of first operand
2023-09-12 11:04:02 +02:00
Janneke Nieuwenhuizen bc4339815f DRAFT test: Add 68-truncate-shift.
* lib/tests/scaffold/68-truncate-shift.c: New file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-09-12 11:04:02 +02:00
Janneke Nieuwenhuizen 57b60fc794 HACK mescc: Consider truncate after each shift operation.
XXX For every binop / binop* operation?  We need tests?

* module/mescc/compile.scm (expr->register): After lshift and rshift,
use convert-r0.
2023-09-12 11:04:02 +02:00
Andrius Štikonas 08b1e9fefe mescc: Do not overflow M1 64bit immediates.
M1 immediates are limited to 31-bit before they become negative.

* module/mescc/x86_64/as.scm (x86_64:value->r, x86_64:r-cmp-value,
x86_64:r-long-mem-add, x86_64:r-and): Limit M1 immediate to #x80000000.

* lib/tests/scaffold/67-m1-overflow-check.c: New test.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-09-12 11:04:02 +02:00
Andrius Štikonas abf677a8c3 mescc: Fix hex2:immediate8 to work with mes/m2-compiled mes.
* module/mescc/M1.scm (hex2:immediate8): Remove mesc? exception.
(mesc?): Remove.
2023-09-12 11:04:02 +02:00
Janneke Nieuwenhuizen 1b87616349 guix: m2-planet: Update to 1.10.0-0.754c5de.
For 64bit platforms, this fix is essential

    85dd953 Add padding when loading global ints on 64-bit arches.

* guix/git/mes.scm (m2-planet): Update to latest git.
2023-09-12 11:04:02 +02:00
Janneke Nieuwenhuizen 7f3f05f856 core: Avoid displaying truncated 64bit values.
* src/display.c (display_helper): Use `ltoa' instead of `itoa'.
2023-09-12 11:04:02 +02:00
Andrius Štikonas 76e6217725 lib: Fix x86_64 M2 elf header to work with debug info.
* lib/m2/x86_64/ELF-x86_64.hex2: Fix e_shoff, e_shentsize, e_shstrndx.
2023-09-12 11:04:02 +02:00
Andrius Štikonas 6d92ad4323 kaem: Pass --64 to blood_elf on 64-bit arches.
* kaem.run (blood_elf_flag): New variable with dummy default value to
support kaem from mescc-tools 1.4.0.
* kaem.x86_64 (blood_elf_flag): New variable.
2023-09-12 11:04:02 +02:00
Janneke Nieuwenhuizen 996b55046c m2: Add new style x86_64 defines to support M2-Planet 1.11.0.
* lib/m2/x86_64/x86_64_defs.M1: Add new M1 defines.
2023-09-12 11:04:02 +02:00
Jan (janneke) Nieuwenhuizen c8294803cd x86_64: build: Cater for M2-Planet.
* build-aux/cflags.sh: Set cc_cpu.
* build-aux/config.sh.in (cc_cpu): Export.
* build-aux/export.make (cc_cpu): Likewise.
* kaem.arm (cc_cpu): New variable.
* kaem.x86 (cc_cpu): New variable.
* kaem.run (cc_cpu): New variable.  Define __<cc_cpu>__.
* scaffold/argv.kaem (cc_cpu): Likewise.  Define __linux__
* scaffold/global-array.kaem (cc_cpu): Likewise.
* scaffold/hello.kaem (cc_cpu): Likewise.
* scaffold/local-array.kaem (cc_cpu): Likewise.
* scaffold/local-static-array.kaem (cc_cpu): Likewise.
* scaffold/main.kaem (cc_cpu): Likewise.
* scaffold/read.kaem (cc_cpu): Likewise.
* kaem.x86_64: New file.
lib/m2/x86_64/ELF-x86_64.hex2,
lib/m2/x86_64/x86_64_defs.M1: New files, imported from M2Libc.
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: New files, adapted for M2-Planet
calling convention from ...
* lib/linux/x86_64-mes-mescc: ... here.
* build-aux/build.sh.in: Also allow kaem build for x86_64.
* include/mes/lib-mini.h[__M2__]: Define as sizeof (void*).
* include/mes/mes.h[__M2__](M2_CELL_SIZE): Define as sizeof (struct scm).
* lib/x86_64-mes/x86_64.M1 (add____$i8,%rbp, mov____%rdi,%rbp): New
defines.
* src/posix.c (TIME_UNITS_PER_SECOND): Cater for 64bit M2-Planet.
2023-09-12 11:04:02 +02:00
Janneke Nieuwenhuizen 61956fb14c build: Generate reproducible doc/version.texi.
* build-aux/GNUmakefile.in (doc/version.texi): Use timestamp from git.
2023-09-09 14:05:28 +02:00
Janneke Nieuwenhuizen 8371544c6f build: Help help2man generate reproducible man-pages.
* build-aux/GNUmakefile.in (SOURCE_DATE_EPOCH): New variable.
2023-09-09 14:05:26 +02:00
Janneke Nieuwenhuizen a4a0d0d66d DRAFT lib: tests: 17-compare-unsigned-le: Add case from 7s-unsigned-compare.
* lib/tests/scaffold/17-compare-unsigned-le.c: Add case from
7s-unsigned-compare; rewrite to avoid gcc-optimize.
2023-08-30 06:17:08 +02:00
Janneke Nieuwenhuizen 37113f1988 DRAFT lib: tests: 17-compare-unsigned-short-le.c: Avoid gcc optimize.
* lib/tests/scaffold/17-compare-unsigned-short-le.c (main): Change
comparison with immediate to comparison with variable.
2023-08-30 06:17:08 +02:00
Janneke Nieuwenhuizen 03179824f8 DRAFT lib: tests: 17-compare-unsigned-char-le.c: Avoid gcc optimize.
* lib/tests/scaffold/17-compare-unsigned-char-le.c (main): Change
comparison with immediate to comparison with variable.
2023-08-30 06:17:08 +02:00
Janneke Nieuwenhuizen b33e3e8b76 squash! lib: tests: Add 17-compare-rotated. 2023-08-30 06:17:08 +02:00
Janneke Nieuwenhuizen 8aace6faae squash! lib: tests: Add 16-cast. 2023-08-30 06:17:08 +02:00
Ekaitz d6f7739bfc lib: tests: Add 17-compare-rotated.
* lib/tests/scaffold/17-compare-rotated.c: Add file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-08-29 22:07:10 +02:00
Ekaitz 5128d6c3b4 lib: tests: Add 16-cast.
* lib/tests/scaffold/16-cast.c: Add file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-08-29 22:07:10 +02:00
Janneke Nieuwenhuizen 96ad09dbfd lib: tests: 63-struct-cell: Avoid segfault by array overflow with gcc >= 10.
* lib/tests/scaffold/63-struct-cell.c (g_functions]: Use size 3.
2023-08-29 22:07:01 +02:00
Janneke Nieuwenhuizen addecda4fe guix: mes.git: Add gdb.
* guix/git/mes.scm (mes.git)[native-inputs]: Add gdb.
2023-08-28 09:43:57 +02:00
Janneke Nieuwenhuizen 102fe7dc58 mescc: Remove duplicate include.
* module/mescc/preprocess.scm (mescc): Remove second (nyacc lang c99
parser) include.
2023-08-27 10:05:33 +02:00
Ekaitz 721a06fc0b tests: Make tests/vector.test compatible with Guile.
* mes/module/mes/type-0.mes (unspecified?): New function.
* tests/vector.test (make-vector): Use it to test equality rather than
rely on string comparison.
2023-08-27 10:05:20 +02:00
Ekaitz 294d8a9737 mes: iota: Make compatible with Guile.
* mes/module/mes/scm.mes (iota): Throw exception when n < 0.
* tests/scm.test: Import (mes catch).
("iota -1"): Rewrite with exception handling.
2023-08-27 10:05:17 +02:00
Ekaitz ff02777236 mes: Add %program to mes-compatibility for Guile.
This fixes running scaffold/boot/gc.scm with Guile.

* module/mes/guile.scm (%program): Define and export.
2023-08-24 15:28:35 +02:00
Ekaitz d5ba672301 build: Fix typo causing tcc tests being skipped.
* build-aux/check-mescc.sh (TESTS): Use $tcc_tests instead of $tcc_test.
2023-08-24 14:58:35 +02:00
Janneke Nieuwenhuizen 8e75c00c7b repl: Fix include, load, use MODULE, and mes-use-module.
Reported by Irvise via IRC.

* mes/module/mes/repl.mes (repl)[load-env, mes-load-module-env]: New
inner defines.
[use]: Use mes-load-module-env, do not return content of module.
Special-case 'include' and 'load'.
2023-07-08 15:10:05 +02:00
Janneke Nieuwenhuizen 5850531ae9 core: Set compiler for M2-Planet.
This is a follow-up to commit
    7a6505be6e
    build: Cater for M2-Planet.

* src/mes.c (mes_environment)[__M2__]: Set compiler to "m2c".
2023-07-08 15:10:05 +02:00
Janneke Nieuwenhuizen ab9946d8ef lib/tests: Initialize local variable.
Reuported by Andrius Štikonas <andrius@stikonas.eu> via IRC.

* lib/tests/assert/50-assert.c (main): Initialize local f.
* lib/tests/scaffold/21-char-array.c (main): Likewise.
2023-07-08 15:10:05 +02:00
Janneke Nieuwenhuizen 00720c8d5f mes: Define R_OK as 4.
Reported by fossy via IRC.

* mes/module/mes/posix.mes (R_OK): Define as 4.
2023-07-08 15:10:05 +02:00
Efraim Flashner 8aa28acb4f build: Fix typo.
* build-aux/GNUmakefile.in (X86_ARCH_HEADERS): Fix typo
2023-07-08 15:10:05 +02:00
Emily Trau c20f6ac025 lib: Define O_TMPFILE for GNU make 4.4.1.
* include/fcntl.h (O_TMPFILE): New define.
2023-07-08 15:10:05 +02:00
Janneke Nieuwenhuizen ad7ce36b5b build: Drop support for mescc-tools 0.5.2.
* build-aux/build-scaffold.sh (stage0_cpu_flag): Remove.  Update users.
* build-aux/cflags.sh (stage0_arch): Remove.
* build-aux/config.sh.in (numbered_arch): Remove.
* configure (main): Remove check for numbered-arch?.  Remove
substitution of @numbered-arch@.
* configure.sh (numbered_arch): Likewise.
* module/mescc.scm (%numbered-arch?): Remove.
(parse-opts): Remove support for --numbered-arch?
* module/mescc/mescc.scm (mescc:compile): Remove alignment exception for
numbered-arch?.
(infos->hex2): Likewise.
(arch-get-architecture): Remove support for numbered-arch?.
* scripts/mescc.in (numbered_arch): Remove.
* scripts/mescc.scm.in (%numbered-arch?): Remove.
("%numbered_arch"): Remove.
2023-05-03 14:52:25 +02:00
Janneke Nieuwenhuizen 1a1fbfd36c DRAFT doc: Update for 0.25.
* doc/images/gcc-mesboot-graph.dot: Regenerate.
* doc/mes.texi (Introduction): Whitespace fixes.
(Full Source Bootstrap): Mention deployment in Guix.
(Requirements): Update M2-Planet to 1.10.0.
(Bootstrap Requirements): Likewise.
(The Mes Bootstrap Process): Update Reduced Binary Bootstrap to Full
Source Bootstrap.  Update next priority.  Add deployments.
(Bootstrapping): Add tagline for "Invoking mesar".
(Full Source Bootstrap Deployments): New subsection.
2023-05-03 08:04:32 +02:00
Andrius Štikonas ad18345687 core: Fix a typo in comment.
* src/gc.c (gc_init): Fix typo.
2023-05-03 08:04:32 +02:00
Andrius Štikonas 762200b65a m2: Add new style x86 defines to support M2-Planet 1.11.0.
* lib/m2/x86/x86_defs.M1: Add new M1 defines.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen 640bdd027b lib: __assert_fail: Remove M2-Planet workarounds.
* lib/mes/__assert_fail.c (__assert_fail): Use *file, *function.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen 6bc6e8354e 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.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen cbea14f843 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.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen 7725574935 kaem: Add kaem.arm and kaem.x86.
* kaem.arm,
kaem.x86: New files.
2023-05-03 08:04:32 +02:00
Jan (janneke) Nieuwenhuizen dad460189f kaem.run: Remove --bootstrap-mode.
* include/linux/arm/syscall.h,
include/linux/x86/syscall.h,
include/mes/constants.h: Remove CONSTANTs.
* 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/symbol.c: Likewise.
* src/vector.c: Likewise.
* src/posix.c: Likewise.
(__raise): Move to...
* include/mes/lib-cc.h (__raise): ...this new file to avoid M2-Planet crash.
* include/sys/types.h: Include it.
* lib/mes/div.c (__raise): Remove prototype.
[__TINYC__ || SYSTEM_LIBC] (__raise): Remove macro.
* include/mes/lib.h (__raise)[SYSTEM_LIBC]: Remove prototype.
* 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.
* include/sys/types.h (EOF): Move to...
* include/mes/lib-cccc.h (EOF): ...here, and...
* include/m2/types.h (EOF): ...here, to avoid M2-Planet crash.
2023-05-03 08:03:48 +02:00