Commit Graph

2168 Commits

Author SHA1 Message Date
Jan (janneke) Nieuwenhuizen 299a9ea369
tests: Add 70-function-modulo.c.
* lib/tests/scaffold/70-function-modulo.c: New file.
* build-aux/check-mescc.sh (tcc_tests): Add it.
2020-12-29 14:24:20 +01:00
Jan (janneke) Nieuwenhuizen 8c85bccd56
tests: 70-strchr.c: Rewrite for TinyCC.
* lib/tests/string/70-strchr.c (main): Use char* hello for comparison.
Allows for duplication of "hello" string.
2020-12-29 14:24:19 +01:00
Jan (janneke) Nieuwenhuizen 614c9146ba
test: scaffold/54-argv.c: Support running with TinyCC.
This fixes running as lib/tests/scaffold/54-argv-i686-unknown-linux-gnu-tcc.

* lib/tests/scaffold/54-argv.c (main): Compare only first 26 characters
of argv[0].
2020-12-29 14:24:18 +01:00
Jan (janneke) Nieuwenhuizen 612714b26b
mescc: Mes C Library: Split _exit.c, _write.c from mini.c.
* lib/freebsd/x86-mes-gcc/mini.c: Split into...
* lib/freebsd/x86-mes-gcc/_exit.c: ...this, and...
* lib/freebsd/x86-mes-gcc/_write.c: ...this.
* lib/freebsd/x86-mes-mescc/mini.c: Slpit into...
* lib/freebsd/x86-mes-mescc/_exit.c: ...this, and...
* lib/freebsd/x86-mes-mescc/_write.c: ...this.
* lib/gnu/x86-mes-gcc/mini.c: Split into...
* lib/gnu/x86-mes-gcc/_exit.c: ...this, and...
* lib/gnu/x86-mes-gcc/_write.c: ...this.
* lib/linux/arm-mes-gcc/mini.c: Split into...
* lib/linux/arm-mes-gcc/_exit.c: ...this, and...
* lib/linux/arm-mes-gcc/_write.c: ...this.
* lib/linux/arm-mes-mescc/mini.c: Split into...
* lib/linux/arm-mes-mescc/_exit.c: ...this, and...
* lib/linux/arm-mes-mescc/_write.c: ...this.
* build-aux/configure-lib.sh (libc_mini_shared_SOURCES): Replace mini.c
with add _exit.c, _write.c.
* simple.sh: Update accordingly.
2020-12-29 14:24:18 +01:00
Danny Milosavljevic d2d3844738
mescc: define int64_t and uint64_t only if it's possible to define them as
exactly 64 bits.

* include/stdint.h[__SIZEOF_LONG_LONG__ != 8]: Remove typedefs for int64_t,
uint16_t.
2020-12-29 14:24:18 +01:00
Jan (janneke) Nieuwenhuizen 54fca6cad9
mescc: Add __SIZEOF defines for int, long, long long.
* module/mescc/mescc.scm (arch-get-define): Rename
to...  (arch-get-defines): ...this.  Return a list of defines: Also
adding __SIZEOF_INT__, __SIZEOF_LONG__, and add __SIZEOF_LONG_LONG__ if
it's >=8.
(mescc:preprocess, c->info): Update callers.
* include/stdint.h[!__SIZEOF_LONG_LONG__]: Remove typedefs for int64_t,
uint16_t.
2020-12-29 14:24:17 +01:00
Jan (janneke) Nieuwenhuizen 2c3e96bcfc
ARM: Add fake asm for setjmp.c.
* lib/arm-mes-gcc/setjmp.c (longjmp, setjmp)[__TINYC__]: Add fake asm.
2020-12-29 14:24:17 +01:00
Jan (janneke) Nieuwenhuizen 9553e33379
ARM: Add fake asm for syscall.c.
* lib/linux/arm-mes-gcc/syscall.c (__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4) [__TINYC__]: Add fake asm.
2020-12-29 14:24:16 +01:00
Jan (janneke) Nieuwenhuizen 8062b7cd21
ARM: Add fake asm for mini.c.
* lib/linux/arm-mes-gcc/mini.c (_exit, _write)[__TINYC__]: Add fake asm.
2020-12-29 14:24:15 +01:00
Jan (janneke) Nieuwenhuizen ae3e50f5b3
ARM: Add fake asm for crt1.c.
* lib/linux/arm-mes-gcc/crt1.c (_start)[__TINYC__]: Use fake asm.
2020-12-29 14:24:15 +01:00
Jan (janneke) Nieuwenhuizen 5eaefeac38
mescc: Mes C Library: Support ARM tcc: Add crti.c, crtn.c.
* lib/linux/arm-mes-gcc/crti.c: New file.
* lib/linux/arm-mes-gcc/crtn.c: New file.
2020-12-29 14:24:14 +01:00
Jan (janneke) Nieuwenhuizen 74e0ed606c
ARM: libtcc1: Add div.c, __memcpy, __memmove, __memset.
* build-aux/configure-lib.sh (libtcc1_SOURCES)[arm]: Add div.c,
__memcpy, __memmove, __memset.
* build-aux/build-source-lib.sh: Generate libtcc1.
2020-12-29 14:24:14 +01:00
Jan (janneke) Nieuwenhuizen def9c6c330
mescc: Mes C Library: Support ARM tcc: Add __memset.
* lib/string/__memset.c: New file.
* include/mes/lib.h (__memset): Add prototype.
2020-12-29 14:24:13 +01:00
Jan (janneke) Nieuwenhuizen f0c1f4c4d2
mescc: Mes C Library: Support ARM tcc: Add __memmove.
* lib/string/__memmove.c: New file.
* include/mes/lib.h (__memmove): Add prototype.
2020-12-29 14:24:12 +01:00
Jan (janneke) Nieuwenhuizen 15d860d334
mescc: Mes C Library: Support ARM tcc: Add __memcpy.
* lib/string/__memcpy.c: New file.
* include/mes/lib.h (__memcpy): Add prototype.
2020-12-29 14:24:12 +01:00
Jan (janneke) Nieuwenhuizen 4e092fdedd
mescc: Mes C Library: abort: Avoid __raise for TinyCC.
* lib/stdlib/abort.c: Use "raise" instead of __raise.
2020-12-29 14:24:11 +01:00
Jan (janneke) Nieuwenhuizen 68fc0e6ec6
doc: Update 'AUTHORS'.
* AUTHORS: Add Natalie Kopaczewski.
2020-12-29 14:24:11 +01:00
Jan (janneke) Nieuwenhuizen 8fb2ab4439
test: Split-off scaffold/60-math-itoa.c.
* lib/tests/scaffold/60-math.c (main): Move itoa tests to...
* lib/tests/scaffold/60-math-itoa.c: ...this new file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2020-12-29 14:24:10 +01:00
Jan (janneke) Nieuwenhuizen a810bc50e0
test: Split-off 36-compare-arithmetic-negative.c.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Move negative
divisions to...
* lib/tests/scaffold/36-compare-arithmetic-negative.c: ...new file here.
* build-aux/check-mescc.sh (mes_tests): Add it.
2020-12-29 14:24:10 +01:00
Jan (janneke) Nieuwenhuizen f478ab3805
test: ARM: 08-assign.c: Avoid assembly for tcc.
* lib/tests/scaffold/08-assign.c (main)[__arm__ && __TINYC__]: Avoid assembly.
2020-12-29 14:24:09 +01:00
Jan (janneke) Nieuwenhuizen 6a8f67efa2
test: Split-off 50-strcmp-itoa.c
* lib/tests/string/50-strcmp.c (main): Move itoa tests to...
* lib/tests/string/50-strcmp-itoa.c: ...this new file.
* build-aux/check-mescc.sh (mes_tests): Add it.
2020-12-29 14:24:09 +01:00
Jan (janneke) Nieuwenhuizen ddfb34a40d
ARM: libtcc1: Add __divsi3, __modsi3, __udivsi3, __umodsi3.
* lib/libtcc1.c (__divsi3, __modsi3, __udivsi3, __umodsi3): New functions.
2020-12-29 14:24:09 +01:00
Jan (janneke) Nieuwenhuizen 40e0cb11b9
ARM: libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
* lib/libtcc1.c (__floatdisf, __floatdidf)[__arm__]: New stubs.
2020-12-29 14:24:08 +01:00
Jan (janneke) Nieuwenhuizen c340ca3e27
libtcc1: Add stubs __floatundidf, __fixunsdfdi, __fixunsdfsi.
* lib/libtcc1.c (__floatundidf, __fixunsdfdi, __fixunsdfsi): New stubs.
2020-12-29 14:24:07 +01:00
Jan (janneke) Nieuwenhuizen e2da1c5c7b
ARM: libtcc1: Add support for TinyCC.
* lib/libtcc1.c: (__udivdi3, __umoddi3, __lshrdi3, __ashldi3,
__fixunsxfdi)[__arm__ && __TINYC__]: Use __mesabi functions.
2020-12-29 14:24:07 +01:00
Jan (janneke) Nieuwenhuizen 9694354633
libtcc1: Remove mesabi dependencies for TinyCC.
* lib/libtcc1.c (__divdi3, __moddi3, __udivdi3, __umoddi3, __lshrdi3,
__ashldi3, __ashrdi3, __floatundixf, __fixunsxfdi, __fixxfdi,
__fixsfdi)[__TINYC__]: No stub printing.
2020-12-29 14:24:06 +01:00
Jan (janneke) Nieuwenhuizen cb79d8ffb1
mescc: Mes C Library: div: Avoid __raise for TinyCC.
* lib/mes/div.c (__raise)[__TINYC__]: New macro.
2020-12-29 14:24:06 +01:00
Jan (janneke) Nieuwenhuizen 0727fd39cc
mescc: Mes C Library: Add __mesabi_umod, __mesabi_udiv.
* lib/mes/div.c (__mesabi_umod, __mesabi_udiv): New functions.
* include/mes/lib.h: Add prototypes.
2020-12-29 14:24:06 +01:00
Danny Milosavljevic 62205a9925
ARM: Implement long division.
* lib/mes/div.c (__mesabi_log2i): New procedure.
(__mesabi_uldiv1): New procedure.
(__mesabi_uldiv): Use it.

Co-Authored-By: Nathalie Kopaczewski <natkopa@gmail.com>
2020-12-29 14:24:05 +01:00
Danny Milosavljevic 80e08cf1ef
ARM: Special-case setjmp struct for gcc with mes libc.
* include/setjmp.h (__jmp_buf): Special-case setjmp struct for gcc with mes
libc.
2020-12-29 14:24:05 +01:00
Jan (janneke) Nieuwenhuizen 04c058fe5e
tests: Add 70-ternary-arithmetic-argument.c.
* lib/tests/scaffold/70-ternary-arithmetic-argument.c: New file.
* build-aux/check-mescc.sh (tcc_tests, xfail_tests): Add it.
2020-12-29 14:24:05 +01:00
Danny Milosavljevic a288598a06
ARM: Speed up __mesabi_uldiv for powers-of-two divisors.
* lib/mes/div.c (__mesabi_uldiv): Speed up division for powers-of-two
divisors.
2020-12-29 14:24:04 +01:00
Jan (janneke) Nieuwenhuizen a8e2cc86e9
ARM: Revert to 4 byte types only.
* module/mescc/armv4/info.scm (armv4:type-alist): Use size 4 for long
longs too.
2020-12-29 14:24:04 +01:00
Jan (janneke) Nieuwenhuizen e488ba3daf
guix: Switch to guile-3.0-latest.
* guix/git/mes.scm (nyacc)[inputs]: New field.
(mes)[inputs]: Update to guile-latest.
2020-12-29 14:24:03 +01:00
Jan (janneke) Nieuwenhuizen b601eb64af
mescc: Mes C Library: ntoab: Use unsigned base.
This fixes 60-math, 60-math-itoa, 70-printf-simple, 70-printf.

* lib/mes/ntoab.c (ntoab): Use unsigned base.
* include/mes/lib.h: Update prototype.
2020-12-13 22:19:06 +01:00
Jan (janneke) Nieuwenhuizen a0560aff67
configure: Use GUILD_OPTIMIZE=-O1 for Guile-3.
* configure (main): Set guild_optimize to "-O1" for Guile-3.
* build-aux/config.make.in (GUILD_OPTIMIZE): New variable.
* build-aux/export.make (GUILD_OPTIMIZE): Export if set.
* build-aux/config.sh.in (GUILD_OPTIMIZE): New variable.
* build-aux/build-guile.sh: Use it.
2020-10-07 14:09:24 +02:00
Jan (janneke) Nieuwenhuizen fa4147a284
mescc: Use signed division for x86, x86_64 when appropriate.
This fixes 36-compare-arithmetic.c

* module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Do not reset
signed?.
* module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Use unique exit
value per failure.
2020-10-06 19:53:02 +02:00
Jan (janneke) Nieuwenhuizen 8429a4b0b6
build: Bump MESCC_STACK.
This fixes running ./pre-inst-env mescc ...

* scripts/mescc.in (MES_STACK): Bump to 6000000.
2020-10-06 16:45:52 +02:00
Jan (janneke) Nieuwenhuizen 252a0df25a
guix: nyacc: Update to 1.00.2.
* guix/git/mes.scm (nyacc): Rename to...
(nyacc-0.99): ...this.
(nyacc): New variable.
2020-10-06 16:45:51 +02:00
Jan (janneke) Nieuwenhuizen 14caa774f7
Revert "guix: nyacc: Update to 1.03.0."
This does not work yet, sorry for the noise.

This reverts commit 70b2942286.
2020-10-06 16:43:12 +02:00
Jan (janneke) Nieuwenhuizen 70b2942286
guix: nyacc: Update to 1.03.0.
* guix/git/mes.scm (nyacc): Rename to...
(nyacc-0.99): ...this.
(nyacc): New variable.
(mes): Update to guile-3.0.
2020-10-06 13:58:33 +02:00
Jan (janneke) Nieuwenhuizen fe60f9a3f7
build: Support guile-3.0.
* configure (main): Prefer guile-3.
2020-10-06 13:54:09 +02:00
Jan (janneke) Nieuwenhuizen 0db5bc48f5
build: Support make check TESTS=... XFAIL=... for mescc tests.
* build-aux/config.sh.in (TESTS, XFAIL_TESTS): Export.
* build-aux/export.make (TESTS, XFAIL_TESTS): Export if set.
* build-aux/check-mescc.sh (TESTS, XFAIL_TESTS): Allow user override.
2020-10-06 13:54:09 +02:00
Jan (janneke) Nieuwenhuizen 9a1c50c1cf
mes: Support for gcc-10.
Fixes <https://lists.gnu.org/archive/html/bug-mes/2020-07/msg00000.html>.

Reported by Vagrant Cascadian <vagrant@reproducible-builds.org>.

* src/string.c (MAX_STRING): Remove duplicate definition.
2020-10-06 13:14:22 +02:00
Jan (janneke) Nieuwenhuizen 84ff05a839
mescc: Mes C Library: Support gcc-10.
See <https://lists.gnu.org/archive/html/bug-mes/2020-07/msg00000.html>.

Reported by Vagrant Cascadian <vagrant@reproducible-builds.org>.

* include/setjmp.h (jmp_buf): Remove.
* include/errno.h (errno): Mark extern.
* include/mes/lib-mini.h (environ, errno, __stdin, __stdout, __stderr):
Likewise.
* lib/mes/globals.c: New file; define them.
* build-aux/configure-lib.sh (libc_mini_shared_SOURCES,
libmescc_SOURCES): Add it.
* build-aux/test-c.sh: Always use -l c-mini as a minimum.
2020-10-06 13:13:44 +02:00
Jan (janneke) Nieuwenhuizen be87ada6b5
build: Resurrect running mescc from elsewhere.
After setting-up a buld environment, running something like

   ~/src/mes/wip/pre-inst-env mescc -v -v ~/src/mes/wip/scaffold/main.c

works again.

TODO: Make this less complex.

 * The mescc-lib (and gcc-lib) build directories do not help;
   these were introduced to support `wip-autotools'.
 * We used to opt for short *PATH variables: "." rather than
   /gnu/store/.... or /home/janneke/src/mes/master to avoid
   filling the MES arena. XXX Has this been solved?
 * In the Guix bootstrap, we run module/mescc.scm directly
       $MES -e '(mescc)' module/mescc.scm

   ...so that's why these overrides started to appear in multiple
   places.

* build-aux/pre-inst-env.in (MES_UNINSTALLED): New variable.
* scripts/mescc.in (includedir,libdir): Use it to override these.
* module/mescc/mescc.scm (arch-find): Use it to add <lib>-messc.
2020-10-06 10:44:50 +02:00
Jan (janneke) Nieuwenhuizen 0650e08744
mescc: Mes C Library: x86_64: Add syscall-internal.
This resurrects the x86_64 build.

* lib/linux/x86_64-mes-gcc/syscall-internal.c (__sys_call_internal),
lib/linux/x86_64-mes-mescc/syscall-internal.c: New file.
2020-10-06 10:05:33 +02:00
Jan (janneke) Nieuwenhuizen e16d1e469a
mescc: Mes C Library: x86_64: Introduce __sys_call and friends.
This prepares for x86_64 syscall-internal.

* lib/linux/x86_64-mes-gcc/syscall.c (__sys_call, __sys_call1,
__sys_call2, __sys_call3, __sys_call4): New functions, copied from ...
(_sys_call, _sys_call1, _sys_call2, _sys_call3, _sys_call4): ... these.
Use them, handle errno only.
2020-10-06 10:05:33 +02:00
Jan (janneke) Nieuwenhuizen 1c128c7a9f
mescc: Mes C Library: x86: Use long for syscalls.
The Linux signature uses long, also this allows for making
_sys_call and friends architecture-independent.

* lib/linux/x86-mes-mescc/syscall-internal.c (__sys_call_internal,
__sys_call2_internal): Use long.  Update callers.
* lib/linux/x86-mes-mescc/syscall.c (__sys_call, __sys_call1,
__sys_call2, __sys_call3, __sys_call4, _sys_call, _sys_call1,
_sys_call2, _sys_call3, _sys_call4): Likewise.
2020-10-06 10:05:33 +02:00
Jan (janneke) Nieuwenhuizen 5f8a424328
mescc: Mes C Library: Remove redundant prototypes.
* lib/linux/x86-mes-gcc/syscall.c(__sys_call, __sys_call1, __sys_call2,
__sys_call3, __sys_call4): Remove prototype.
2020-10-06 10:05:33 +02:00