Compare commits

...

111 Commits

Author SHA1 Message Date
Andrius Štikonas a34f255f40 riscv64: Fix arguments of main function in tcc.
* lib/linux/riscv64-mes-tcc/crt1.c
2023-10-06 19:54:40 +01:00
Andrius Štikonas eea9f759ee riscv64: simplify assembly constructs not supported by tcc.
At the moment tcc does not support assembler instructions
with C expression operands. As a workaround read values
directly from stack.

* lib/linux/riscv64-mes-tcc/_exit.c
* lib/linux/riscv64-mes-tcc/_write.c
* lib/linux/riscv64-mes-tcc/syscall.c
2023-10-04 23:23:05 +01:00
Janneke Nieuwenhuizen 44de0ec1c4 squash! riscv64: add support for tcc 2023-09-21 18:10:25 +02:00
Ekaitz 72758d48d8 riscv64: add support for tcc
Adapted from -gcc but make assembly match tcc style assembly where the
offsets are received as an extra input argument:

  sw a0, 9(t0)

Becomes:

  sw a0, t0, 9

* lib/linux/riscv64-mes-tcc/_exit.c,
lib/linux/riscv64-mes-tcc/_write.c,
lib/linux/riscv64-mes-tcc/crt1.c,
lib/linux/riscv64-mes-tcc/exit-42.S,
lib/linux/riscv64-mes-tcc/hello-mes.S,
lib/linux/riscv64-mes-tcc/syscall-internal.c,
lib/linux/riscv64-mes-tcc/syscall.c: New files.
2023-09-21 18:07:48 +02:00
Janneke Nieuwenhuizen 98f37a5bdb squash! mescc: Fix switch statements' fallthrough 2023-09-17 07:44:16 +02:00
Janneke Nieuwenhuizen 6ec2715f74 Revert "squash! mescc: Fix switch statements' fallthrough --support mes"
This reverts commit ef4f4bb25a.
2023-09-17 07:41:03 +02:00
Janneke Nieuwenhuizen c65ce2798b Revert "squash! squash! mescc: Fix switch statements' fallthrough --support mes"
This reverts commit 3266f6a834.
2023-09-17 07:41:01 +02:00
Janneke Nieuwenhuizen 3266f6a834 squash! squash! mescc: Fix switch statements' fallthrough --support mes 2023-09-16 17:38:48 +02:00
Janneke Nieuwenhuizen ef4f4bb25a squash! mescc: Fix switch statements' fallthrough --support mes 2023-09-16 08:19:02 +02:00
Ekaitz 1ec88d0109 mescc: Fix switch statements' fallthrough
Flattens case structures as nyacc is giving consecutive cases as a
nested block like:

    (case testA
      (case testB
        (case testC BODY)))

We convert to:

    ((case testA (expr-stmt))
     (case testB (expr-stmt))
     (case testC BODY))

And then treat them as independent cases. For the fallthrough we just
add a jump to each case's body right before its clause (each of the case
blocks is responsible of adding its own jump to its body):

        // This doesn't have it because it's the first
    CASE1:
        testA
    CASE1_BODY:

        goto CASE2_BODY
    CASE2:
        testB
    CASE2_BODY:

        goto CASE3_BODY
    CASE3:
        testB
    CASE3_BODY:

This enables complex fallthrough schemes comparing to what was done
before.

* module/mescc/compile.scm
  (ast->info)[switch]{flatten-cases}: New variable.
  (ast->info)[switch]{statements}: Use flatten-cases on it.
  (switch->expr): Remove unneeded matchers and add jumps to body.
* build-aux/check-mescc.sh(xfail-tests): Remove
  lib/tests/scaffold/66-local-char-array.c
2023-09-13 13:48:33 +02:00
Ekaitz 7ae03cc19b lib/tests: 44-switch-body-fallthrough-not-default.c: Add test.
This test detects if the fallthrough in a switch statement falls to the
next case (good) or to the default case (bad).

* lib/tests/scaffold/44-switch-body-fallthrough-not-default.c: New file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-09-12 11:04:11 +02:00
Ekaitz c989f9c56a lib/tests: 50-compare-rotated-weird.c: Add test for RV reloc
We detected the value in off64 in the test is not -1 as it should but 56
ones. This is because the rotation is applied as unsigned even with the
signed cast. This breaks many things in tcc.

* lib/tests/scaffold/50-compare-rotated-weird.c: New file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-09-12 11:04:11 +02:00
Ekaitz 4e9f08e2af mescc: Add support for signed rotation.
* module/mescc/compile.scm (expr->register)[rshift, assn-expr]: Add
signed right-rotation support.
* lib/arm-mes/arm.M1 (asr): Add instruction.
* lib/x86-mes/x86.M1 (sar): Add instruction.
* lib/x86_64-mes/x86_64.M1 (sar): Add instruction.
* module/mescc/armv4/as.scm (armv4:r0>>r1-signed): New procedure.
(armv4:instructions): Register it.
* module/mescc/i386/as.scm (i386:r0>>r1-signed): New procedure.
(i386:instructions): Register it.
* module/mescc/riscv64/as.scm (riscv64:r0>>r1-signed): New procedure.
(riscv64:instructions): Register it.
* module/mescc/x86_64/as.scm (x86_64:r0>>r1-signed): New procedure.
(x86_64:instructions): Register it.
(
2023-09-12 11:04:11 +02:00
Ekaitz efa2ff9474 XXX lib: Make objdump work on binaries in riscv64
XXX: do the same for other architectures

* lib/linux/riscv64-mes/elf32-header.hex2: Fix header sizes for objdump.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 0f0a510c43 Revert "crt1: Move main declaration to mes/lib-mini.h."
This reverts commit 5b55627e0ccf7c798284a380a20a2eb4d6b9c4c0.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 376f8a43d0 crt1: Move main declaration to mes/lib-mini.h.
* include/mes/lib-mini.h (main): New declaration.
lib/freebsd/x86-mes-gcc/crt1.c (main): Remove declaration.
lib/freebsd/x86-mes-mescc/crt1.c (main): Remove declaration.
lib/gnu/x86-mes-gcc/crt1.c (main): Remove declaration.
lib/linux/arm-mes-gcc/crt1.c (main): Remove declaration.
lib/linux/arm-mes-m2/crt1.c (main): Remove declaration.
lib/linux/arm-mes-mescc/crt1.c (main): Remove declaration.
lib/linux/riscv64-mes-gcc/crt1.c (main): Remove declaration.
lib/linux/riscv64-mes-m2/crt1.c (main): Remove declaration.
lib/linux/riscv64-mes-mescc/crt1.c (main): Remove declaration.
lib/linux/x86-mes-gcc/crt1.c (main): Remove declaration.
lib/linux/x86-mes-m2/crt1.c (main): Remove declaration.
lib/linux/x86-mes-mescc/crt1.c (main): Remove declaration.
lib/linux/x86_64-mes-gcc/crt0.c (main): Remove declaration.
lib/linux/x86_64-mes-gcc/crt1.c (main): Remove declaration.
lib/linux/x86_64-mes-m2/crt1.c (main): Remove declaration.
lib/linux/x86_64-mes-mescc/crt1.c (main): Remove declaration.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen fdf147fa59 DRAFT doc: Add ANNOUNCE-0.25.
* doc/announce/ANNOUNCE-0.24: Typo.
* doc/announce/ANNOUNCE-0.25: New file.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 7317a2f5a8 Add .mailmap.
* .mailmap: New file.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 84785b16f7 DRAFT doc: Update `NEWS'.
* NEWS (Changes in 0.25 since 0.24.2): New section.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 8b0f2e29db DRAFT doc: Update `AUTHORS'.
* AUTHORS: Mention RISC-V port.
* mes/module/mes/repl.mes (welcome): Add Wladimir van der Laan and
Andrius Štikonas.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen c7981c0c9e DRAFT doc: Update `README'.
* README: Updates for 0.25.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen ed12d52f1a DRAFT doc: Bump M2-Planet requirement to 1.11.0.
* doc/mes.texi (Requirements): Update M2-Planet version to 1.11.0.
(Bootstrap Requirements): Likewise.
* INSTALL (Other GNU/Linux): Likewise.
2023-09-12 11:04:11 +02:00
Ekaitz b12f56c922 mescc: Initialize missing struct fields to 0.
This is a follow-up to commits
    7a8a2fc517
    mescc: x86_64 support: Refactor to abstracted assembly, add x86_64.

and

    c9ba7a619b
    mescc: Refactor variable declaration.

There was a debug "22" leaking in compile.scm.  It should be a "0".

* module/mescc/compile.scm (init-local): Replace "22" with "0".
* lib/tests/scaffold/7v-struct-initialize-zeroes.c: New test.
* build-aux/check-mescc.sh (tcc_tests): Add it.
(xfail-tests): Remove lib/tests/scaffold/72-typedef-struct-def-local.c.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen c5fbf9a06c lib/tests: 76-pointer-arithmetic: Cater for RISC-V64.
* lib/tests/scaffold/76-pointer-arithmetic.c (struct
foo)[__riscv_xlen==64]: Add __align.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 7980716681 riscv64: lib/tests: Skip 70-extern.c for gcc.
* build-aux/check-mescc.sh (xfail_tests)[gcc && riscv64]: Add
lib/tests/scaffold/70-extern.c.
2023-09-12 11:04:11 +02:00
Andrius Štikonas e42cf58d14 riscv64: Port to word based mescc-tools.
* module/mescc/M1.scm (riscv:i-format, riscv:j-format, riscv:u-format):
New procedures for RISC-V instruction formats.
(info->M1): Use them to switch from !0xAB to M1
weird strings 'AB'.
* module/mescc/riscv64/as.scm,
lib/linux/riscv64-mes-m2/_exit.c
ib/linux/riscv64-mes-m2/_write.c,.
lib/linux/riscv64-mes-m2/crt1.M1,.
lib/linux/riscv64-mes-m2/syscall.c,.
lib/linux/riscv64-mes-mescc/_exit.c,.
lib/linux/riscv64-mes-mescc/_write.c,.
lib/linux/riscv64-mes-mescc/crt1.c,.
lib/linux/riscv64-mes-mescc/syscall-internal.c,.
lib/linux/riscv64-mes-mescc/syscall.c,.
lib/m2/riscv64/riscv64_defs.M1,.
lib/riscv64-mes-mescc/setjmp.c,.
lib/riscv64-mes/riscv64.M1: Switch to riscv64 word-based macros.
* lib/linux/open.c (open)[!SYS_open]: Add support using openat syscall.
* include/linux/riscv64/syscall.h (MAKESTRING, MAKESTRING2,
RISCV_SYSCALL): New macros.
2023-09-12 11:04:11 +02:00
Andrius Štikonas c009e6a191 build: Ignore /m2 build directory.
* .gitignore: Add /m2.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 60c4c193ef guix: m2-planet: Update to 0.10.0-1-c82fb8c353.
* guix/git/mes.scm (m2-planet)[source]: Update to
0.10.0-1-c82fb8c3530e93fd49efe60da785ffff827ea4d.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 6bcc8813cf doc: Update `PORTING'.
* PORTING (Setup environment): Use nyacc 1.00.2.  Prefer git-minimal
over git to avoid dependencies on subversion and graphic libraries.  Add
riscv64-linux example.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 03ef0cabc4 gnu: Update main prototype.
* lib/gnu/x86-mes-gcc/crt1.c (main): Add parameters.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 02bc7e62ee riscv64: lib: Use __init_io.
* lib/linux/riscv64-mes-gcc/crt1.c (_start): Replace manual initialization
of __stdin, __stdout, __stderr, and environ with __init_io ().
* lib/linux/riscv64-mes-mescc/crt1.c (_start): Likewise.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 826c517ad0 arm: lib: Use __init_io.
* lib/linux/arm-mes-gcc/crt1.c (_start): Replace manual initialization
of __stdin, __stdout, __stderr, and environ with __init_io ().
* lib/linux/arm-mes-m2/crt1.M1 (_start): Likewise.
* lib/linux/arm-mes-mescc/crt1.c (_start): Likewise.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 4ca7029115 freebsd: lib: Use __init_io.
* * lib/freebsd/x86-mes-gcc/crt1.c (_start): Replace manual initialization
of __stdin, __stdout, __stderr, and environ with __init_io ().
* lib/freebsd/x86-mes-mescc/crt1.c (_start): Likewise.
* lib/freebsd/x86-mes-gcc/_write.c (SYS_exit): Remove.
(SYS_write): New define.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen a65981af98 x86_64: lib: Use __init_io.
* lib/linux/x86_64-mes-gcc/crt1.c (_start): Replace manual initialization
of __stdin, __stdout, __stderr, and environ with __init_io ().
* lib/linux/x86_64-mes-m2/crt1.M1 (_start): Likewise.
* lib/linux/x86_64-mes-mescc/crt1.c (_start): Likewise.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen afe3831e66 x86: lib: Use __init_io.
* build-aux/configure-lib.sh (libc_mini_shared_SOURCES): Add init_io.c.
* include/mes/lib-mini.h (__init_io): Declare it.
* lib/linux/x86-mes-gcc/crt1.c (_start): Replace manual initialization
of __stdin, __stdout, __stderr, and environ with __init_io ().
* lib/linux/x86-mes-m2/crt1.M1 (_start): Likewise.
* lib/linux/x86-mes-mescc/crt1.c (_start): Likewise.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen df15c0ecd7 core: Remove duplicate environment initialization.
* src/mes.c (init): Remove envp parameter.  Remove environment initialization.
(main): Remove envp parameter.  Update caller.
2023-09-12 11:04:11 +02:00
Jan (janneke) Nieuwenhuizen d40520af55 riscv64: Cater for M2-Planet.
* kaem.riscv64: New file.

* lib/linux/riscv64-mes-m2/crt1.M1,
lib/m2/riscv64/ELF-riscv64.hex2,
lib/m2/riscv64/riscv64_defs.M1: New files, imported from M2Lib.c
* lib/linux/riscv64-mes-m2/_exit.c,
lib/linux/riscv64-mes-m2/_write.c,
lib/linux/riscv64-mes-m2/crt1.c,
lib/linux/riscv64-mes-m2/syscall.c: New files, adapted for M2-Planet
calling convention from ...
* lib/linux/riscv64-mes-mescc: ...here
* kaem.run: Move fcntl.h up.  Include signal.h.
* build-aux/build.sh.in: Also allow kaem build for riscv64.
2023-09-12 11:04:11 +02:00
Janneke Nieuwenhuizen 14ef14edf5 scaffold: Add env.
* scaffold/env.c,
scaffold/env.kaem: New files.
* build-aux/build.sh.in: Use them.
2023-09-12 11:04:11 +02:00
Jan (janneke) Nieuwenhuizen 96aec42a89 guix: mescc-tools: Add RISCV architectures.
This is a follow-up to commit
    79da3fc3e2
    guix: mescc-tools: Update to 1.4.0

* guix/git/mes.scm (mescc-tools)[supported-systems]: Add riscv32-linux
and riscv64-linux.
2023-09-12 11:04:11 +02:00
Jan (janneke) Nieuwenhuizen 3c767a3bf9 mescc: Use size 8 for stack.
Reported by  W. J. van der Laan <laanwj@protonmail.com>.

* module/mescc/x86_64/as.scm (x86_64:function-locals): Oops, use size 8.
2023-09-12 11:04:11 +02:00
W. J. van der Laan 310620eef9 lib: Linux riscv64-mes-mescc support.
* lib/linux/riscv64-mes-mescc/_exit.c,
lib/linux/riscv64-mes-mescc/_write.c,
lib/linux/riscv64-mes-mescc/crt1.c,
lib/linux/riscv64-mes-mescc/syscall-internal.c,
lib/linux/riscv64-mes-mescc/syscall.c: New files.  These add support for
building for riscv64-mes-mescc and make it self-hosting.
2023-09-12 11:04:11 +02:00
W. J. van der Laan 9d5613e0af lib: Base riscv64-mes-mescc support.
* lib/riscv64-mes-mescc/setjmp.c: New file.
(setjmp, longjmp): Implement for RV64.
2023-09-12 11:04:11 +02:00
W. J. van der Laan 58fb0c78f2 lib: Add RISCV64 instruction macros for M1.
* lib/riscv64-mes/riscv64.M1: New file.  Add set of instruction macros
for RV64.  These are all potentially needed by the code generation.  I
have made no effort yet to minimize the list of instructions for mes+tcc
compile.
2023-09-12 11:04:11 +02:00
W. J. van der Laan dc6af19506 mescc: RISC-V64 code generation.
* mes/module/mescc/mescc.mes: Import riscv64 code generation modules.
* mes/module/mescc/riscv64/as.mes: Imports for as.mes.
* mes/module/mescc/riscv64/info.mes: Imports for info.mes.
* module/mescc/mescc.scm (replace-suffix, arch-get, arch-get-info,
arch-get-machine, arch-get-m1-macros, .E?, .s?, .o?): Handle riscv64 and
some stubs for riscv32.
(arch-get-defines): Add defines for riscv32 and riscv64.
* module/mescc/riscv64/as.scm: New file: Code generator module for RISC-V64.
* module/mescc/riscv64/info.scm: New file: Architecture info for RISC-V64.
* build-aux/build-guile.sh (SCM_FILES): Add them.
2023-09-12 11:04:11 +02:00
W. J. van der Laan 9044e13309 lib: Make stdarg work for GCC on RISC-V64.
* include/stdarg.h: GCC on RISC-V always passes arguments in registers.
Implementing these macros without the use of built-ins would be very
involved. So use those for now to make printf etc work.
2023-09-12 11:04:11 +02:00
W. J. van der Laan fa3e83691d lib/tests: Take RISC-V into account in size conditionals.
* lib/tests/scaffold/76-pointer-arithmetic.c (main): Use the right sizes
in the test for RISC-V architectures.
* lib/tests/scaffold/7k-for-each-elem.c (main): Same.
* lib/tests/scaffold/85-sizeof.c: Same.
2023-09-12 11:04:10 +02:00
W. J. van der Laan f24b1e467c lib: General Linux RISC-V64 syscall support.
* include/linux/riscv32/kernel-stat.h,
include/linux/riscv64/kernel-stat.h: New files.
* include/fcntl.h (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR): Add
necessary constants.
* include/stdint.h: Integer size defines for RISC-V.
* include/sys/stat.h: "stat" struct for RISC-V.
* lib/linux/_open3.c (_open3)[!SYS_open]: Use SYS_openat.
* lib/linux/access.c (access)[!SYS_access]: Use SYS_faccessat.
* lib/linux/chmod.c (chmod)[!SYS_chmod]: Use SYS_fchmodat.
* lib/linux/dup2.c (dup2)[!SYS_dup2]: Use if SYS_dup3.
* lib/linux/fork.c (fork)[!SYS_fork]: Use SYS_clone.
* lib/linux/getdents.c (getdents)[!SYS_getdents]: Use SYS_getdents64.
* lib/linux/link.c (link)[!SYS_link]: Use SYS_linkat.
* lib/linux/lstat.c (lstat)[!SYS_lstat]: Use SYS_newfstatat.
* lib/linux/mkdir.c (mkdir)[!SYS_mkdir]: Use SYS_mkdirat.
* lib/linux/mknod.c (mknod)[!SYS_mknod]: Use SYS_mknodat.
* lib/linux/pipe.c (pipe)[!SYS_pipe]: Use SYS_pipe2.
* lib/linux/readlink.c (readlink)[!SYS_readlinkat]: Use SYS_readlinkat.
* lib/linux/rename.c (rename)[!SYS_rename]: Use SYS_renameat2.
* lib/linux/rmdir.c (rmdir)[!SYS_rmdir]: Use SYS_unlinkat.
* lib/linux/signal.c (_restorer_for_siginfo): Remove unused function
that causes compilation issue.
* lib/linux/stat.c (stat)[!SYS_stat]: Use SYS_newfstatat.
* lib/linux/symlink.c (symlink)[!SYS_symlinkat]: Use SYS_symlink.
* lib/linux/unlink.c (unlink)[!SYS_unlink]: Use SYS_unlinkat.
2023-09-12 11:04:10 +02:00
W. J. van der Laan 9ce2b56743 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-09-12 11:04:10 +02:00
W. J. van der Laan 32d7171835 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-09-12 11:04:10 +02:00
W. J. van der Laan 8af58676b9 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-09-12 11:04:10 +02:00
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
Jan (janneke) Nieuwenhuizen e354d912ef lib: posix/open: Support M2-Planet.
* lib/posix/open.c (open)[__M2__]: New function.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen 6ec74a34c4 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.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen 4d4e6959e9 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.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen 2a759f904d 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.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen fda2e4b9fc 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.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen 468a9c7cd8 kaem: main: Remove --bootstrap-mode.
* scaffold/main.kaem: Remove --bootstrap-mode from M2-Planet call.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen 37e8093bbb guix: m2-planet: Update to 1.10.0.
* guix/git/mes.scm (m2-planet): Update to 1.10.0.
[supported-systems]: Add riscv32-linux, riscv64-linux.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen 402b024982 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.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen 29341f5783 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.
2023-05-02 10:22:45 +02:00
Jan (janneke) Nieuwenhuizen e428c17cc5
lib/m2: Update syscall includes.
This is a follow-up to commit
    bc1fa57851
    lib: stat: Use SYS_stat64 for 32bit platforms.

* lib/m2/chmod.c: Update to <arch/syscall.sh>.
* lib/m2/clock_gettime.c: Likewise.
* lib/m2/read.c: Likewise.
2023-05-02 10:22:01 +02:00
Jan (janneke) Nieuwenhuizen c656bab1fd
doc: Post-release update.
* build-aux/GNUmakefile.in (--previous-version): Update to 0.24.2.
* doc/announce/ANNOUNCE-0.24.2: Run `make sum-announce'.
2023-02-13 12:11:01 +01:00
218 changed files with 6584 additions and 1165 deletions

5
.gitignore vendored
View File

@ -1,5 +1,5 @@
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2016,2017,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2016,2017,2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -64,6 +64,8 @@
/lib/x86-mes/0exit-42
/lib/x86-mes/exit-42
/m2
/lib/tests/*/[0-9a][0-9a-z]-*
!/lib/tests/*/*.c
!/lib/tests/*/*.exit
@ -80,6 +82,7 @@
/scaffold/tiny-mes
/scaffold/argv-m2
/scaffold/env-m2
/scaffold/hello-m2
/scaffold/main-m2
/scaffold/micro-mes-m2

1
.mailmap Normal file
View File

@ -0,0 +1 @@
Janneke Nieuwenhuizen <janneke@gnu.org>

View File

@ -36,6 +36,10 @@ lib/div.c (__mesabi_log2i)
W. J. van der Laan <laanwj@protonmail.com>
Bugfixes for logand, 64bit build, and va_arg
RISC-V port
Andrius Štikonas <andrius@stikonas.eu>
Rewrite the RISC-V port to use new word-based macros.
List of imported files
@ -91,7 +95,7 @@ lib/m2/x86/x86_defs.M1
lib/m2/x86/ELF-x86.hex2
* legalese
Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
Copyright © 2016,2017,2018,2019,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@ -1,7 +1,7 @@
-*- org -*-
#+TITLE: Building and Installing GNU Mes
Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
Copyright © 2016,2017,2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@ -27,12 +27,12 @@ similar way.
*** Other GNU/Linux
- [[https://savannah.gnu.org/projects/mescc-tools/][mescc-tools]], 1.4.0 is known to work.
- [[https://github.com/oriansj/m2-planet][M2-Planet]] (optional), 1.9.0 is known to work.
- [[https://github.com/oriansj/m2-planet][M2-Planet]] (optional), 1.11.0 is known to work.
- [[https://savannah.gnu.org/projects/nyacc][Nyacc]], 1.00.2 is known to work.
- GNU Gcc, 7.5.0 is known to work.
- GNU Guile, version 3.0.4 is know to work.
- GNU Guile, version 3.0.4 is known to work.
- SH, /bin/sh, GNU Bash 5.0.16 is known to work.
- GNU coreutils
- GNU coreutils.
- sed, GNU sed 4.8 is known to work.
** Build it

15
NEWS
View File

@ -10,6 +10,21 @@ Copyright © 2016,2017,2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen <jan
Please send Mes bug reports to bug-mes@gnu.org.
* Changes in 0.25 since 0.24.2
** Core
*** Support for riscv64-linux.
** Build
*** Support M2-Planet build for x86_64-linux.
*** Building with M2-Planet-1.11.0 is now supported.
*** The requirement for M2-Planet's --bootstrap-mode was dropped.
** Noteworthy bug fixes
*** In the REPL, `include', `load', and `,use MODULE' now work.
*** Using mes' `access' with R_OK now respects read permissions.
*** On 64bit, displayed values are no longer truncated.
*** On 64bit, MesCC now correctly supports 8-byte immediate values.
*** MesCC now initializes struct fields to 0.
*** The MesCC test suite passes with gcc >= 10
An array overflow bug was fixed in `63-struct-cell.c'.
* Changes in 0.24.2 since 0.24.1
** Build
*** A number of compile warnings have been fixed.

View File

@ -22,7 +22,9 @@ to your config.scm and run guix system reconfigure.
For example (note: ARM is no longer a 'port', see HACKING)
#+BEGIN_SRC bash
guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git guile gzip help2man make mescc-tools nyacc openssh-sans-x pkg-config sed tar texinfo
guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git-minimal guile gzip help2man make mescc-tools nyacc@1.00.2 openssh-sans-x pkg-config sed tar texinfo
guix shell --system=aarch64-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git-minimal guile gzip help2man m2-planet make mescc-tools nyacc@1.00.2 openssh-sans-x pkg-config sed tar texinfo
guix shell --system=riscv64-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git-minimal guile gzip help2man m2-planet make mescc-tools nyacc@1.00.2 openssh-sans-x pkg-config sed tar texinfo
#+END_SRC
** Try it
@ -75,7 +77,7 @@ a Reduced Binary seed, thus significantly reducing the Trusted Computing
Base (TCB), strategic decisions about the build process can start.
* Legalese
Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]>
Copyright © 2019,2022,2023 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

26
README
View File

@ -4,11 +4,11 @@
#+SUBTITLE: Maxwell Equations of Software
[[https://www.gnu.org/software/mes][GNU Mes]] is a Scheme interpreter and C compiler for bootstrapping the GNU
System. Since version 0.22 it has again helped to halve the size of
opaque, uninspectable binary seeds that are currently being used in the
[[https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25][Further Reduced Binary Seed bootstrap]] of [[https://www.gnu.org/software/guix][GNU Guix]]. The final goal is to
help create a full-source bootstrap as part of the [[https://bootstrappable.org][bootstrappable builds]]
effort for UNIX-like operating systems.
System. It has helped to decimate the number and size of binary seeds
that were used in the bootstrap of [[https://www.gnu.org/software/guix][GNU Guix]] 1.0. Recently, version
0.24.2 has realized the first [[https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/][Full Source Bootstrap]] for Guix. The final
goal is to help create a full source bootstrap as part of the
[[https://bootstrappable.org][bootstrappable builds]] effort for any UNIX-like operating system.
The Scheme interpreter is written in ~5,000 LOC of simple C, and the C
compiler written in Scheme and these are mutual self-hosting. Mes can
@ -20,14 +20,14 @@ R7RS ellipsis, Matt Wette's [[https://www.nongnu.org/nyacc][Nyacc]] --and test s
support a REPL and a C99 compiler: mescc.
Mes + MesCC + Mes C Library can build a [[https://gitlab.com/janneke/tinycc][bootstrappable TinyCC]] that is
self-hosting. Using this tcc and the Mes C library we now have a
Reduced Binary Seed bootstrap for the gnutools triplet: glibc-2.2.5,
self-hosting. Using this bootstrappable-tcc and the Mes C library we
can build an ancient version of the GNU tools triplet: glibc-2.2.5,
binutils-2.20.1, gcc-2.95.3. This is enough to bootstrap Guix for
i686-linux, x86_64-linux, armhf-linux and aarch64-linux.
Mes is inspired by The Maxwell Equations of Software: [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf][LISP-1.5]] -- John
McCarthy page 13, GNU Guix's source/binary packaging transparency and
Jeremiah Orians's [[https://github.com/oriansj/stage0][stage0]] ~500 byte self-hosting hex assembler.
Mes was inspired by The Maxwell Equations of Software: [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf][LISP-1.5]] -- John
McCarthy page 13, Guix's source/binary packaging transparency and
Jeremiah Orians's [[https://github.com/oriansj/stage0][stage0]], a ~500-byte self-hosting hex assembler.
We are very grateful to NLNet for sponsoring the [[https://nlnet.nl/project/GNUMes][Reduced Binary Seed
bootstrap]], the [[https://nlnet.nl/project/GNUMes-arm][ARM port]], and the [[https://nlnet.nl/project/GNUMes-ARM_RISC-V][Full Source Bootstrap.]]
@ -67,8 +67,8 @@ General Public Licence version 3 or later. See the file [[file:COPYING][COPYING
* Links
[0] https://www.gnu.org/software/mes
[1] https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25
[2] https://www.gnu.org/software/guix
[1] https://www.gnu.org/software/guix
[2] https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/
[3] https://bootstrappable.org
[4] https://github.com/oriansj/m2-planet
[5] https://savannah.nongnu.org/projects/mescc-tools
@ -83,7 +83,7 @@ General Public Licence version 3 or later. See the file [[file:COPYING][COPYING
[14] https://nlnet.nl/project/GNUMes-ARM_RISC-V
* Legalese
Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]>
Copyright © 2016,2017,2018,2019,2020,2021,2022,2023 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@ -85,7 +85,7 @@ PHONY_TARGETS:=\
.PHONY: $(PHONY_TARGETS)
X86_ARCH_HEADERS = $(wildcard $(scrdest)include/linux/x86/*.h)
X86_ARCH_HEADERS = $(wildcard $(srcdest)include/linux/x86/*.h)
ARCH_HEADERS = $(X86_ARCH_HEADERS:$(srcdest)include/linux/x86/%=include/arch/%)
default: all
@ -170,10 +170,14 @@ uninstall:
doc/version.texi: ${srcdest}doc/mes.texi GNUmakefile
@mkdir -p $(@D)
(set `LANG= date -r $< +'%d %B %Y'`;\
echo "@set UPDATED $$1 $$2 $$3"; \
echo "@set UPDATED-MONTH $$2 $$3"; \
echo "@set EDITION $(VERSION)"; \
timestamp=$$({ git log --pretty=format:%ct -- $< \
|| date +%s -r $<; } \
| sort -n -r | head -n 1); \
dmy=$$(date --date="@$$timestamp" "+%-d %B %Y"); \
(set `LANG=' \
echo "@set UPDATED $$dmy"; \
echo "@set UPDATED-MONTH $$my"; \
echo "@set EDITION $(VERSION)"; \
echo "@set VERSION $(VERSION)") > $@
doc: doc/version.texi
@ -227,6 +231,10 @@ man: doc/mes.1 doc/mescc.1 doc/mesar.1
%: %.o
%: %.c
# help2man reproducibility
SOURCE_DATE_EPOCH=$(shell git show HEAD --format=%ct --no-patch 2>/dev/null || echo 0)
export SOURCE_DATE_EPOCH
doc/mes.1: src/${program_prefix}mes | build
MES_ARENA=10000000 ./pre-inst-env $(HELP2MAN) \
--name="Scheme interpreter for bootstrapping the GNU system" \
@ -286,7 +294,7 @@ TARBALL_VERSION=$(COMMIT:v%=%)
TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
TARBALL:=$(TARBALL_DIR).tar.gz
# Be friendly to Debian; avoid using EPOCH
MTIME=$(shell git show HEAD --format=%ct --no-patch 2>/dev/null)
MTIME=$(SOURCE_DIR_EPOCH)
# Reproducible tarball
TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s
@ -398,7 +406,7 @@ gen-announce:
$(GEN_ANNOUNCE) \
--release-type=beta \
--package-name=mes \
--previous-version='0.24.1' \
--previous-version='0.24.2' \
--current-version=$(VERSION) \
--gpg-key-id=$(GPG_KEY_ID) \
--url-directory=https://ftp.gnu.org/gnu/mes \

View File

@ -1,7 +1,7 @@
#! @SHELL@
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -54,16 +54,18 @@ AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ../include -I include"
AM_CFLAGS="-L ${srcdest}lib"
mkdir -p $mes_cpu-mes
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c .
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS crt1.c
cp crt1.o $mes_cpu-mes
cp crt1.s $mes_cpu-mes
objects=
for c in $libc_mini_SOURCES; do
o=$(basename $c .c).o
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
o=$b.o
if test ! -e $o -o ${srcdest}$c -nt $o; then
echo " CC $c"
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
fi
objects="$objects $o"
done
@ -72,10 +74,11 @@ $AR crD $mes_cpu-mes/libc-mini.a $objects
objects=
for c in $libmescc_SOURCES; do
o=$(basename $c .c).o
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
o=$b.o
if test ! -e $o -o ${srcdest}$c -nt $o; then
echo " CC $c"
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
fi
objects="$objects $o"
done
@ -84,10 +87,11 @@ $AR crD $mes_cpu-mes/libmescc.a $objects
objects=
for c in $libc_SOURCES; do
o=$(basename $c .c).o
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
o=$b.o
if test ! -e $o -o ${srcdest}$c -nt $o; then
echo " CC $c"
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
fi
objects="$objects $o"
done
@ -96,10 +100,11 @@ $AR crD $mes_cpu-mes/libc.a $objects
objects=
for c in $libc_tcc_SOURCES; do
o=$(basename $c .c).o
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
o=$b.o
if test ! -e $o -o ${srcdest}$c -nt $o; then
echo " CC $c"
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
fi
objects="$objects $o"
done
@ -113,10 +118,11 @@ AM_CFLAGS="-L ${srcdest}lib"
objects=
for c in $mes_SOURCES; do
o=$(basename $c .c).o
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
o=$b.o
if test ! -e $o -o ${srcdest}$c -nt $o; then
echo " CC $c"
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
fi
objects="$objects $o"
done

View File

@ -2,6 +2,7 @@
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
#
# This file is part of GNU Mes.
#
@ -38,6 +39,8 @@ module/mescc/armv4/as.scm
module/mescc/armv4/info.scm
module/mescc/i386/as.scm
module/mescc/i386/info.scm
module/mescc/riscv64/as.scm
module/mescc/riscv64/info.scm
module/mescc/x86_64/as.scm
module/mescc/x86_64/info.scm
module/mescc/info.scm

View File

@ -1,7 +1,7 @@
#! /bin/sh
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -26,7 +26,8 @@
trap 'test -f .log && cat .log' EXIT
mkdir -p $mes_cpu-mes
compile lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c .
compile crt1.c
cp crt1.o $mes_cpu-mes
if test -e crt1.s; then
cp crt1.s $mes_cpu-mes

View File

@ -1,7 +1,7 @@
#! /bin/sh
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2017,2018,2019,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -54,15 +54,9 @@ trace "TEST exit-42"
[ $r != 42 ] && echo " => $r"
[ $r = 42 ]
if $numbered_arch; then
stage0_cpu_flag="--Architecture $stage0_arch";
else
stage0_cpu_flag="--architecture $stage0_cpu";
fi
trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2" $HEX2\
--little-endian\
$stage0_cpu_flag\
--architecture $stage0_cpu\
--base-address 0x1000000\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2\
@ -75,7 +69,7 @@ trace "TEST 0exit-42"
trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2" $HEX2\
--little-endian\
$stage0_cpu_flag\
--architecture $stage0_cpu\
--base-address 0x1000000\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2\
@ -101,7 +95,7 @@ trace "TEST hello-mes"
trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2" $HEX2\
--little-endian\
$stage0_cpu_flag\
--architecture $stage0_cpu\
--base-address 0x1000000\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2\
@ -114,7 +108,7 @@ trace "TEST 0hello-mes"
trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2" $HEX2\
--little-endian\
$stage0_cpu_flag\
--architecture $stage0_cpu\
--base-address 0x1000000\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\
-f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2\

View File

@ -1,7 +1,7 @@
#! /bin/sh
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2018,2019,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -102,7 +102,10 @@ fi
)
if test -n "$M2_PLANET" && (test "$mes_cpu" == "x86" \
|| test "$mes_cpu" == "arm"); then
|| test "$mes_cpu" == "x86_64" \
|| test "$mes_cpu" == "arm" \
|| test "$mes_cpu" == "riscv64" \
); then
(
. ${srcdest}build-aux/trace.sh
if [ -z "$V" -o "$V" = 0 ]; then
@ -113,6 +116,7 @@ if test -n "$M2_PLANET" && (test "$mes_cpu" == "x86" \
trace "KAEM scaffold/main.kaem" kaem --strict $__verbose -f scaffold/main.kaem
trace "KAEM scaffold/hello.kaem" kaem --strict $__verbose -f scaffold/hello.kaem
trace "KAEM scaffold/argv.kaem" kaem --strict $__verbose -f scaffold/argv.kaem
trace "KAEM scaffold/env.kaem" kaem --strict $__verbose -f scaffold/env.kaem
trace "KAEM scaffold/read.kaem" kaem --strict $__verbose -f scaffold/read.kaem
trace "KAEM kaem.run" kaem --strict $__verbose
)
@ -150,7 +154,6 @@ fi
${SHELL} ${srcdest}build-aux/build-lib.sh
${SHELL} ${srcdest}build-aux/build-source-lib.sh
if $bootstrap; then
rm -f globals.* # FIXME: avoid name clash with globals from lib
${SHELL} ${srcdest}build-aux/build-mes.sh
cp -f bin/mes-mescc ../bin
cp -f bin/mes ../bin

View File

@ -1,5 +1,5 @@
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -18,8 +18,12 @@
objects=
compile () {
c=${srcdest}$1
b=$(basename $c .c)
if test $(dirname $1) = "."; then
c=$1
else
c=${srcdest}$1
fi
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
o=$b.o
objects="$objects $o"
if test ! -e $o -o $c -nt $o; then
@ -34,7 +38,7 @@ archive () {
sources="$@"
objects=
for c in $sources; do
b=$(basename $c .c)
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
o=$b.o
compile $c
done

View File

@ -1,5 +1,5 @@
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2018,2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -18,20 +18,24 @@
case "$mes_cpu" in
arm)
stage0_arch=40
cc_cpu=arm
stage0_cpu=armv7l
;;
x86_64)
stage0_arch=2
cc_cpu=x86_64
stage0_cpu=amd64
;;
x86)
stage0_arch=1
cc_cpu=i386
stage0_cpu=x86
;;
riscv64)
cc_cpu=riscv64
stage0_cpu=riscv64
;;
*)
stage0_arch=1
stage0_cpu=$mes_cpu
cc_cpu=$mes_cpu
;;
esac

View File

@ -1,7 +1,9 @@
#! /bin/sh
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2017,2018,2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
# Copyright © 2023 Ekaitz Zarraga <ekaitz@elenq.tech>
#
# This file is part of GNU Mes.
#
@ -46,6 +48,7 @@ lib/tests/scaffold/13-if-neq.c
lib/tests/scaffold/14-if-goto.c
lib/tests/scaffold/15-if-not-f.c
lib/tests/scaffold/16-if-t.c
lib/tests/scaffold/16-cast.c
lib/tests/scaffold/17-compare-char.c
lib/tests/scaffold/17-compare-ge.c
lib/tests/scaffold/17-compare-gt.c
@ -63,6 +66,7 @@ lib/tests/scaffold/17-compare-or.c
lib/tests/scaffold/17-compare-and-or.c
lib/tests/scaffold/17-compare-assign.c
lib/tests/scaffold/17-compare-call.c
lib/tests/scaffold/17-compare-rotated.c
lib/tests/scaffold/18-assign-shadow.c
lib/tests/scaffold/20-while.c
lib/tests/scaffold/21-char-array-simple.c
@ -97,12 +101,14 @@ lib/tests/scaffold/43-for-do-while.c
lib/tests/scaffold/44-switch.c
lib/tests/scaffold/44-switch-fallthrough.c
lib/tests/scaffold/44-switch-body-fallthrough.c
lib/tests/scaffold/44-switch-body-fallthrough-not-default.c
lib/tests/scaffold/45-void-call.c
lib/tests/scaffold/46-function-static.c
lib/tests/scaffold/47-function-expression.c
lib/tests/scaffold/48-global-static.c
lib/tests/assert/50-assert.c
lib/tests/mes/50-itoa.c
lib/tests/scaffold/50-compare-rotated-weird.c
lib/tests/posix/50-getenv.c
lib/tests/stdlib/50-malloc.c
lib/tests/string/50-memcmp.c
@ -132,6 +138,8 @@ lib/tests/scaffold/63-struct-cell.c
lib/tests/scaffold/64-make-cell.c
lib/tests/scaffold/65-read.c
lib/tests/scaffold/66-local-char-array.c
lib/tests/scaffold/67-m1-overflow-check.c
lib/tests/scaffold/68-truncate-shift.c
"
tcc_tests="
@ -190,6 +198,7 @@ lib/tests/scaffold/7u-inc-byte-word.c
lib/tests/scaffold/7u-struct-func.c
lib/tests/scaffold/7u-struct-size10.c
lib/tests/scaffold/7u-vstack.c
lib/tests/scaffold/7v-struct-initialize-zeroes.c
lib/tests/scaffold/70-array-in-struct-init.c
lib/tests/scaffold/70-struct-short-enum-init.c
lib/tests/scaffold/70-struct-post.c
@ -244,8 +253,6 @@ if test $compiler = mescc; then
xfail_tests="$xfail_tests
lib/tests/scaffold/17-compare-unsigned-char-le.c
lib/tests/scaffold/17-compare-unsigned-short-le.c
lib/tests/scaffold/66-local-char-array.c
lib/tests/scaffold/72-typedef-struct-def-local.c
lib/tests/scaffold/70-ternary-arithmetic-argument.c
lib/tests/mes/90-abtod.c
lib/tests/mes/90-dtoab.c
@ -290,6 +297,12 @@ lib/tests/scaffold/70-extern.c
lib/tests/stdio/80-sscanf.c
lib/tests/posix/90-execlp.c
lib/tests/string/90-snprintf.c
"
fi
if test $mes_cpu = riscv64; then
xfail_tests="$xfail_tests
lib/tests/scaffold/70-extern.c
"
fi
fi
@ -298,7 +311,7 @@ fi
if test -n "$bootstrap"; then
TESTS="${TESTS-$mes_tests$tcc_tests}"
else
TESTS="${TESTS-$mes_tests$tcc_test$gnu_tests}"
TESTS="${TESTS-$mes_tests$tcc_tests$gnu_tests}"
fi
# Allow for make check xfail_tests=lib/tests/setjmp/80-setjmp.c

View File

@ -1,5 +1,5 @@
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2018,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -57,7 +57,6 @@ abs_top_srcdir="@abs_top_srcdir@"
arch="@arch@"
build="@build@"
host="@host@"
numbered_arch=${numbered_arch-"@numbered_arch@"}
bootstrap=${bootstrap-@bootstrap@}
compiler=${compiler-@compiler@}
@ -98,6 +97,7 @@ export CC
export DIFF
export SHELL
export V
export cc_cpu
export colors
export compiler
export courageous

View File

@ -1,7 +1,7 @@
#! /bin/sh
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2019,2020,2021,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -30,6 +30,7 @@ fi
. ./config.sh
libc_mini_shared_SOURCES="
lib/mes/__init_io.c
lib/mes/eputs.c
lib/mes/oputs.c
"
@ -74,7 +75,7 @@ libc_mini_SOURCES="$libc_mini_shared_SOURCES"
if test $mes_libc = mes; then
libc_mini_SOURCES="$libc_mini_SOURCES
lib/mes/mini-write.c
lib/mes/write.c
"
fi
@ -215,6 +216,7 @@ lib/linux/malloc.c
lib/linux/_read.c
lib/linux/time.c
lib/linux/unlink.c
lib/linux/wait4.c
lib/linux/waitpid.c
lib/linux/$mes_cpu-mes-$compiler/syscall.c
lib/linux/getpid.c

View File

@ -1,5 +1,5 @@
# GNU Mes --- Maxwell Equations of Software
# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2018,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
#
# This file is part of GNU Mes.
#
@ -43,6 +43,7 @@ export moduledir
export sysconfdir
export bootstrap
export cc_cpu
export compiler
export courageous
export mes_system

View File

@ -48,7 +48,6 @@ sed -ri \
include/mes/mes.h \
include/mes/symbols.h \
include/mes/builtins.h \
include/m2/lib.h \
src/builtins.c \
src/cc.c \
src/core.c \

18
configure vendored
View File

@ -6,6 +6,7 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)'
;;; GNU Mes --- Maxwell Equations of Software
;;; Copyright © 2016,2017,2018,2019,2020,2021,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020 Vagrant Cascadian <vagrant@reproducible-builds.org>
;;; Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
;;;
;;; configure: This file is part of GNU Mes.
;;;
@ -538,12 +539,12 @@ Some influential environment variables:
(mes-cpu (cond ((member mes-cpu '("i386" "i486" "i586" "i686")) "x86")
((member mes-cpu '("arm" "armv4" "armv7l")) "arm")
(else mes-cpu)))
(mes-bits (if (member mes-cpu '("x86_64")) "64"
(mes-bits (if (member mes-cpu '("x86_64" "riscv64")) "64"
"32"))
(mes-libc (if system-libc? "system" "mes"))
(mes-kernel (car (filter
(compose not
(cut member <> '("pc" "portbld" "unknown")))
(cut member <> '("pc" "portbld" "unknown" "redhat")))
(cdr host-type-list))))
(mes-kernel (if (string-prefix? "freebsd" mes-kernel) "freebsd" mes-kernel))
(mes-compiler (cond (gcc? "gcc") (tcc? "gcc") (mescc? "mescc") (else "bootstrap")))
@ -556,12 +557,7 @@ Some influential environment variables:
(and (file-exists? "/bin/sh") "/bin/sh")
(file-name "sh" deps)
"sh"))
(hex2 (file-name "hex2" deps))
(numbered-arch? (begin
(stdout "checking for stage0 architecture flag... ")
(let ((numbered? (and hex2 (string-contains (gulp-pipe (string-append hex2 " --help 2>&1" )) "--Architecture 12345"))))
(stdout (if numbered? "numbered\n" "named\n"))
numbered?))))
(hex2 (file-name "hex2" deps)))
(define* (substitute file-name pairs
#:key (target (if (string-suffix? ".in" file-name)
@ -579,7 +575,9 @@ Some influential environment variables:
(when (and (not (member mes-system '("arm-linux-mes"
"x86-linux-mes"
"x86_64-linux-mes")))
"x86_64-linux-mes"
"riscv32-linux-mes"
"riscv64-linux-mes")))
(not with-courage?))
(stderr "platform not supported: ~a
See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
@ -655,7 +653,6 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "-static -g"))
("@HEX2FLAGS@" . ,(or (getenv "HEX2FLAGS") ""))
("@M1FLAGS@" . ,(or (getenv "M1FLAGS") ""))
("@numbered_arch@" . ,(if numbered-arch? "true" "false"))
,@(map
(lambda (o)
@ -724,7 +721,6 @@ GNU Mes is configured for
libc: " mes-libc "
kernel: " mes-kernel "
system: " mes-system "
tools: " (if numbered-arch? "numbered" "named") " arch
bootstrap: " (if with-bootstrap? "yes" "no") "
courageous: " (if with-courage? "yes" "no") "

View File

@ -99,13 +99,6 @@ else
GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')}
fi
numbered_arch=false
mes_tools=named
if ( $HEX2 --help 2>&1 ) | grep -q "\-\-Architecture 12345"; then
numbered_arch=true
mes_tools=numbered
fi
bindir=$(eval echo ${bindir-$prefix/bin})
datadir=$(eval echo ${datadir-$prefix/share})
docdir=$(eval echo ${docdir-$datadir/doc/mes})
@ -172,7 +165,6 @@ subst () {
-e s,"@M2_PLANET@,$M2_PLANET,"\
-e s,"@KAEM@,$KAEM,"\
-e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\
-e s,"@numbered_arch@,$numbered_arch,"\
-e s,"@SHELL@,$SHELL,"\
$1 > $2
}

View File

@ -10,7 +10,7 @@ Mes has now been ported to M2-Planet and can be bootstrapped using
stage0-posix[0], starting from the 357-byte hex0 binary of the
bootstrap-seeds[1], as was promised at FOSDEM'21[2].
We are exciteda that the NlNet Foundation[4] is again sponsoring this
We are excited that the NlNet Foundation[4] is again sponsoring this
work!
What's next?

View File

@ -61,8 +61,8 @@ Enjoy!
Here are the SHA1 and SHA256 checksums:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.24.2.tar.gz
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.24.2.tar.gz
30b0ce4cd37c87dca37b85a6c19646001881be46 mes-0.24.2.tar.gz
7ddae0854e46ebfa18c13ab37e64839a7b86ea88aeed366a8d017efd11dae86e mes-0.24.2.tar.gz
[*] Use a .sig file to verify that the corresponding file (without the
.sig suffix) is intact. First, be sure to download both the .sig file

108
doc/announce/ANNOUNCE-0.25 Normal file
View File

@ -0,0 +1,108 @@
Subject: GNU Mes 0.25 released
<#secure method=pgpmime mode=sign>
We are happy to announce the release of GNU Mes 0.25!
Although it's been only four months since the previous release, this
release represents 70 commits over two years by five people. This
release brings RISC-V64-linux support.
We are excited that the NLnet Foundation is sponsoring this work!
What's next?
Bringing the Full Source Bootstrap to NixOS. Full Guile compatible
module support, and support for running Gash and Gash-Utils. Support
for bootstrapping gcc-4.6.4, and a Full Source Bootstrap for
armhf-linux, and riscv64-linux.
Enjoy!
* About
GNU Mes is a Scheme interpreter and C compiler for bootstrapping the
GNU System. It has helped to decimate the number and size of binary
seeds that were used in the bootstrap of GNU Guix 1.0. Recently,
version 0.24.2 has realized the first Full Source Bootstrap for Guix
<https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/>.
The final goal is to help create a full source bootstrap as part of
the bootstrappable builds effort <https://bootstrappable.org> for any
UNIX-like operating system.
Mes + MesCC + Mes C Library can build a bootstrappable TinyCC
<https://gitlab.com/janneke/tinycc> that is self-hosting. Using this
bootstrappable-tcc and the Mes C library we can build an ancient
version of the GNU tools triplet: glibc-2.2.5, binutils-2.20.1,
gcc-2.95.3. This is enough to bootstrap Guix for i686-linux,
x86_64-linux, armhf-linux and aarch64-linux.
Mes was inspired by The Maxwell Equations of Software: LISP-1.5 --
John McCarthy page 13, Guix's source/binary packaging transparency and
Jeremiah Orians's Stage0 <https://github.com/oriansj/stage0>, a
~500-byte self-hosting hex assembler.
* Download
git clone git://git.savannah.gnu.org/mes.git
Here are the compressed sources and a GPG detached signature[*]:
https://ftp.gnu.org/gnu/mes/mes-0.25.tar.gz
https://ftp.gnu.org/gnu/mes/mes-0.25.tar.gz.sig
Use a mirror for higher download bandwidth:
https://ftpmirror.gnu.org/mes/mes-0.25.tar.gz
https://ftpmirror.gnu.org/mes/mes-0.25.tar.gz.sig
Here are the SHA1 and SHA256 checksums:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.25.tar.gz
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.25.tar.gz
[*] Use a .sig file to verify that the corresponding file (without the
.sig suffix) is intact. First, be sure to download both the .sig file
and the corresponding tarball. Then, run a command like this:
gpg --verify mes-0.25.tar.gz.sig
If that command fails because you don't have the required public key,
or that public key has expired, try the following commands to update
or refresh it, and then rerun the 'gpg --verify' command.
gpg --recv-keys 1A858392E331EAFDB8C27FFBF3C1A0D9C1D65273
Alternatively, Mes can be installed or updated using Guix:
guix pull
guix install mes
* Changes in 0.25 since 0.24.2
** Core
*** Support for riscv64-linux.
** Build
*** Support M2-Planet build for x86_64-linux.
*** Building with M2-Planet-1.11.0 is now supported.
*** The requirement for M2-Planet's --bootstrap-mode was dropped.
** Noteworthy bug fixes
*** In the REPL, `include', `load', and `,use MODULE' now work.
*** Using mes' `access' with R_OK now respects read permissions.
*** On 64bit, displayed values are no longer truncated.
*** On 64bit, MesCC now correctly supports 8-byte immediate values.
*** MesCC now initializes struct fields to 0.
*** The MesCC test suite passes with gcc >= 10
An array overflow bug was fixed in `63-struct-cell.c'.
Join bug-mes@gnu.org and #bootstrappable on irc.libera.chat for
discussions.
Thanks to everyone who contributed to this release:
7 Andrius Štikonas
1 Efraim Flashner
1 Emily Trau
5 Ekaitz Zarraga
49 Janneke Nieuwenhuizen
15 W. J. van der Laan

View File

@ -1,107 +1,80 @@
digraph "Guix bag" {
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" [label = "gcc-core-mesboot0@2.95.3", shape = box, fontname = sans];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = red];
"/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = red];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" [label = "binutils-mesboot0@2.14", shape = box, fontname = sans];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = cyan3];
"/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = cyan3];
"/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" [label = "bash-mesboot0@2.05b", shape = box, fontname = sans];
"/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = darkgoldenrod];
"/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = darkgoldenrod];
"/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkgoldenrod];
"/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkgoldenrod];
"/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkgoldenrod];
"/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkgoldenrod];
"/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [label = "make-mesboot0@3.80", shape = box, fontname = sans];
"/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = magenta];
"/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = magenta];
"/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = magenta];
"/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = magenta];
"/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = magenta];
"/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [label = "tcc-boot0@0.9.26-1103-g6e62e0e", shape = box, fontname = sans];
"/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" [color = darkseagreen];
"/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/a6nbjivhxp65wqj5s8rz0fnmwzqxmhry-bootstrap-mescc-tools-0.5.2.drv" [color = darkseagreen];
"/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkseagreen];
"/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkseagreen];
"/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkseagreen];
"/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkseagreen];
"/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" [label = "mes-boot@0.22", shape = box, fontname = sans];
"/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" [color = peachpuff4];
"/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/a6nbjivhxp65wqj5s8rz0fnmwzqxmhry-bootstrap-mescc-tools-0.5.2.drv" [color = peachpuff4];
"/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = peachpuff4];
"/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = peachpuff4];
"/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = peachpuff4];
"/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = peachpuff4];
"/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" [label = "bootstrap-mes-rewired@0.19", shape = box, fontname = sans];
"/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" -> "/gnu/store/r7bbw2ywmgqp6m5a1hp0fs4lhc51w3sq-bootstrap-mes-0.drv" [color = cyan3];
"/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = cyan3];
"/gnu/store/r7bbw2ywmgqp6m5a1hp0fs4lhc51w3sq-bootstrap-mes-0.drv" [label = "bootstrap-mes@0", shape = box, fontname = sans];
"/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [label = "gash-boot@0.2.0", shape = box, fontname = sans];
"/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkviolet];
"/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkviolet];
"/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [label = "bootar@1a", shape = box, fontname = sans];
"/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue];
"/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [label = "guile-bootstrap@2.0", shape = box, fontname = sans];
"/gnu/store/a6nbjivhxp65wqj5s8rz0fnmwzqxmhry-bootstrap-mescc-tools-0.5.2.drv" [label = "bootstrap-mescc-tools@0.5.2", shape = box, fontname = sans];
"/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [label = "gash-utils-boot@0.1.0", shape = box, fontname = sans];
"/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = blue];
"/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = blue];
"/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue];
"/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [label = "bzip2-mesboot@1.0.8", shape = box, fontname = sans];
"/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = blue];
"/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = blue];
"/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = blue];
"/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = blue];
"/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = blue];
"/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue];
"/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" [label = "gzip-mesboot@1.2.4", shape = box, fontname = sans];
"/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = red];
"/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = red];
"/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = red];
"/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = red];
"/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = red];
"/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" [label = "patch-mesboot@2.5.9", shape = box, fontname = sans];
"/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = darkseagreen];
"/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = darkseagreen];
"/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkseagreen];
"/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkseagreen];
"/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkseagreen];
"/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkseagreen];
"/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" [label = "sed-mesboot0@1.18", shape = box, fontname = sans];
"/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = darkgoldenrod];
"/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = darkgoldenrod];
"/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkgoldenrod];
"/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkgoldenrod];
"/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkgoldenrod];
"/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkgoldenrod];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" [label = "tcc-boot@0.9.27", shape = box, fontname = sans];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [color = blue];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = blue];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = blue];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = blue];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = blue];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = blue];
"/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" [label = "gcc-core-mesboot0@2.95.3", shape = box, fontname = sans];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkgoldenrod];
"/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" [label = "binutils-mesboot0@2.20.1a", shape = box, fontname = sans];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkgoldenrod];
"/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkgoldenrod];
"/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" [label = "gzip-mesboot@1.2.4", shape = box, fontname = sans];
"/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = peachpuff4];
"/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = peachpuff4];
"/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = peachpuff4];
"/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = peachpuff4];
"/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = peachpuff4];
"/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [label = "tcc-boot0@0.9.26-1136-g5bba73cc", shape = box, fontname = sans];
"/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" [color = cyan3];
"/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" [color = cyan3];
"/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = cyan3];
"/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = cyan3];
"/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = cyan3];
"/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = cyan3];
"/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" [label = "mes-boot@0.24.2", shape = box, fontname = sans];
"/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" [color = darkseagreen];
"/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkseagreen];
"/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkseagreen];
"/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkseagreen];
"/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkseagreen];
"/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" [label = "stage0-posix@1.4", shape = box, fontname = sans];
"/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/7zxbgnrnhvm7g8bz1m5knpsbdfxzxl9g-bootstrap-seeds-1.0.0.drv" [color = darkviolet];
"/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkviolet];
"/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkviolet];
"/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkviolet];
"/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkviolet];
"/gnu/store/7zxbgnrnhvm7g8bz1m5knpsbdfxzxl9g-bootstrap-seeds-1.0.0.drv" [label = "bootstrap-seeds@1.0.0", shape = ellipse, fontname = sans];
"/gnu/store/7zxbgnrnhvm7g8bz1m5knpsbdfxzxl9g-bootstrap-seeds-1.0.0.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkgoldenrod];
"/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [label = "bootar@1b", shape = box, fontname = sans];
"/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = peachpuff4];
"/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [label = "guile-bootstrap@2.0", shape = ellipse, fontname = sans];
"/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [label = "gash-boot@0.3.0", shape = box, fontname = sans];
"/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkseagreen];
"/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkseagreen];
"/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [label = "gash-utils-boot@0.2.0", shape = box, fontname = sans];
"/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkviolet];
"/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkviolet];
"/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkviolet];
"/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" [label = "patch-mesboot@2.5.9", shape = box, fontname = sans];
"/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = blue];
"/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = blue];
"/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = blue];
"/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = blue];
"/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = blue];
"/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = blue];
"/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [label = "make-mesboot0@3.80", shape = box, fontname = sans];
"/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = dimgrey];
"/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = dimgrey];
"/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = dimgrey];
"/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = dimgrey];
"/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = dimgrey];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" [label = "tcc-boot@0.9.27", shape = box, fontname = sans];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" [color = blue];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = blue];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = blue];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = blue];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = blue];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = blue];
"/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = blue];
}

View File

@ -13,7 +13,7 @@
@set OPENPGP-SIGNING-KEY-ID 1A858392E331EAFDB8C27FFBF3C1A0D9C1D65273
@copying
Copyright @copyright{} 2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen@*
Copyright @copyright{} 2018,2019,2020,2021,2022,2023 Jan (janneke) Nieuwenhuizen@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@ -93,7 +93,11 @@ Bootstrapping
* The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk.
* Invoking mes:: Running Mes, a minimalist Guile lookalike.
* Invoking mescc:: Running the MesCC bootstrap compiler.
* Invoking mesar::
* Invoking mesar:: Running the MesCC bootstrap archiver.
The Mes Bootstrap Process
* Full Source Bootstrap Deployments::
Invoking mes
@ -156,8 +160,8 @@ essential freedoms:
@item
The freedom to study how the program works, and change it so it does
your computing as you wish (freedom 1). Access to the source code is
a precondition for this.
your computing as you wish (freedom 1). Access to the source code
is a precondition for this.
@item
The freedom to redistribute copies so you can help others (freedom
@ -165,8 +169,8 @@ essential freedoms:
@item
The freedom to distribute copies of your modified versions to others
(freedom 3). By doing this you can give the whole community a chance
to benefit from your changes. Access to the source code is a
(freedom 3). By doing this you can give the whole community a
chance to benefit from your changes. Access to the source code is a
precondition for this.
@end enumerate
@end quotation
@ -325,12 +329,21 @@ from source.
@node Full Source Bootstrap
@section Full Source Bootstrap
@quotation
The holy grail for bootstrappability will be connecting @code{hex0} to
@code{mes}.
@author Carl Dong
@end quotation
Reduction of binary seeds is great, but there is an obvious target: we
cannot allow any binary seeds in our software stack. Not even in the
bootstrap binary seed. Maybe that is a bit too strong: we want to have
the absolute minimum of binary seeds and all binary seeds need to be
inspectable and must be reviewed. How big would the absolute minimal
set be?
set be? During the Guix 1.5 development series we managed to close the
gap between @code{stage0-posix} and @code{mes}. We refer to this as the
@emph{Full-Source Bootstrap}.
@menu
* Stage0:: The Magical Self-Hosting Hex Assembler.
@ -565,7 +578,7 @@ The following dependencies are optional:
@itemize
Support for building the bootstrap @file{bin/mes-m2} depends on
@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.9.0.
@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.11.0.
@end itemize
@cindex Guile, compatibility
@ -595,7 +608,7 @@ Bootstrapping Mes depends on the following packages:
@itemize
@item a POSIX-compatible shell
@item @url{https://savannah.gnu.org/projects/mescc-tools/, mescc-tools}, version 1.4.0,
@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.9.0.
@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.11.0.
@item @url{https://savannah.gnu.org/projects/nyacc/, NYACC}, version 1.00.2,
@end itemize
@ -684,17 +697,17 @@ responsibility.
* The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk.
* Invoking mes:: Running Mes, a minimalist Guile lookalike.
* Invoking mescc:: Running the MesCC bootstrap compiler.
* Invoking mesar::
* Invoking mesar:: Running the MesCC bootstrap archiver.
@end menu
@node The Mes Bootstrap Process
@section The Mes Bootstrap Process
The Reduced Binary Seed bootstrap currently adopted by Guix@footnote{See
The Full Source Bootstrap currently adopted by Guix@footnote{See
@file{gnu/packages/commencement.scm} in the @var{master} branch in Guix
git
@url{https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/commencement.scm}}.
In its intiial form it is only available for x86-linux and armhf-linux.
In its intiial form it is only available for x86-linux.
Currently, it goes like this:
@ -702,48 +715,48 @@ Currently, it goes like this:
gcc-mesboot (4.9.4)
^
|
glibc-mesboot (2.16.0)
(...)
^
|
gcc-mesboot1 (4.7.4)
binutils-mesboot (2.20.1a), glibc-mesboot (2.2.5),
gcc-core-mesboot (2.95.3)
^
|
binutils-mesboot (2.20.1a)
patch-mesboot (2.5.9)
^
|
gcc-mesboot0 (2.95.3)
bootstrappable-tcc (0.9.26+31 patches)
^
|
glibc-mesboot0 (2.2.5)
gnu-make-mesboot0 (3.80)
^
|
gcc-core-mesboot (2.95.3)
gzip-mesboot (1.2.4)
^
|
make-mesboot0, diffutils-mesboot, binutils-mesboot0 (2.20.1a)
tcc-boot (0.9.27)
^
|
tcc-boot
mes-boot (0.24.2)
^
|
tcc-boot0
stage0-posix (hex0..M2-Planet)
^
|
mes-boot
gash-boot, gash-utils-boot
^
|
*
gash-boot, gash-utils-boot
^
|
*
bootstrap-mescc-tools, bootstrap-mes (~12 MiB)
bootstrap-guile (~48 MiB)
bootstrap-seeds (357-bytes for x86)
~~~
[bootstrap-guile-2.0.9 driver (~25 MiB)]
@end verbatim
@c This graph is generated from wip-bootstrap, doing:
@c This graph is generated from Guix master, doing:
@c guix graph --type=bag -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' > doc/images/gcc-mesboot-graph.dot
@c guix graph --type=bag -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' \
@c | sed -re 's,((bootstrap-seeds|guile-bootstrap).*shape =) box,\1 ellipse,' \
@c > doc/images/gcc-mesboot-graph.dot
@c dot -T png doc/images/gcc-mesboot-graph.dot > doc/images/gcc-mesboot-graph.png
Here's a generated dependency diagram to for the initial bootstrap gcc
@ -751,12 +764,6 @@ that builds the rest of Guix.
@image{images/gcc-mesboot-graph,6in,,Reference graph of the gcc-core-mesboot0}
Work is ongoing to remove these binary seeds that were intentionally
injected by our own doing as temporary shortcut
@example
bootstrap-mescc-tools (seed), bootstrap-mes (seed)
@end example
For now, this additional non-bootstrapped dependencies (i.e., binary
seeds) are taken for granted
@ -764,7 +771,53 @@ seeds) are taken for granted
bootstrap-guile
@end example
Our next priority is to eleminate these one by one.
Our next priority is to eleminate the dependency on
@code{bootstrap-guile} for @code{Gash} and @code{Gash-Utils}, and thus
for @code{Mes}.
@menu
* Full Source Bootstrap Deployments::
@end menu
@node Full Source Bootstrap Deployments
@subsection Full Source Bootstrap Deployments
@table @code
@item GNU Guix
Reference implementation of the Full Source Bootstrap for
@code{i686-linux} and @code{x86_64-linux}
@url{https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/,Guix FSB, building from source all the way down}.
@item Bitcoin Core
The first application of Guix' Reduced Binary Seed Bootstrap was done in
bitcoin core
@url{https://github.com/bitcoin/bitcoin/blob/master/contrib/guix/README.md,
Bootstrappable Bitcoin Core Builds}.
@item Live Bootstrap
The @url{https://github.com/fosslinux/live-bootstrap/,live-bootstrap}
has no dependency on @code{guile-bootstrap}, and removes and bootstraps
generated autotools and flex/bison files.
@item Freedesktop SDK
The Freedesktop SDK used to have an informal dependency on its previous
version being installed in binary from. This dependency was mostly
broken in
@url{https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/merge_requests/11557,
bootstrap freedesktop binary seed}, they still have a dependency on
binary Rust.
@item Full Source Bootstrap from Git
Building on the Live Bootstrap, but building most everything from Git
@url{https://github.com/schierlm/FullSourceBootstrapFromGit, FSB from Git}.
@item NixOS
Implementation of a FSB has started
@url{https://github.com/NixOS/nixpkgs/pull/227914,NixOS 256b bootstrap
(in progress)}.
@end table
@node Invoking mes
@section Invoking mes

View File

@ -31,6 +31,7 @@
#:use-module (gnu packages commencement)
#:use-module (gnu packages cross-base)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gdb)
#:use-module (gnu packages graphviz)
#:use-module (gnu packages guile)
#:use-module (gnu packages man)
@ -66,8 +67,9 @@
(base32
"0z2ni2qn2np1walcaqlxz8sinzb78d4hiq9glddzf26wxc226hs4"))))
(build-system gnu-build-system)
(supported-systems
'("aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux"))
(supported-systems '("i686-linux" "x86_64-linux"
"armhf-linux" "aarch64-linux"
"riscv32-linux" "riscv64-linux"))
(native-inputs (list which))
(arguments
`(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
@ -85,35 +87,41 @@ get_machine.")
(license gpl3+)))
(define-public m2-planet
(package
(name "m2-planet")
(version "1.9.0")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/oriansj/m2-planet")
(commit (string-append "Release_" version))
(recursive? #t))) ;for M2libc
(file-name (git-file-name name version))
(sha256
(base32
"0cgvvq91cbxxm93k8ayyvhpaf3c2lv10qw4wyqwn3hc1qb1cfyvr"))))
(native-inputs (list mescc-tools))
(build-system gnu-build-system)
(arguments
`(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
(string-append "CC=" ,(cc-for-target)))
#:tests? #f
#:phases (modify-phases %standard-phases
(delete 'bootstrap)
(delete 'configure))))
(synopsis "The PLAtform NEutral Transpiler")
(description
"M2-Planet, The PLAtform NEutral Transpiler, when combined with
(let ((version "1.10.0")
(revision "1")
(commit "c82fb8c3530e93fd49efe60da785ffff827ea4d"))
(package
(name "m2-planet")
(version (git-version version revision commit))
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/oriansj/m2-planet")
(commit commit)
(recursive? #t))) ;for M2libc
(file-name (git-file-name name version))
(sha256
(base32
"1fy6ll8z96y6xzyi7zfgsn07rxxvfm600i8f8vwc57266a3sds9j"))))
(native-inputs (list mescc-tools))
(build-system gnu-build-system)
(supported-systems '("i686-linux" "x86_64-linux"
"armhf-linux" "aarch64-linux"
"riscv32-linux" "riscv64-linux"))
(arguments
`(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
(string-append "CC=" ,(cc-for-target)))
#:tests? #f
#:phases (modify-phases %standard-phases
(delete 'bootstrap)
(delete 'configure))))
(synopsis "The PLAtform NEutral Transpiler")
(description
"M2-Planet, The PLAtform NEutral Transpiler, when combined with
mescc-tools compiles a subset of the C language into working binaries
with introspective steps inbetween.")
(home-page "https://github.com/oriansj/m2-planet")
(license gpl3+)))
(home-page "https://github.com/oriansj/m2-planet")
(license gpl3+))))
(define-public nyacc-0.99
(package
@ -238,7 +246,7 @@ Guile.")
(license gpl3+)))
(define-public mes.git
(let ((version #!mes!# "0.24.2")
(let ((version #!mes!# "0.24.2")
(revision "0")
(commit (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ))))
(package
@ -247,4 +255,7 @@ Guile.")
(version (string-append version "-" revision "." (string-take commit 7)))
(source (local-file %source-dir
#:recursive? #t
#:select? (git-predicate %source-dir))))))
#:select? (git-predicate %source-dir)))
(native-inputs
`(("gdb" ,gdb)
,@(package-native-inputs mes))))))

View File

@ -1,6 +1,8 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Emily Trau <emily@downunderctf.com>
*
* This file is part of GNU Mes.
*
@ -40,12 +42,17 @@
#define O_APPEND 0x400
#ifdef __arm__
#define O_DIRECTORY 0x4000
/*#define O_DIRECT 0x10000*/
#define O_DIRECTORY 0x4000
#define O_TMPFILE 0x404000
#else
#define O_DIRECTORY 0x10000
#define O_DIRECTORY 0x10000
#define O_TMPFILE 0x410000
#endif
#define AT_FDCWD -100
#define AT_SYMLINK_NOFOLLOW 0x100
#define AT_REMOVEDIR 0x200
#elif __GNU__
#define O_RDONLY 1
#define O_WRONLY 2
@ -69,8 +76,11 @@
#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode)
int dup (int old);
int dup2 (int old, int new);
#if !__M2__
int fcntl (int filedes, int command, ...);
int open (char const *s, int flags, ...);
#endif
#endif // ! SYSTEM_LIBC

111
include/linux/SYSCALLS Normal file
View File

@ -0,0 +1,111 @@
#+COMMENT: -*- org -*-
#+TITLE: Linux System Calls
|---------------+----------+-----+--------+-----+---------|
| name | old | x86 | x86_64 | arm | riscv64 |
|---------------+----------+-----+--------+-----+---------|
| libc-mini | | | | | |
|---------------+----------+-----+--------+-----+---------|
| exit | | 1 | 60 | 1 | 1 |
| write | | 4 | 1 | 4 | 4 |
|---------------+----------+-----+--------+-----+---------|
| libc | | | | | |
|---------------+----------+-----+--------+-----+---------|
| fork | | 2 | 57 | 2 | 2 |
| read | | 3 | 0 | 3 | 3 |
| open | | 5 | 2 | 5 | 5 |
| waitpid | | 7 | | | |
| wait4 | waitpid | 114 | 61 | 114 | 114 |
| execve | | 11 | 59 | 11 | 11 |
| chmod | | 15 | 90 | 15 | 15 |
| access | | 33 | 21 | 33 | 33 |
| brk | | 45 | 12 | 45 | 45 |
| ioctl | | 54 | 16 | 54 | 54 |
| fsync | | 118 | 74 | 118 | 118 |
| getcwd | | 183 | 79 | 183 | 183 |
| dup | | 41 | 32 | 41 | 41 |
| dup2 | | 63 | 33 | 63 | 63 |
| unlink | | 10 | 87 | 10 | 10 |
| gettimeofday | time | 78 | 96 | 78 | 78 |
| clock_gettime | | 265 | 228 | 263 | 260 |
| time | | 13 | 201 | 13 | |
|---------------+----------+-----+--------+-----+---------|
| libc+tcc | | | | | |
|---------------+----------+-----+--------+-----+---------|
| close | | 6 | 3 | 6 | 6 |
| lseek | | 19 | 8 | 19 | 19 |
| rmdir | | 40 | 84 | 40 | 40 |
| stat | | 106 | 4 | 106 | 106 |
|---------------+----------+-----+--------+-----+---------|
| libc+GNU | | | | | |
|---------------+----------+-----+--------+-----+---------|
| chdir | | 12 | 80 | 12 | 12 |
| link | | 9 | 86 | 9 | 9 |
| getpid | | 20 | 39 | 20 | 20 |
| getuid | | 24 | 102 | 24 | 199 |
| kill | | 37 | 62 | 37 | 37 |
| rename | | 38 | 82 | 38 | 38 |
| mkdir | | 39 | 83 | 39 | 39 |
| pipe | | 42 | 22 | 42 | 42 |
| getgid | | 47 | 104 | 47 | 200 |
| signal | | 48 | | | 48 |
| sigaction | | 67 | | 67 | 67 |
| rt_sigaction | | 174 | 13 | 174 | 174 |
| signal | | 48 | | | 48 |
| fcntl | | 55 | 72 | 55 | 55 |
| getrusage | | 77 | 98 | 77 | 77 |
| lstat | | 107 | 6 | 107 | 107 |
| setitimer | | 104 | 38 | 104 | 104 |
| fstat | | 108 | 5 | 108 | 108 |
| nanosleep | | 162 | 35 | 162 | 162 |
| getdents | | 141 | 78 | 141 | 141 |
|---------------+----------+-----+--------+-----+---------|
| GNU+bash | | | | | |
|---------------+----------+-----+--------+-----+---------|
| setuid | | 23 | 105 | 23 | 213 |
| geteuid | | 49 | 107 | 49 | 201 |
| getegid | | 50 | 108 | 50 | 202 |
| setgid | | 46 | 106 | 46 | 214 |
| getppid | | 64 | 110 | 64 | 64 |
|---------------+----------+-----+--------+-----+---------|
| GNU+make | | | | | |
|---------------+----------+-----+--------+-----+---------|
| sigprocmask | | 126 | | 126 | 126 |
|---------------+----------+-----+--------+-----+---------|
| GNU+tar | | | | | |
|---------------+----------+-----+--------+-----+---------|
| symlink | | 83 | 88 | 83 | 83 |
| readlink | | 85 | 89 | 85 | 85 |
| mknod | | 14 | 133 | 14 | 14 |
|---------------+----------+-----+--------+-----+---------|
| new | | | | | |
|---------------+----------+-----+--------+-----+---------|
| clone | fork | 120 | 56 | 120 | 120 |
| getdents64 | getdents | 220 | 217 | 217 | 220 |
| openat | open | 295 | 257 | 322 | 288 |
| mkdirat | mkdir | 296 | 258 | 323 | 289 |
| mknodat | mknod | 297 | 259 | 324 | 290 |
| unlinkat | rmdir | 301 | 263 | 328 | 294 |
| unlinkat | unlink | 301 | 263 | 328 | 294 |
| renameat | rename | 302 | 264 | 329 | 295 |
| linkat | link | 303 | 265 | 330 | 296 |
| symlinkat | symlink | 304 | 266 | 331 | 297 |
| readlinkat | readlink | 305 | 267 | 332 | 298 |
| fchmodat | chmod | 306 | 268 | 333 | 299 |
| faccessat | access | 307 | 269 | 334 | 300 |
| dup3 | dup2 | 330 | 292 | 358 | 326 |
| pipe2 | pipe | 331 | 293 | 359 | 325 |
|---------------+----------+-----+--------+-----+---------|
* Sources
https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl
https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_32.tbl
https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_64.tbl
* Legalese
Copyright © 2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

View File

@ -18,54 +18,39 @@
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
/* Commentary:
* See https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl
*
* Code:
*/
#ifndef __MES_LINUX_ARM_SYSCALL_H
#define __MES_LINUX_ARM_SYSCALL_H 1
/* See https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl */
/* libc-mini */
#ifndef SYS_exit
// CONSTANT SYS_exit 0x01
#define SYS_exit 0x01
#endif
#ifndef SYS_write
// CONSTANT SYS_write 0x04
#define SYS_write 0x04
#endif
/* libc */
// CONSTANT SYS_fork 0x02
#define SYS_fork 0x02
// CONSTANT SYS_read 0x03
#define SYS_read 0x03
// CONSTANT SYS_open 0x05
#define SYS_open 0x05
//#define SYS_waitpid
// CONSTANT SYS_wait4 0x72
#define SYS_wait4 0x72
// CONSTANT SYS_execve 0x0b
#define SYS_execve 0x0b
// CONSTANT SYS_chmod 0x0f
#define SYS_chmod 0x0f
// CONSTANT SYS_access 0x21
#define SYS_access 0x21
// CONSTANT SYS_brk 0x2d
#define SYS_brk 0x2d
// CONSTANT SYS_ioctl 0x36
#define SYS_ioctl 0x36
// CONSTANT SYS_fsync 0x76
#define SYS_fsync 0x76
// CONSTANT SYS_getcwd 0xb7
#define SYS_getcwd 0xb7
// CONSTANT SYS_dup 0x29
#define SYS_dup 0x29
// CONSTANT SYS_dup2 0x3f
#define SYS_dup2 0x3f
// CONSTANT SYS_unlink 0x0a
#define SYS_unlink 0x0a
// CONSTANT SYS_gettimeofday 0x4e
#define SYS_gettimeofday 0x4e
// CONSTANT SYS_clock_gettime 0x107
#define SYS_clock_gettime 0x107
/* libc+tcc */

View File

@ -0,0 +1,46 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
#ifndef __MES_LINUX_RISCV32_KERNEL_STAT_H
#define __MES_LINUX_RISCV32_KERNEL_STAT_H 1
// *INDENT-OFF*
struct stat
{
unsigned long st_dev;
unsigned long st_ino;
unsigned short st_mode;
unsigned short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
unsigned long st_rdev;
long st_size; /* Linux: unsigned long; glibc: off_t (i.e. signed) */
unsigned long st_blksize;
unsigned long st_blocks;
time_t st_atime; /* Linux: unsigned long; glibc: time_t */
unsigned long st_atime_usec;
time_t st_mtime; /* Linux: unsigned long; glibc: time_t */
unsigned long st_mtime_usec;
time_t st_ctime; /* Linux: unsigned long; glibc: time_t */
unsigned long st_ctime_usec;
unsigned long __foo0;
unsigned long __foo1;
};
#endif // __MES_LINUX_RISCV32_KERNEL_STAT_H

View File

@ -0,0 +1,46 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
#ifndef __MES_LINUX_RISCV64_KERNEL_STAT_H
#define __MES_LINUX_RISCV64_KERNEL_STAT_H 1
// *INDENT-OFF*
struct stat
{
unsigned long st_dev;
unsigned long st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned int st_uid;
unsigned int st_gid;
unsigned long st_rdev;
long st_size;
unsigned long st_blksize;
unsigned long st_blocks;
time_t st_atime;
unsigned long st_atime_usec;
time_t st_mtime;
unsigned long st_mtime_usec;
time_t st_ctime;
unsigned long st_ctime_usec;
unsigned long __foo0;
unsigned long __foo1;
};
#endif // __MES_LINUX_RISCV64_KERNEL_STAT_H

View File

@ -0,0 +1,101 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#ifndef __MES_LINUX_RISCV_SYSCALL_H
#define __MES_LINUX_RISCV_SYSCALL_H 1
/** RISC-V uses the asm-generic syscalls (asm-generic/unistd.h) with the
following configuration for 64-bit:
* #define __ARCH_WANT_NEW_STAT
* #define __ARCH_WANT_SET_GET_RLIMIT
* #define __ARCH_WANT_SYS_CLONE3
*/
#define MAKESTRING(s) #s
#define MAKESTRING2(s) MAKESTRING (rd_a7 ! ## s addi)
#define RISCV_SYSCALL(s) MAKESTRING2 (s)
// libc-mini
#ifndef SYS_exit
#define SYS_exit 93
#endif
#ifndef SYS_write
#define SYS_write 64
#endif
// libc
#define SYS_clone 220
#define SYS_read 63
#define SYS_openat 56
#define SYS_wait4 260
#define SYS_execve 221
#define SYS_fchmodat 53
#define SYS_faccessat 48
#define SYS_brk 214
#define SYS_ioctl 29
#define SYS_fsync 82
// libc+tcc
#define SYS_close 57
#define SYS_lseek 62
#define SYS_unlinkat 35
#define SYS_gettimeofday 169
#define SYS_getcwd 17
// libc+gnu
#define SYS_chdir 49
#define SYS_linkat 37
#define SYS_getpid 172
#define SYS_getuid 174
#define SYS_kill 129
#define SYS_renameat2 276
#define SYS_mkdirat 34
#define SYS_dup 23
#define SYS_pipe2 59
#define SYS_getgid 176
#define SYS_rt_sigaction 134
#define SYS_fcntl 25
#define SYS_dup3 24
#define SYS_getrusage 165
#define SYS_newfstatat 79
#define SYS_setitimer 103
#define SYS_fstat 80
#define SYS_nanosleep 101
#define SYS_getdents64 61
#define SYS_clock_gettime 113
// bash
#define SYS_setuid 146
#define SYS_geteuid 175
#define SYS_getegid 177
#define SYS_setgid 144
#define SYS_getppid 173
// make+POSIX
#define SYS_rt_sigprocmask 135
// tar
#define SYS_symlinkat 36
#define SYS_readlinkat 78
#define SYS_mknodat 33
#endif // __MES_LINUX_RISCV_SYSCALL_H

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -26,6 +27,7 @@ long _sys_call1 (long sys_call, long one);
long _sys_call2 (long sys_call, long one, long two);
long _sys_call3 (long sys_call, long one, long two, long three);
long _sys_call4 (long sys_call, long one, long two, long three, long four);
long _sys_call5 (long sys_call, long one, long two, long three, long four, long five);
long _sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six);
#endif //__MES_SYSCALL_H

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -17,55 +17,40 @@
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
/* Commentary:
* See https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_32.tbl
*
* Code:
*/
#ifndef __MES_LINUX_X86_SYSCALL_H
#define __MES_LINUX_X86_SYSCALL_H 1
/* libc-mini */
#ifndef SYS_exit
// CONSTANT SYS_exit 0x01
#define SYS_exit 0x01
#endif
#ifndef SYS_write
// CONSTANT SYS_write 0x04
#define SYS_write 0x04
#endif
/* libc */
// CONSTANT SYS_fork 0x02
#define SYS_fork 0x02
// CONSTANT SYS_read 0x03
#define SYS_read 0x03
// CONSTANT SYS_open 0x05
#define SYS_open 0x05
// CONSTANT SYS_waitpid 0x07
#define SYS_waitpid 0x07
// CONSTANT SYS_wait4 0x72
#define SYS_wait4 0x72
// CONSTANT SYS_execve 0x0b
#define SYS_execve 0x0b
// CONSTANT SYS_chmod 0x0f
#define SYS_chmod 0x0f
// CONSTANT SYS_access 0x21
#define SYS_access 0x21
// CONSTANT SYS_brk 0x2d
#define SYS_brk 0x2d
// CONSTANT SYS_ioctl 0x36
#define SYS_ioctl 0x36
// CONSTANT SYS_fsync 0x76
#define SYS_fsync 0x76
// CONSTANT SYS_getcwd 0xb7
#define SYS_getcwd 0xb7
// CONSTANT SYS_dup 0x29
#define SYS_dup 0x29
// CONSTANT SYS_dup2 0x3f
#define SYS_dup2 0x3f
// CONSTANT SYS_unlink 0x0a
#define SYS_unlink 0x0a
// CONSTANT SYS_gettimeofday 0x4e
#define SYS_gettimeofday 0x4e
// CONSTANT SYS_clock_gettime 0x109
#define SYS_clock_gettime 0x109
// CONSTANT SYS_time 0x0d
#define SYS_time 0x0d
/* libc+tcc */

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -17,12 +17,21 @@
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
/* Commentary:
* See https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_64.tbl
*
* Code:
*/
#ifndef __MES_LINUX_X86_64_SYSCALL_H
#define __MES_LINUX_X86_64_SYSCALL_H 1
// libc-mini
// #define SYS_write 0x01
// #define SYS_exit 0x3c
#ifndef SYS_write
#define SYS_write 0x01
#endif
#ifndef SYS_exit
#define SYS_exit 0x3c
#endif
// libc
#define SYS_fork 0x39
@ -36,16 +45,19 @@
#define SYS_brk 0x0c
#define SYS_ioctl 0x10
#define SYS_fsync 0x4a
#define SYS_getcwd 0x4f
#define SYS_dup 0x20
#define SYS_dup2 0x21
#define SYS_unlink 0x57
#define SYS_gettimeofday 0x60
#define SYS_clock_gettime 0xe4
#define SYS_time 0xc9
// libc+tcc
#define SYS_close 0x03
#define SYS_time 0xc9
#define SYS_lseek 0x08
#define SYS_unlink 0x57
#define SYS_rmdir 0x54
#define SYS_gettimeofday 0x60
#define SYS_stat 0x04
#define SYS_getcwd 0x4f
// libc+gnu
#define SYS_chdir 0x50
@ -55,20 +67,17 @@
#define SYS_kill 0x3e
#define SYS_rename 0x52
#define SYS_mkdir 0x53
#define SYS_dup 0x20
#define SYS_pipe 0x16
#define SYS_getgid 0x68
#define SYS_rt_sigaction 0x0d
#define SYS_rt_sigreturn 0x0f
#define SYS_fcntl 0x48
#define SYS_dup2 0x21
#define SYS_getrusage 0x62
#define SYS_lstat 0x06
#define SYS_setitimer 0x26
#define SYS_fstat 0x05
#define SYS_nanosleep 0x33
#define SYS_getdents 0x4e
#define SYS_clock_gettime 0xe4
// bash
#define SYS_setuid 0x69

View File

@ -1,70 +0,0 @@
/*
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2019 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/>.
*/
#ifndef __M2_LIB_H
#define __M2_LIB_H
char **environ;
int __stdin;
int __stdout;
int __stderr;
int errno;
// CONSTANT EOF 0xffffffff
// CONSTANT __FILEDES_MAX 512
char* cast_intp_to_charp (int *i);
char* cast_long_to_charp (long i);
long cast_charp_to_long (char const *);
long cast_int_to_long (int i);
long cast_voidp_to_long (void const *);
char *itoa (int number);
char *ltoa (long number);
int __ungetc_p (int filedes);
int eputs (char *s);
int oputs (char *s);
int puts (char *s);
size_t strlen (char *s);
ssize_t _write ();
ssize_t write (int filedes, void *buffer, size_t size);
void __ungetc_clear (int filedes);
void __ungetc_init ();
void __ungetc_set (int filedes, int c);
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
struct timespec
{
long tv_sec;
long tv_nsec;
};
struct timeval
{
long tv_sec;
long tv_usec;
};
#endif /* __M2_LIB_H */

View File

@ -20,6 +20,13 @@
#ifndef __M2_TYPES_H
#define __M2_TYPES_H 1
// FIXME M2_Planet chokes on -1, even inside #if ! __M2__
#if __arm__ || __i386__
#define EOF 0xffffffff
#else
#define EOF 0xffffffffffffffff
#endif
/*
#ifndef __MES_CLOCK_T
#define __MES_CLOCK_T

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -23,76 +23,32 @@
/* Cell types */
// CONSTANT TCHAR 0
#define TCHAR 0
// CONSTANT TBYTES 1
#define TBYTES 1
// CONSTANT TCLOSURE 2
#define TCLOSURE 2
// CONSTANT TCONTINUATION 3
#define TCONTINUATION 3
// CONSTANT TKEYWORD 4
#define TKEYWORD 4
// CONSTANT TMACRO 5
#define TMACRO 5
// CONSTANT TNUMBER 6
#define TNUMBER 6
// CONSTANT TPAIR 7
#define TPAIR 7
// CONSTANT TPORT 8
#define TPORT 8
// CONSTANT TREF 9
#define TREF 9
// CONSTANT TSPECIAL 10
#define TSPECIAL 10
// CONSTANT TSTRING 11
#define TSTRING 11
// CONSTANT TSTRUCT 12
#define TSTRUCT 12
// CONSTANT TSYMBOL 13
#define TSYMBOL 13
// CONSTANT TVALUES 14
#define TVALUES 14
// CONSTANT TVARIABLE 15
#define TVARIABLE 15
// CONSTANT TVECTOR 16
#define TVECTOR 16
// CONSTANT TBROKEN_HEART 17
#define TBROKEN_HEART 17
/* Struct types */
// CONSTANT STRUCT_TYPE 0
#define STRUCT_TYPE 0
// CONSTANT STRUCT_PRINTER 1
#define STRUCT_PRINTER 1
// CONSTANT GC_FRAME_SIZE 5
#define GC_FRAME_SIZE 5
// CONSTANT GC_FRAME_PROCEDURE 4
#define GC_FRAME_PROCEDURE 4
// CONSTANT STDIN 0
// CONSTANT STDOUT 1
// CONSTANT STDERR 2
/* Unknown type 1
// CONSTANT EOF -1
*/
// CONSTANT O_RDONLY 0
// CONSTANT O_WRONLY 1
// CONSTANT O_CREAT 0x40
// CONSTANT O_TRUNC 0x200
// CONSTANT PATH_MAX 1024
// CONSTANT __FILEDES_MAX 512
// CONSTANT S_IRUSR 00400
// CONSTANT S_IWUSR 00200
// CONSTANT CLOCK_PROCESS_CPUTIME_ID 2
#endif /* __MES_CONSTANTS_H */

29
include/mes/lib-cc.h Normal file
View File

@ -0,0 +1,29 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2022 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/>.
*/
#ifndef __MES_LIB_CC_H
#define __MES_LIB_CC_H
#define EOF -1
#if __TINYC__ || SYSTEM_LIBC
#define __raise(x) -1
#endif
#endif //__MES_LIB_CC_H

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2018,2020,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -25,26 +25,33 @@
#include <mes/config.h>
#endif
// CONSTANT STDIN 0
#ifndef STDIN
#define STDIN 0
#endif
// CONSTANT STDOUT 1
#ifndef STDOUT
#define STDOUT 1
#endif
// CONSTANT STDERR 2
#ifndef STDERR
#define STDERR 2
#endif
/* M2-Planet does not support pointer arithmetic. Explicitly compensate
for that by multiplying with M2_PTR_SIZE when using (char)
pointers. */
#if __M2__
#define M2_PTR_SIZE sizeof (void*)
#else
#define M2_PTR_SIZE 1
#endif
extern char **environ;
extern int __stdin;
extern int __stdout;
extern int __stderr;
void __init_io ();
int eputs (char const *s);
int puts (char const *s);
int oputs (char const *s);
@ -63,10 +70,14 @@ int oputs (char const *s);
#ifndef __MES_SIZE_T
#define __MES_SIZE_T
#undef size_t
#if __M2__
typedef unsigned size_t;
#else
typedef unsigned long size_t;
#endif
#endif
#endif
#endif
#ifndef _SSIZE_T
#define _SSIZE_T

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -22,6 +22,10 @@
#define __MES_LIB_H
#include <mes/lib-mini.h>
#include <mes/lib-cc.h>
#define __FILEDES_MAX 512
extern char *__brk;
char *cast_intp_to_charp (int const *i);
char *cast_long_to_charp (long i);
@ -34,14 +38,11 @@ void __ungetc_init ();
void __ungetc_clear (int filedes);
void __ungetc_set (int filedes, int c);
int __ungetc_p (int filedes);
double abtod (char const **p, int base);
long abtol (char const **p, int base);
char *dtoab (double number, int base, int signed_p);
char *itoa (int number);
char *ltoa (long number);
char *ltoab (long x, int base);
char *ntoab (long number, unsigned base, int signed_p);
char *ultoa (unsigned long number);
char *utoa (unsigned number);
int eputc (int c);
int fdgetc (int fd);
@ -61,10 +62,11 @@ char *search_path (char const *file_name);
ssize_t _read (int fd, void *buffer, size_t size);
void assert_msg (int check, char *msg);
extern char *__brk;
extern void (*__call_at_exit) (void);
#define __FILEDES_MAX 512
long __mesabi_imod (long a, long b);
long __mesabi_idiv (long a, long b);
void *__memcpy (void *dest, void const *src, size_t n);
void *__memmove (void *dest, void const *src, size_t n);
void *__memset (void *s, int c, size_t n);
#if !SYSTEM_LIBC
void __assert_fail (char const *s, char const *file, unsigned line,
@ -73,18 +75,20 @@ ssize_t __buffered_read (int filedes, void *buffer, size_t size);
size_t __buffered_read_clear (int filedes);
void _exit (int code);
long brk (void *addr);
#ifndef __raise
int __raise (int signal);
#endif
#endif // !SYSTEM_LIBC
long __mesabi_imod (long a, long b);
long __mesabi_idiv (long a, long b);
#if !__M2__
extern void (*__call_at_exit) (void);
double abtod (char const **p, int base);
char *dtoab (double number, int base, int signed_p);
char *ultoa (unsigned long number);
unsigned long __mesabi_umod (unsigned long a, unsigned long b);
unsigned long __mesabi_udiv (unsigned long a, unsigned long b);
unsigned long __mesabi_uldiv (unsigned long a, unsigned long b,
unsigned long *remainder);
void *__memcpy (void *dest, void const *src, size_t n);
void *__memmove (void *dest, void const *src, size_t n);
void *__memset (void *s, int c, size_t n);
int __raise (int signal);
#endif
#endif //__MES_LIB_H

View File

@ -53,6 +53,15 @@ struct scm
};
};
/* M2-Planet does not support pointer arithmetic. Explicitly compensate
for that by multiplying with M2_CELL_SIZE when using cell
pointers. */
#if __M2__
#define M2_CELL_SIZE sizeof (struct scm)
#else
#define M2_CELL_SIZE 1
#endif
/* mes */
extern char *g_datadir;
extern int g_debug;

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -137,14 +137,8 @@ extern struct scm *cell_type_broken_heart;
extern struct scm *cell_symbol_program;
extern struct scm *cell_symbol_test;
// CONSTANT SYMBOL_MAX 114
#define SYMBOL_MAX 114
// CONSTANT CELL_UNSPECIFIED 7
#define CELL_UNSPECIFIED 7
// CONSTANT CELL_SYMBOL_RECORD_TYPE 82
#define CELL_SYMBOL_RECORD_TYPE 82
#endif /* __MES_SYMBOLS_H */

View File

@ -29,9 +29,12 @@
#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long)))
typedef struct {
#if !__M2__
typedef struct
{
unsigned long items[_SIGSET_NITEMS];
} sigset_t;
#endif
typedef long stack_t;
#include <sys/types.h>
@ -91,6 +94,7 @@ typedef long stack_t;
#define SA_NOMASK SA_NODEFER
#define SA_ONESHOT SA_RESETHAND
#if !__M2__ // lacks short, casts
typedef struct siginfo_t
{
int si_signo;
@ -120,7 +124,7 @@ typedef struct siginfo_t
} siginfo_t;
// *INDENT-ON*
#if __MESC__
#if __M2__ || __MESC__
typedef long sighandler_t;
#else
typedef void (*sighandler_t) (int);
@ -255,6 +259,7 @@ int sigemptyset (sigset_t * set);
#endif
int sigprocmask (int how, sigset_t const *set, sigset_t * oldset);
#endif // !__M2__
#endif //! SYSTEM_LIBC
#endif // __MES_SIGNAL_H

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -26,7 +27,19 @@
#define va_arg8(ap, type) va_arg(ap, type)
#else // ! SYSTEM_LIBC
#elif __GNUC__ && __riscv
// GCC on RISC-V always passes arguments in registers. Implementing these macros without
// the use of built-ins would be very involved.
typedef __builtin_va_list va_list;
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#define va_arg8(ap, type) va_arg(ap, type)
#define va_copy(d,s) __builtin_va_copy(d,s)
#else // ! SYSTEM_LIBC && ! __riscv
#include <sys/types.h>

View File

@ -87,7 +87,7 @@ typedef unsigned uintmax_t;
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#if __i386__ || __arm__
#if __i386__ || __arm__ || __riscv_xlen == 32
#define LONG_MIN INT_MIN
#define LONG_MAX INT_MAX
#define UINT_MAX UINT32_MAX
@ -95,7 +95,7 @@ typedef unsigned uintmax_t;
#define LLONG_MIN INT64_MIN
#define LLONG_MAX INT64_MAX
#define SIZE_MAX UINT32_MAX
#elif __x86_64__
#elif __x86_64__ || __riscv_xlen == 64
#define LONG_MIN INT64_MIN
#define LONG_MAX INT64_MAX
#define UINT_MAX UINT32_MAX

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -65,30 +65,33 @@ int ferror (FILE * stream);
int fflush (FILE * stream);
int fgetc (FILE * stream);
char *fgets (char *s, int size, FILE * stream);
int fprintf (FILE * stream, char const *format, ...);
int fpurge (FILE * stream);
int fputc (int c, FILE * stream);
int fputs (char const *s, FILE * stream);
int fscanf (FILE * stream, char const *template, ...);
int fseek (FILE * stream, long offset, int whence);
int getc (FILE * stream);
int getchar (void);
char *getlogin (void);
int printf (char const *format, ...);
int putc (int c, FILE * stream);
int putchar (int c);
int puts (char const *s);
int remove (char const *file_name);
int setvbuf (FILE * stream, char *buf, int mode, size_t size);
int snprintf (char *str, size_t size, char const *format, ...);
int sprintf (char *str, char const *format, ...);
int sscanf (char const *str, char const *format, ...);
int ungetc (int c, FILE * stream);
long ftell (FILE * stream);
size_t fread (void *ptr, size_t size, size_t count, FILE * stream);
size_t freadahead (FILE * fp);
size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream);
#if !__M2__
int fprintf (FILE * stream, char const *format, ...);
int fscanf (FILE * stream, char const *template, ...);
int printf (char const *format, ...);
int snprintf (char *str, size_t size, char const *format, ...);
int sprintf (char *str, char const *format, ...);
int sscanf (char const *str, char const *format, ...);
#endif // !__M2__
#endif // ! SYSTEM_LIBC
#endif // __MES_STDIO_H

View File

@ -28,8 +28,13 @@
#define TCGETS 0x5401
#define TCGETA 0x5405
#if __M2__
int ioctl (int fd, unsigned request, long data);
int ioctl3 (int fd, unsigned request, long data);
#else
int ioctl (int fd, unsigned long request, ...);
int ioctl3 (int fd, unsigned long request, long data);
#endif
#endif // ! SYSTEM_LIBC

View File

@ -32,20 +32,20 @@ struct rusage
{
struct timeval ru_utime;
struct timeval ru_stime;
long int ru_maxrss;
long int ru_ixrss;
long int ru_idrss;
long int ru_isrss;
long int ru_minflt;
long int ru_majflt;
long int ru_nswap;
long int ru_inblock;
long int ru_oublock;
long int ru_msgsnd;
long int ru_msgrcv;
long int ru_nsignals;
long int ru_nvcsw;
long int ru_nivcsw;
long ru_maxrss;
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_msgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
};
#define RUSAGE_SELF 0

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -20,6 +20,8 @@
#ifndef __MES_SYS_TYPES_H
#define __MES_SYS_TYPES_H 1
#include <mes/lib-cc.h>
#if SYSTEM_LIBC
#undef __MES_SYS_TYPES_H
#include_next <sys/types.h>
@ -31,10 +33,6 @@
#define __MESCCLIB__ 15
#endif
#ifndef EOF
#define EOF -1
#endif
#ifndef NULL
#define NULL 0
#endif
@ -66,15 +64,23 @@ typedef unsigned gid_t;
#ifndef __MES_INO_T
#define __MES_INO_T
#undef ino_t
#if __M2__
typedef unsigned ino_t;
#else
typedef unsigned long ino_t;
#endif
#endif
#if __SIZEOF_LONG_LONG__ == 8
#ifndef __MES_INO64_T
#define __MES_INO64_T
#undef ino64_t
#if __M2__
typedef unsigned ino64_t;
#else
typedef unsigned long long ino64_t;
#endif
#endif
#endif // __SIZEOF_LONG_LONG__ == 8
#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined)
@ -83,8 +89,12 @@ typedef unsigned long long ino64_t;
#undef intptr_t
typedef long intptr_t;
#undef uintptr_t
#if __M2__
typedef unsigned uintptr_t;
#else
typedef unsigned long uintptr_t;
#endif
#endif
#ifndef __MES_OFF_T
#define __MES_OFF_T
@ -96,8 +106,12 @@ typedef long off_t;
#ifndef __MES_OFF64_T
#define __MES_OFF64_T
#undef off64_t
#if __M2__
typedef unsigned off64_t;
#else
typedef unsigned long long off64_t;
#endif
#endif
#endif // __SIZEOF_LONG_LONG__ == 8
#ifndef __MES_PID_T
@ -126,9 +140,13 @@ typedef long sigval_t;
#ifndef __MES_SIZE_T
#define __MES_SIZE_T
#undef size_t
#if __M2__
typedef unsigned size_t;
#else
typedef unsigned long size_t;
#endif
#endif
#endif
#ifndef __MES_SSIZE_T
#define __MES_SSIZE_T

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -20,6 +20,8 @@
#ifndef __MES_SYS_WAIT_H
#define __MES_SYS_WAIT_H 1
#include <sys/resource.h>
#if SYSTEM_LIBC
#undef __MES_SYS_WAIT_H
#include_next <sys/wait.h>
@ -35,6 +37,8 @@ typedef int pid_t;
pid_t waitpid (pid_t pid, int *status_ptr, int options);
pid_t wait (int *status_ptr);
pid_t wait4 (pid_t pid, int *wstatus, int options,
struct rusage *rusage);
#endif // ! SYSTEM_LIBC

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -27,8 +27,8 @@
#ifndef __MES_TIME_T
#define __MES_TIME_T 1
typedef long int clockid_t;
typedef long int time_t;
typedef long clockid_t;
typedef long time_t;
#endif
struct tm

25
kaem.arm Normal file
View File

@ -0,0 +1,25 @@
#! /bin/sh
# Copyright © 2022 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/>.
# Usage:
# kaem --verbose --strict
cc_cpu=arm
mes_cpu=arm
stage0_cpu=armv7l
kaem --verbose --strict

26
kaem.riscv64 Normal file
View File

@ -0,0 +1,26 @@
#! /bin/sh
# Copyright © 2022 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/>.
# Usage:
# kaem --verbose --strict
cc_cpu=riscv64
mes_cpu=riscv64
stage0_cpu=riscv64
blood_elf_flag=--64
kaem --verbose --strict

View File

@ -1,5 +1,6 @@
#! /bin/sh
# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
#
# This file is part of GNU Mes.
#
@ -19,41 +20,53 @@
# Usage:
# kaem --verbose --strict
cc_cpu=${cc_cpu:-i386}
mes_cpu=${mes_cpu:-x86}
stage0_cpu=${stage0_cpu:-x86}
blood_elf_flag=${blood_elf_flag:---little-endian}
mkdir -p m2
M2-Planet \
--bootstrap-mode \
--debug \
--architecture ${stage0_cpu} \
-f include/m2/lib.h \
-D __${cc_cpu}__=1 \
-D __linux__=1 \
-f include/mes/config.h \
-f include/mes/lib-mini.h \
-f include/mes/lib.h \
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
-f lib/mes/__init_io.c \
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
-f lib/mes/globals.c \
-f lib/m2/cast.c \
-f lib/m2/exit.c \
-f lib/mes/mini-write.c \
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
-f lib/stdlib/exit.c \
-f lib/mes/write.c \
-f include/linux/${mes_cpu}/syscall.h \
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
-f lib/stub/__raise.c \
-f lib/linux/brk.c \
-f lib/m2/malloc.c \
-f lib/linux/malloc.c \
-f lib/string/memset.c \
-f lib/m2/read.c \
-f lib/linux/read.c \
-f lib/mes/fdgetc.c \
-f lib/stdio/getchar.c \
-f lib/stdio/putchar.c \
-f lib/m2/open.c \
-f lib/m2/mes_open.c \
-f lib/stub/__buffered_read.c \
-f include/fcntl.h \
-f lib/linux/_open3.c \
-f lib/linux/open.c \
-f lib/mes/mes_open.c \
-f lib/string/strlen.c \
-f lib/mes/eputs.c \
-f lib/mes/fdputc.c \
-f lib/mes/eputc.c \
\
-f include/time.h \
-f include/sys/time.h \
-f include/m2/types.h \
-f include/sys/types.h \
-f include/mes/mes.h \
-f include/mes/builtins.h \
-f include/mes/constants.h \
@ -84,17 +97,22 @@ M2-Planet \
-f lib/linux/access.c \
-f include/linux/m2/kernel-stat.h \
-f include/sys/stat.h \
-f lib/m2/chmod.c \
-f lib/linux/chmod.c \
-f lib/linux/ioctl3.c \
-f include/sys/ioctl.h \
-f lib/m2/isatty.c \
-f include/signal.h \
-f lib/linux/fork.c \
-f lib/m2/execve.c \
-f lib/m2/execv.c \
-f lib/m2/waitpid.c \
-f include/sys/resource.h \
-f lib/linux/wait4.c \
-f lib/linux/waitpid.c \
-f lib/linux/gettimeofday.c \
-f lib/m2/clock_gettime.c \
-f lib/linux/clock_gettime.c \
-f lib/m2/time.c \
-f lib/linux/_getcwd.c \
-f include/limits.h \
-f lib/m2/getcwd.c \
-f lib/linux/dup.c \
-f lib/linux/dup2.c \
@ -112,6 +130,7 @@ M2-Planet \
-f src/math.c \
-f src/mes.c \
-f src/module.c \
-f include/signal.h \
-f src/posix.c \
-f src/reader.c \
-f src/stack.c \
@ -121,7 +140,7 @@ M2-Planet \
-f src/vector.c \
-o m2/mes.M1
blood-elf --little-endian -f m2/mes.M1 -o m2/mes.blood-elf-M1
blood-elf ${blood_elf_flag} --little-endian -f m2/mes.M1 -o m2/mes.blood-elf-M1
M1 \
--architecture ${stage0_cpu} \

25
kaem.x86 Normal file
View File

@ -0,0 +1,25 @@
#! /bin/sh
# Copyright © 2022 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/>.
# Usage:
# kaem --verbose --strict
cc_cpu=i386
mes_cpu=x86
stage0_cpu=x86
kaem --verbose --strict

27
kaem.x86_64 Normal file
View File

@ -0,0 +1,27 @@
#! /bin/sh
# Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
# 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/>.
# Usage:
# kaem --verbose --strict
cc_cpu=x86_64
mes_cpu=x86_64
stage0_cpu=amd64
blood_elf_flag=--64
kaem --verbose --strict

View File

@ -269,6 +269,7 @@ DEFINE lsl____%r0,%r0,%r1 1001a0e1 # lsl %r0, %r0, %r1
DEFINE lsl____%r0,%r0,$i8 90a0e31009a0e1 # mov r9, #xx; lsl %r0, %r0, %r9
DEFINE lsl____%r1,%r1,$i8 90a0e31119a0e1 # mov r9, #xx; lsl %r1, %r1, %r9
DEFINE lsr____%r0,%r0,%r1 3001a0e1 # lsr %r0, %r0, %r1
DEFINE asr____%r0,%r0,%r1 5001a0e1 # asr %r0, %r0, %r1
DEFINE ldr____%r0,(%sp,#$i8) 009de5 # ldr r0, [r13+xx]
DEFINE ldr____%r1,(%sp,#$i8) 109de5 # ldr r1, [r13+xx]
#DEFINE add____%r2,%r0,%r1,lsl#4 012280e0

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2019,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -20,7 +20,7 @@
#include "mes/lib-mini.h"
#define SYS_exit "0x01"
#define SYS_write "0x04"
// *INDENT-OFF*
ssize_t

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2018,2019,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -19,45 +19,20 @@
*/
#include <mes/lib-mini.h>
//int main (int argc, char *argv[], char *envp[]);
int main (int argc, char *argv[], char *envp[]);
// *INDENT-OFF*
void
_start ()
{
asm (
"mov $0,%%eax\n\t"
"mov %%eax,%0\n"
: "=r" (__stdin)
: //no inputs ""
);
asm (
"mov $1,%%eax\n\t"
"mov %%eax,%0\n"
: "=r" (__stdout)
: //no inputs ""
);
asm (
"mov $2,%%eax\n\t"
"mov %%eax,%0\n"
: "=r" (__stderr)
: //no inputs ""
);
asm (
"mov %%ebp,%%eax\n\t"
"add $4,%%eax\n\t"
"mov (%%eax),%%eax\n\t"
"add $3,%%eax\n\t"
"shl $2,%%eax\n\t"
"add %%ebp,%%eax\n\t"
"mov %%eax,%0\n\t"
"push %%eax\n\t"
: "=r" (environ)
: //no inputs ""
);
asm (
"mov %ebp,%eax\n\t"
"add $4,%eax\n\t"
"mov (%eax),%eax\n\t"
"add $3,%eax\n\t"
"shl $2,%eax\n\t"
"add %ebp,%eax\n\t"
"push %eax\n\t"
"mov %ebp,%eax\n\t"
"add $8,%eax\n\t"
"push %eax\n\t"
@ -67,6 +42,7 @@ _start ()
"mov (%eax),%eax\n\t"
"push %eax\n\t"
"call __init_io\n\t"
"call main\n\t"
"push %eax\n\t"

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2018,2019,2021,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -19,21 +19,11 @@
*/
#include "mes/lib-mini.h"
int main (int argc, char *argv[], char *envp[]);
int
_start ()
{
asm ("mov____$i8,%eax !0");
asm ("mov____%eax,0x32 &__stdin");
asm ("mov____$i8,%eax !1");
asm ("mov____%eax,0x32 &__stdout");
asm ("mov____$i8,%eax !2");
asm ("mov____%eax,0x32 &__stderr");
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !4");
@ -42,7 +32,6 @@ _start ()
asm ("shl____$i8,%eax !0x02");
asm ("add____%ebp,%eax");
asm ("mov____%eax,0x32 &environ");
asm ("push___%eax");
asm ("mov____%ebp,%eax");
@ -54,6 +43,7 @@ _start ()
asm ("mov____(%eax),%eax");
asm ("push___%eax");
__init_io ();
main ();
asm ("mov____%eax,%ebx");

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2018,2019,2023 Janneke Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
@ -19,13 +19,13 @@
*/
#include <gnu/hurd.h>
int main (int argc, char *argv[], char *envp[]);
char **environ;
int __stdin;
int __stdout;
int __stderr;
int main ();
void _exit (int status);
void _hurd_start (void);

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -26,7 +27,15 @@
int
_open3 (char const *file_name, int flags, int mask)
{
int r = _sys_call3 (SYS_open, (long) file_name, (int) flags, (int) mask);
long long_file_name = cast_charp_to_long (file_name);
#if defined (SYS_open)
int r = _sys_call3 (SYS_open, long_file_name, flags, mask);
#elif defined (SYS_openat)
int r = _sys_call4 (SYS_openat, AT_FDCWD, long_file_name, flags, mask);
#else
#error No usable open syscall
#endif
__ungetc_init ();
if (r > 2)
{
__ungetc_clear (r);

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -21,11 +22,18 @@
#include <mes/lib.h>
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <fcntl.h>
int
access (char const *file_name, int how)
{
long long_file_name = cast_charp_to_long (file_name);
long long_how = cast_int_to_long (how);
#if defined (SYS_access)
return _sys_call2 (SYS_access, long_file_name, long_how);
#elif defined (SYS_faccessat)
return _sys_call3 (SYS_faccessat, AT_FDCWD, long_file_name, long_how);
#else
#error No usable access sysall
#endif
}

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2018,2019,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2019,2020 Danny Milosavljevic <dannym@scratchpost.org>
*
* This file is part of GNU Mes.
@ -20,7 +20,7 @@
*/
#include <mes/lib-mini.h>
//int main (int argc, char *argv[], char *envp[]);
int main (int argc, char *argv[], char *envp[]);
/* Note: GCC automatically emits a preable in order to set up the
frame pointer: "push {fp}" "add fp, sp, 0"
@ -30,27 +30,6 @@ frame pointer: "push {fp}" "add fp, sp, 0"
void
_start ()
{
asm (
"mov r0,#0\n\t"
"mov %0,r0\n"
: "=r" (__stdin)
: //no inputs ""
);
asm (
"mov r0,#1\n\t"
"mov %0,r0\n"
: "=r" (__stdout)
: //no inputs ""
);
asm (
"mov r0,#2\n\t"
"mov %0,r0\n"
: "=r" (__stderr)
: //no inputs ""
);
/* environ = argv + argc + 1 */
asm (
"ldr r0,[fp,#4]\n\t" /* r0 = argc */
@ -61,14 +40,10 @@ _start ()
"push {r2}\n\t" /* envp */
"push {r1}\n\t" /* argv */
"push {r0}\n\t" /* argc */
"mov %0,r2\n\t"
: "=r" (environ)
: //no inputs ""
);
asm (
"ldr r0,[sp]\n\t" /* argc */
"ldr r1,[sp, #4]\n\t" /* argv */
"ldr r2,[sp, #8]\n\t" /* envp */
"bl __init_io\n\t"
"bl main\n\t"
"mov r7, #1\n\t"
"swi #0\n\t"
@ -79,31 +54,6 @@ _start ()
void
_start ()
{
#if 0
__asm__ (".int 0xe320f000\n"); //nop {0}
__asm__ (".int 0xe320f000\n"); //nop {0}
#endif
int *in = &__stdin;
int *out = &__stdout;
int *err = &__stderr;
char ***env = &environ;
#if 0
__asm__ (".int 0xe320f000\n"); //nop {0}
__asm__ (".int 0xe320f000\n"); //nop {0}
__asm__ (".int 0xe320f000\n"); //nop {0}
*in = 0x22;
__asm__ (".int 0xe320f000\n"); //nop {0}
*out = 0x33;
__asm__ (".int 0xe320f000\n"); //nop {0}
*err = 0x44;
__asm__ (".int 0xe320f000\n"); //nop {0}
*env = 0x55;
__asm__ (".int 0xe320f000\n"); //nop {0}
#endif
/* environ = argv + argc + 1 */
__asm__ (".int 0xe59b000c\n"); //ldr r0, [fp, #12]
__asm__ (".int 0xe28b1010\n"); //add r1, fp, #16
@ -118,34 +68,11 @@ _start ()
__asm__ (".int 0xe52d0004\n"); //push {r0} ; (str r0, [sp, #-4]!)
__asm__ (".int 0xe1a02002\n"); //mov r2, r2
// *in = 0;
__asm__ (".int 0xe3a01000\n"); //mov r1, #0
__asm__ (".int 0xe51b0004\n"); //ldr r0, [fp, #-4]
__asm__ (".int 0xe5801000\n"); //str r1, [r0]
__asm__ (".int 0xe320f000\n"); //nop {0}
// *out = 1;
__asm__ (".int 0xe3a01001\n"); //mov r1, #1
__asm__ (".int 0xe51b0008\n"); //ldr r0, [fp, #-8]
__asm__ (".int 0xe5801000\n"); //str r1, [r0]
__asm__ (".int 0xe320f000\n"); //nop {0}
// *err = 2;
__asm__ (".int 0xe3a01002\n"); //mov r1, #2
__asm__ (".int 0xe51b000c\n"); //ldr r0, [fp, #-12]
__asm__ (".int 0xe5801000\n"); //str r1, [r0]
__asm__ (".int 0xe320f000\n"); //nop {0}
// *env = [sp, #8]
__asm__ (".int 0xe59d1008\n"); //ldr r1, [sp, #8]
__asm__ (".int 0xe51b0010\n"); //ldr r0, [fp, #-16]
__asm__ (".int 0xe5801000\n"); //str r1, [r0]
__asm__ (".int 0xe320f000\n"); //nop {0}
// setup argc, argv, envp parameters in registers
__asm__ (".int 0xe59d0000\n"); //ldr r0, [sp]
__asm__ (".int 0xe59d1004\n"); //ldr r1, [sp, #4]
__asm__ (".int 0xe59d2008\n"); //ldr r2, [sp, #8]
__init_io ();
main ();
__asm__ (".int 0xe3a07001\n"); //mov r7, #1

View File

@ -1,6 +1,6 @@
### GNU Mes --- Maxwell Equations of Software
### Copyright (C) 2016 Jeremiah Orians
### Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
### Copyright © 2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
###
### This file is part of GNU Mes.
###
@ -32,21 +32,10 @@
'0' R0 R0 ADD BP ARITH2_ALWAYS ; ENVP_address = BP + OFFSET
{R0} PUSH_ALWAYS ; Put envp on the stack
mov____%r0,0x32 &GLOBAL_environ
;; Stack offset
!4 BP ADD BP ARITH_ALWAYS ; Fix BP
;;^~FUNCTION___init_io CALL_ALWAYS ; Setup for FILE*
;; Initialize MesCC lib file descriptors.
!0 mov____$i8,%r0
mov____%r0,0x32 &GLOBAL___stdin
!1 mov____$i8,%r0
mov____%r0,0x32 &GLOBAL___stdout
!2 mov____$i8,%r0
mov____%r0,0x32 &GLOBAL___stderr
^~FUNCTION___init_io CALL_ALWAYS ; Init libc
^~FUNCTION_main CALL_ALWAYS ; Jump right into main
SYS_exit mov____$i8,%r7

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2018,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
*
* This file is part of GNU Mes.
@ -20,7 +20,6 @@
*/
#include "mes/lib-mini.h"
int main (int argc, char *argv[], char *envp[]);
void /* must not return */
@ -36,21 +35,6 @@ environ = &argv[argc + 1]
HOWEVER, the function entry already allocated space for locals on the stack (after saving lr and fp, which moved sp again). Hence, use fp instead of sp.
*/
/* stdin = 0 */
asm ("!0 mov____$i8,%r0");
asm ("mov____%r0,0x32 &__stdin");
/* stdout = 1 */
asm ("!1 mov____$i8,%r0");
asm ("mov____%r0,0x32 &__stdout");
/* stderr = 2 */
asm ("!2 mov____$i8,%r0");
asm ("mov____%r0,0x32 &__stderr");
/* Add "environ" to main's arguments */
asm ("!8 ldr____%r0,(%fp,+#$i8)"); /* "argc" */
@ -63,10 +47,7 @@ HOWEVER, the function entry already allocated space for locals on the stack (aft
asm ("push___%r1"); /* argv */
asm ("push___%r0"); /* argc */
/* environ = r2 */
asm ("mov____%r2,0x32 &environ");
__init_io ();
main ();
asm ("SYS_exit mov____$i8,%r7");

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -22,11 +23,18 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <sys/stat.h>
#include <fcntl.h>
int
chmod (char const *file_name, mode_t mask)
{
long long_file_name = cast_charp_to_long (file_name);
long long_mask = cast_int_to_long (mask);
#if defined (SYS_chmod)
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
#elif defined (SYS_fchmodat)
return _sys_call3 (SYS_fchmodat, AT_FDCWD, long_file_name, long_mask);
#else
#error No usable chmod syscall
#endif
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -26,5 +27,11 @@ dup2 (int old, int new)
{
long long_old = old;
long long_new = new;
#if defined (SYS_dup2)
return _sys_call2 (SYS_dup2, long_old, long_new);
#elif defined (SYS_dup3)
return _sys_call3 (SYS_dup3, long_old, long_new, 0);
#else
#error No usable dup2 syscall
#endif
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -20,9 +21,17 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <signal.h>
#include <unistd.h>
int
fork ()
{
#if defined (SYS_fork)
return _sys_call (SYS_fork);
#elif defined (SYS_clone)
return _sys_call4 (SYS_clone, SIGCHLD, 0, NULL, 0);
#else
#error No usable clone syscall found
#endif
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -25,5 +26,11 @@
int
getdents (int filedes, char *buffer, size_t nbytes)
{
#if defined (SYS_getdents)
return _sys_call3 (SYS_getdents, (int) filedes, (long) buffer, (long) nbytes);
#elif defined (SYS_getdents64)
return _sys_call3 (SYS_getdents64, (int) filedes, (long) buffer, (long) nbytes);
#else
#error No usable getdents syscall
#endif
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -20,9 +21,16 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <fcntl.h>
int
link (char const *old_name, char const *new_name)
{
#if defined (SYS_link)
return _sys_call2 (SYS_link, (long) old_name, (long) new_name);
#elif defined (SYS_linkat)
return _sys_call4 (SYS_linkat, AT_FDCWD, (long) old_name, AT_FDCWD, (long) new_name);
#else
#error No usable link syscall
#endif
}

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -24,23 +24,23 @@
#include <stdio.h>
#include <sys/types.h>
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
off_t
_lseek (int filedes, off_t offset, int whence)
{
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
long long_offset = offset;
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
}
#endif
off_t
lseek (int filedes, off_t offset, int whence)
{
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
#if !__MESC__ && !__M2__
if (_lseek (filedes, 0, SEEK_CUR) == -1)
return -1;
#endif
size_t skip = __buffered_read_clear (filedes);
if (whence == SEEK_CUR)
offset -= skip;
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
long long_offset = offset;
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -20,10 +21,18 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <fcntl.h>
#include <sys/stat.h>
int
lstat (char const *file_name, struct stat *statbuf)
{
#if defined (SYS_lstat)
return _sys_call2 (SYS_lstat, (long) file_name, (long) statbuf);
#elif defined (SYS_newfstatat)
return _sys_call4 (SYS_newfstatat, AT_FDCWD, (long) file_name, (long) statbuf, 0);
#else
#error No usable stat syscall
#endif
return 0;
}

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 Danny Milosavljevic <dannym@scratchpost.org>
*
* This file is part of GNU Mes.
@ -31,9 +31,11 @@ malloc (size_t size)
{
if (!__brk)
__brk = cast_long_to_charp (brk (0));
#if !__M2__
/* align what we give back. */
__brk = (char*) (((uintptr_t) __brk
+ sizeof (max_align_t) - 1) & -sizeof (max_align_t));
#endif
if (brk (__brk + size) == -1)
return 0;
char *p = __brk;

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -20,10 +21,17 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <fcntl.h>
#include <sys/stat.h>
int
mkdir (char const *file_name, mode_t mode)
{
#if defined (SYS_mkdir)
return _sys_call2 (SYS_mkdir, (long) file_name, (long) mode);
#elif defined (SYS_mkdirat)
return _sys_call3 (SYS_mkdirat, AT_FDCWD, (long) file_name, (long) mode);
#else
#error No usable mkdir syscall
#endif
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -21,9 +22,16 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <sys/stat.h>
#include <fcntl.h>
int
mknod (char const *file_name, mode_t mode, dev_t dev)
{
#if defined (SYS_mknod)
return _sys_call3 (SYS_mknod, (long) file_name, (long) mode, (long) dev);
#elif defined (SYS_mknodat)
return _sys_call4 (SYS_mknodat, AT_FDCWD, (long) file_name, (long) mode, (long) dev);
#else
#error No usable mknod syscall
#endif
}

62
lib/linux/open.c Normal file
View File

@ -0,0 +1,62 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <mes/lib.h>
#include <fcntl.h>
#include <stdarg.h>
#if __M2__
int
open (char *file_name, int flags, int mask)
{
#if defined (SYS_open)
int r = _sys_call3 (SYS_open, file_name, flags, mask);
#elif defined (SYS_openat)
int r = _sys_call4 (SYS_openat, AT_FDCWD, file_name, flags, mask);
#else
#error No usable open syscall
#endif
if (r > 2)
__ungetc_clear (r);
return r;
}
#else // !__M2__
int
open (char const *file_name, int flags, ...)
{
va_list ap;
va_start (ap, flags);
int mask = va_arg (ap, int);
#if defined (SYS_open)
int r = _sys_call3 (SYS_open, (long) file_name, flags, mask);
#elif defined (SYS_openat)
int r = _sys_call4 (SYS_openat, AT_FDCWD, (long) file_name, flags, mask);
#else
#error No usable open syscall
#endif
va_end (ap);
if (r > 2)
__ungetc_clear (r);
return r;
}
#endif // !__M2__

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -21,9 +22,16 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <unistd.h>
#include <fcntl.h>
int
pipe (int filedes[2])
{
#if defined (SYS_pipe)
return _sys_call1 (SYS_pipe, (long) filedes);
#elif defined (SYS_pipe2)
return _sys_call2 (SYS_pipe2, (long) filedes, 0);
#else
#error No usable pipe syscall found
#endif
}

View File

@ -27,7 +27,9 @@ ssize_t
read (int filedes, void *buffer, size_t size)
{
long long_filedes = filedes;
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, (long) buffer, (long) size);
long long_buffer = cast_voidp_to_long (buffer);
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, long_buffer, size);
#if !__M2__
if (__mes_debug () > 4)
{
if (bytes == 1)
@ -48,5 +50,6 @@ read (int filedes, void *buffer, size_t size)
eputs ("\n");
}
}
#endif
return bytes;
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -20,10 +21,17 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <fcntl.h>
#include <sys/stat.h>
ssize_t
readlink (char const *file_name, char *buffer, size_t size)
{
#if defined (SYS_readlink)
return _sys_call3 (SYS_readlink, (long) file_name, (long) buffer, (long) size);
#elif defined (SYS_readlinkat)
return _sys_call4 (SYS_readlinkat, AT_FDCWD, (long) file_name, (long) buffer, (long) size);
#else
#error No usable readlink syscall
#endif
}

View File

@ -1,6 +1,7 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* This file is part of GNU Mes.
*
@ -21,9 +22,16 @@
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <unistd.h>
#include <fcntl.h>
int
rename (char const *old_name, char const *new_name)
{
#if defined (SYS_rename)
return _sys_call2 (SYS_rename, (long) old_name, (long) new_name);
#elif defined (SYS_renameat2)
return _sys_call5 (SYS_renameat2, AT_FDCWD, (long) old_name, AT_FDCWD, (long) new_name, 0);
#else
#error No usable rename syscall
#endif
}

View File

@ -0,0 +1,39 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
#include "mes/lib-mini.h"
#define SYS_exit 93
// *INDENT-OFF*
void
_exit (int code)
{
register long __a7 asm ("a7") = SYS_exit;
register long __a0 asm ("a0") = code;
asm volatile (
"ecall\n\t"
: // no outputs
: "r" (__a0), "r" (__a7)
);
// not reached
_exit (0);
}

View File

@ -0,0 +1,40 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
#include "mes/lib-mini.h"
#define SYS_write 64
// *INDENT-OFF*
ssize_t
_write (int filedes, void const *buffer, size_t size)
{
register long __a7 asm ("a7") = (long) SYS_write;
register long __a0 asm ("a0") = (long) filedes;
register long __a1 asm ("a1") = (long) buffer;
register long __a2 asm ("a2") = (long) size;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7), "r" (__a1), "r" (__a2)
);
return (ssize_t)__a0;
}

View File

@ -0,0 +1,66 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2019,2020 Danny Milosavljevic <dannym@scratchpost.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
#include <mes/lib-mini.h>
int main (int argc, char *argv[], char *envp[]);
/* gcc will generate the following preamble:
addi sp,sp,-16
sd s0,8(sp)
addi s0,sp,16
*/
// *INDENT-OFF*
void
_start ()
{
asm (
".option push\n\t"
".option norelax\n\t"
"lla gp, __global_pointer$\n\t"
".option pop\n\t"
"andi sp, sp, ~15\n\t" // make sure sp conforms to ABI alignment
);
// environ is &argv[argc + 1]
asm (
"lw t0, 0(s0)\n\t"
"addi t1, s0, 8\n\t"
"addi t0, t0, 1\n\t"
"slli t0, t0, 3\n\t"
"add t0, t1, t0\n\t"
"lw a0, 0(s0)\n\t" // a0 argc
"addi a1, s0, 8\n\t" // a1 argv
"mv a2, t0\n\t" // a2 envp
"jal __init_io\n\t"
"jal main\n\t"
"li a7, 93\n\t" // SYS_exit
"ecall\n\t" // exit(return value from main)
"ebreak\n\t"
: //no outputs ""
: "r" (environ)
);
}

View File

@ -0,0 +1,31 @@
/*
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
/** Code: */
SYS_exit = 93 /* Linux syscalls. */
.globl _start /* Magic linker symbol: --entry-address. */
.text /* Program text. */
_start:
li a7, SYS_exit /* System call function: exit, in a7. */
li a0, 42 /* 1st parameter: exit status, in a0. */
ecall /* Call system. */
wfi /* Should not be reached. */

View File

@ -0,0 +1,45 @@
/*
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
/** Code: */
SYS_exit = 93 /* Linux syscalls. */
SYS_write = 64
stdout = 1 /* File descriptor */
.globl _start /* Magic linker symbol: --entry-address. */
.text /* Program text. */
hello: .ascii "Hello, GNU Mes!\n"
bye:
.equ string_size, (bye - hello)
_start:
li a7, SYS_write /* System call function: write, in a7. */
li a0, stdout /* 1st parameter: file descriptor, in a0. */
.equ string_offset, (hello - .)
auipc a1, 0 /* Load pc for pc-relative address */
addi a1, a1, string_offset /* 2nd parameter: address, in a1. */
li a2, string_size /* 3rd parameter: byte count a2. */
ecall /* Call system. */
li a7, SYS_exit /* System call function: exit, in a7. */
li a0, 0 /* 1st parameter: exit status, in a0. */
ecall /* Call system. */
wfi /* Should not be reached. */

View File

@ -0,0 +1,62 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
#include <linux/riscv64/syscall.h>
// *INDENT-OFF*
static long
__sys_call_internal (long sys_call)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0");
asm volatile (
"ecall\n\t"
: "=r" (__a0)
: "r" (__a7)
);
return __a0;
}
static long
__sys_call2_internal (long sys_call, long one, long two)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0") = one;
register long __a1 asm ("a1") = two;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7), "r" (__a1)
);
return __a0;
}
// *INDENT-ON*
/* Returns < 0 on error (errno-like value from kernel), or 0 on success */
int
__raise (int signum)
{
long pid = __sys_call_internal (SYS_getpid);
if (pid < 0)
return pid;
else
return __sys_call2_internal (SYS_kill, pid, signum);
}

View File

@ -0,0 +1,197 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
*
* 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/>.
*/
#include <errno.h>
#include <linux/riscv64/syscall.h>
// *INDENT-OFF*
long
__sys_call (long sys_call)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0");
asm volatile (
"ecall\n\t"
: "=r" (__a0)
: "r" (__a7)
);
return __a0;
}
long
__sys_call1 (long sys_call, long one)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0") = one;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7)
);
return __a0;
}
long
__sys_call2 (long sys_call, long one, long two)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0") = one;
register long __a1 asm ("a1") = two;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7), "r" (__a1)
);
return __a0;
}
long
__sys_call3 (long sys_call, long one, long two, long three)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0") = one;
register long __a1 asm ("a1") = two;
register long __a2 asm ("a2") = three;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7), "r" (__a1), "r" (__a2)
);
return __a0;
}
long
__sys_call4 (long sys_call, long one, long two, long three, long four)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0") = one;
register long __a1 asm ("a1") = two;
register long __a2 asm ("a2") = three;
register long __a3 asm ("a3") = four;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3)
);
return __a0;
}
long
__sys_call5 (long sys_call, long one, long two, long three, long four, long five)
{
register long __a7 asm ("a7") = sys_call;
register long __a0 asm ("a0") = one;
register long __a1 asm ("a1") = two;
register long __a2 asm ("a2") = three;
register long __a3 asm ("a3") = four;
register long __a4 asm ("a4") = five;
asm volatile (
"ecall\n\t"
: "+r" (__a0)
: "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), "r" (__a4)
);
return __a0;
}
// *INDENT-ON*
long
_sys_call (long sys_call)
{
long r = __sys_call (sys_call);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call1 (long sys_call, long one)
{
long r = __sys_call1 (sys_call, one);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call2 (long sys_call, long one, long two)
{
long r = __sys_call2 (sys_call, one, two);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call3 (long sys_call, long one, long two, long three)
{
long r = __sys_call3 (sys_call, one, two, three);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call4 (long sys_call, long one, long two, long three, long four)
{
long r = __sys_call4 (sys_call, one, two, three, four);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call5 (long sys_call, long one, long two, long three, long four, long five)
{
long r = __sys_call5 (sys_call, one, two, three, four, five);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}

View File

@ -1,6 +1,8 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2018,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* This file is part of GNU Mes.
*
@ -18,14 +20,13 @@
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/syscall.h>
#include <syscall.h>
#include <sys/stat.h>
#include "mes/lib-mini.h"
int
chmod (char const *file_name, int mask)
void
_exit (int status)
{
long long_file_name = file_name;
long long_mask = mask;
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
asm ("rd_a0 rs1_fp !-8 ld");
asm ("rd_a7 !93 addi # SYS_exit");
asm ("ecall");
// no need to read return value
}

View File

@ -0,0 +1,34 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#include "mes/lib-mini.h"
void
_write (int filedes, void const *buffer, size_t size)
{
asm ("rd_a0 rs1_fp !-8 ld");
asm ("rd_a1 rs1_fp !-16 ld");
asm ("rd_a2 rs1_fp !-24 ld");
asm ("rd_a7 !64 addi # SYS_write");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}

View File

@ -0,0 +1,53 @@
## Copyright (C) 2021 Andrius Štikonas
## Copyright (C) 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
## Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
##
## This file is part of stage0.
##
## stage0 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.
##
## 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/>.
:_start
rd_fp rs1_sp mv ; Protect stack pointer
; Prepare argv
rd_a0 rs1_fp !8 addi ; ARGV_address = FP + 8
rd_sp rs1_sp !-8 addi
rs1_sp rs2_a0 sd ; Put argv on the stack
; Prepare envp
rd_a0 rs1_fp mv ; Address we need to load from
rd_a0 rs1_a0 ld ; Get ARGC
rd_a0 rs1_a0 !2 addi ; OFFSET = ARGC + 2
rd_a0 rs1_a0 rs2_x3 slli ; OFFSET = OFFSET * WORDSIZE
rd_a0 rs1_fp rs2_a0 add ; ENVP_address = RSP + OFFSET
rd_sp rs1_sp !-8 addi
rs1_sp rs2_a0 sd ; Put envp on the stack
; Stack offset
rd_fp rs1_fp !8 addi
; Init libc
rd_ra $FUNCTION___init_io jal
; Call main function
rd_ra $FUNCTION_main jal
; Put return value on the stack so that _exit gets it
rd_sp rs1_sp !-16 addi
rs1_sp rs2_a0 sd
; Exit to kernel
rd_a0 rs1_sp ld
rd_a7 !93 addi ; Syscall for exit
ecall ; Exit with code in a0

View File

@ -0,0 +1,34 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2022 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/>.
*/
#include "mes/lib-mini.h"
int __stdin;
int __stdout;
int __stderr;
char **environ;
int main (int argc, char **argv, char **envp);
/* FIXME: this is going to be called `FUNCTION__start' */
//#int
//#_start ()
//#{
//# ..
//#}

View File

@ -0,0 +1,183 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2020,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#include <errno.h>
#include <linux/riscv64/syscall.h>
long
__sys_call (long sys_call)
{
asm ("rd_a7 rs1_fp !-8 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
long
__sys_call1 (long sys_call, long one)
{
asm ("rd_a7 rs1_fp !-8 ld");
asm ("rd_a0 rs1_fp !-16 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
long
__sys_call2 (long sys_call, long one, long two)
{
asm ("rd_a7 rs1_fp !-8 ld");
asm ("rd_a0 rs1_fp !-16 ld");
asm ("rd_a1 rs1_fp !-24 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
long
__sys_call3 (long sys_call, long one, long two, long three)
{
asm ("rd_a7 rs1_fp !-8 ld");
asm ("rd_a0 rs1_fp !-16 ld");
asm ("rd_a1 rs1_fp !-24 ld");
asm ("rd_a2 rs1_fp !-32 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
long
__sys_call4 (long sys_call, long one, long two, long three, long four)
{
asm ("rd_a7 rs1_fp !-8 ld");
asm ("rd_a0 rs1_fp !-16 ld");
asm ("rd_a1 rs1_fp !-24 ld");
asm ("rd_a2 rs1_fp !-32 ld");
asm ("rd_a3 rs1_fp !-40 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
long
__sys_call5 (long sys_call, long one, long two, long three, long four, long five)
{
asm ("rd_a7 rs1_fp !-8 ld");
asm ("rd_a0 rs1_fp !-16 ld");
asm ("rd_a1 rs1_fp !-24 ld");
asm ("rd_a2 rs1_fp !-32 ld");
asm ("rd_a3 rs1_fp !-40 ld");
asm ("rd_a4 rs1_fp !-48 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
long
_sys_call (long sys_call)
{
long r = __sys_call (sys_call);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call1 (long sys_call, long one)
{
long r = __sys_call1 (sys_call, one);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call2 (long sys_call, long one, long two)
{
long r = __sys_call2 (sys_call, one, two);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call3 (long sys_call, long one, long two, long three)
{
long r = __sys_call3 (sys_call, one, two, three);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call4 (long sys_call, long one, long two, long three, long four)
{
long r = __sys_call4 (sys_call, one, two, three, four);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}
long
_sys_call5 (long sys_call, long one, long two, long three, long four, long five)
{
long r = __sys_call5 (sys_call, one, two, three, four, five);
if (r < 0)
{
errno = -r;
r = -1;
}
else
errno = 0;
return r;
}

View File

@ -0,0 +1,33 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#include "mes/lib-mini.h"
#include "linux/riscv64/syscall.h"
void
_exit (int status)
{
asm ("rd_a0 rs1_fp !16 ld");
asm (RISCV_SYSCALL(SYS_exit));
asm ("ecall");
// no need to read return value
}

View File

@ -0,0 +1,35 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#include "mes/lib-mini.h"
#include "linux/riscv64/syscall.h"
void
_write (int filedes, void const *buffer, size_t size)
{
asm ("rd_a0 rs1_fp !16 ld");
asm ("rd_a1 rs1_fp !24 ld");
asm ("rd_a2 rs1_fp !32 ld");
asm (RISCV_SYSCALL(SYS_write));
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}

View File

@ -0,0 +1,60 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#include "mes/lib-mini.h"
#include "linux/riscv64/syscall.h"
int main (int argc, char *argv[], char *envp[]);
/* mesc will generate the following preamble:
push ra
push fp
*/
int
_start ()
{
asm ("rd_t1 rs1_fp mv");
asm ("rd_t1 rs1_t1 !0x18 addi"); // 0x10 to skip over pushed fp+ra, 0x8 to skip over argc
asm ("rd_t5 rs1_fp !0x10 addi"); // 0x10 to skip over pushed fp+ra
asm ("rd_t0 rs1_t5 ld");
asm ("rd_t0 rs1_t0 !1 addi");
asm ("rd_t5 !3 addi"); // skip over all arguments and the final NULL
asm ("rd_t0 rs1_t0 rs2_t5 sll");
asm ("rd_t0 rs1_t0 rs2_t1 add");
asm ("rd_sp rs1_sp !-8 addi"); // push envp onto stack
asm ("rs1_sp rs2_t0 sd");
asm ("rd_sp rs1_sp !-8 addi"); // push argv onto stack
asm ("rs1_sp rs2_t1 sd");
asm ("rd_t5 rs1_fp !0x10 addi"); // 0x10 to skip over pushed fp+ra
asm ("rd_t0 rs1_t5 ld");
asm ("rd_sp rs1_sp !-8 addi"); // push argc onto stack
asm ("rs1_sp rs2_t0 sd");
__init_io ();
main ();
asm ("rd_a0 rs1_t0 mv");
asm (RISCV_SYSCALL(SYS_exit));
asm ("ecall");
asm ("ebreak");
}

View File

@ -0,0 +1,57 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2016,2017,2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
*
* 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/>.
*/
#include <errno.h>
#include <linux/riscv64/syscall.h>
static long
__sys_call_internal (long sys_call)
{
asm ("rd_a7 rs1_fp !16 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
static long
__sys_call2_internal (long sys_call, long one, long two)
{
asm ("rd_a7 rs1_fp !16 ld");
asm ("rd_a0 rs1_fp !24 ld");
asm ("rd_a1 rs1_fp !32 ld");
asm ("ecall");
asm ("rd_t0 rs1_a0 mv");
}
/* Return < 0 on error (errno-like value from kernel), or 0 on success */
int
__raise (int signum)
{
long pid = __sys_call_internal (SYS_getpid);
if (pid < 0)
return pid;
else
return __sys_call2_internal (SYS_kill, pid, signum);
}

Some files were not shown because too many files have changed in this diff Show More