W. J. van der Laan
c8dfa47e10
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-11-05 09:40:37 +01:00
W. J. van der Laan
9d7360cca6
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-11-05 09:39:29 +01:00
W. J. van der Laan
04e6fdad13
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-11-05 09:39:29 +01:00
W. J. van der Laan
e07d1052aa
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-11-05 09:39:29 +01:00
W. J. van der Laan
f5d6a7b100
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-11-05 09:39:29 +01:00
W. J. van der Laan
6051a6e91e
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-11-05 09:39:29 +01:00
W. J. van der Laan
2eb0085ba0
lib: Add RISC-V64 Linux syscall numbers header.
...
* include/linux/riscv64/syscall.h: New file: list relevant syscall
number constants.
2023-11-05 09:39:29 +01:00
Jan (janneke) Nieuwenhuizen
9ae3426c96
lib: Document syscalls.
...
* include/linux/SYSCALLS: New file.
2023-11-05 09:39:29 +01:00
W. J. van der Laan
2848cf6a18
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-11-05 09:39:29 +01:00
W. J. van der Laan
bf5e8b245e
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-11-05 09:39:29 +01:00
W. J. van der Laan
5d64961c83
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-11-05 09:39:29 +01:00
W. J. van der Laan
edf397038a
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-11-05 09:39:29 +01:00
Ekaitz Zarraga
acfead04ed
DRAFT lib: Make objdump work on binaries in x86-linux.
...
* lib/linux/x86-mes/elf32-header.hex2: Fix header sizes for objdump.
2023-11-05 09:39:06 +01:00
Ekaitz Zarraga
1120073d8d
DRAFT lib: Make objdump work on binaries in x86_64-linux.
...
* lib/linux/x86_64-mes/elf64-header.hex2: Fix header sizes for objdump.
2023-11-05 09:39:00 +01:00
Janneke Nieuwenhuizen
83f26445b0
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-11-05 09:38:57 +01:00
Janneke Nieuwenhuizen
592a612777
DRAFT mescc: Consider truncate after each shift operation.
...
* module/mescc/compile.scm (expr->register): After lshift and rshift,
use convert-r0. Tuncate on largest of default/int or size of first
operand.
2023-11-05 09:38:53 +01:00
Andrius Štikonas
05e945c0a8
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-11-05 09:36:26 +01:00
Andrius Štikonas
2e13faa3c2
mescc: Fix hex2:immediate8 to work with mes/m2-compiled mes.
...
* module/mescc/M1.scm (hex2:immediate8): Remove mesc? exception.
(mesc?): Remove.
2023-11-05 09:36:26 +01:00
Janneke Nieuwenhuizen
516b5849f2
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-11-05 09:36:26 +01:00
Janneke Nieuwenhuizen
f32b5f5510
core: Avoid displaying truncated 64bit values.
...
* src/display.c (display_helper): Use `ltoa' instead of `itoa'.
2023-11-05 09:36:26 +01:00
Andrius Štikonas
1650f0caae
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-11-05 09:36:26 +01:00
Andrius Štikonas
3a514386c5
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-11-05 09:36:26 +01:00
Janneke Nieuwenhuizen
73acbc37b1
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-11-05 09:36:26 +01:00
Jan (janneke) Nieuwenhuizen
189ea8eb9d
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-11-05 09:36:26 +01:00
Janneke Nieuwenhuizen
002dc6253a
build: Generate reproducible doc/version.texi.
...
* build-aux/GNUmakefile.in (doc/version.texi): Use timestamp from git.
2023-11-05 09:36:11 +01:00
Janneke Nieuwenhuizen
b6bad13883
build: Help help2man generate reproducible man-pages.
...
* build-aux/GNUmakefile.in (SOURCE_DATE_EPOCH): New variable.
2023-11-05 09:36:11 +01:00
Janneke Nieuwenhuizen
6aa77fe162
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-11-05 09:36:11 +01:00
Janneke Nieuwenhuizen
a0c9c0aedb
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-11-05 09:36:11 +01:00
Janneke Nieuwenhuizen
0f0dad6436
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-11-05 09:36:11 +01:00
Ekaitz Zarraga
2be2de827f
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-11-05 09:36:11 +01:00
Ekaitz Zarraga
4134285e8e
lib: tests: Add 16-cast.
...
* lib/tests/scaffold/16-cast.c: Add file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2023-11-05 09:36:11 +01: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 Zarraga
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 Zarraga
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 Zarraga
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 Zarraga
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