Commit Graph

2147 Commits

Author SHA1 Message Date
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
Jan (janneke) Nieuwenhuizen c11a721c36
mescc: Mes C Library: Whitespace fixes.
* lib/linux/signal.c (signal): Whitespace fixes.
* lib/linux/time.c (time): Likewise.
2020-10-06 10:04:42 +02:00
Danny Milosavljevic 443f662361
command line: Support "mescc --print-libgcc-file-name".
* module/mescc.scm (parse-opts): Add "--print-libgcc-file-name".
2020-10-06 10:04:41 +02:00
Danny Milosavljevic 237dd8a0f0
Distinguish between gcc and mescc; select LIBS accordingly.
* build-aux/check.sh.in: Distinguish between gcc and mescc;
add MES_CHECKING_BUILTIN_LIBS.
* build-aux/test-c.sh: Use it to select LIBS accordingly.
2020-10-06 10:04:41 +02:00
Danny Milosavljevic 56f859200e
Make "raise" available for gcc use.
* build-aux/configure-lib.sh (libc_tcc_SOURCES): Move lib/posix/raise.c,
lib/linux/getpid.c, lib/linux/kill.c to...
(libc_SOURCES): ...here.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 0b79ca74ea
build: Use libgcc.a instead of libmescc.a for gcc. 2020-10-06 10:04:29 +02:00
Danny Milosavljevic afac5847e7
div: Remove libgcc-compatible API.
* lib/mes/div.c (__aeabi_idiv): Delete procedure.
(__aeabi_idivmod): Delete procedure.
(__aeabi_uidivmod): Delete procedure.
(__aeabi_uidiv): Delete procedure.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 9db916bba1
Revert syscall split (of commit 55d38162be);
just copy the two syscalls I need for __raise instead.

* lib/linux/arm-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/arm-mes-gcc/syscall.c: ...here.
* lib/linux/arm-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/arm-mes-mescc/syscall.c: ...here.
* lib/linux/x86-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/x86-mes-gcc/syscall.c: ...here.
* lib/linux/x86-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure.
(__sys_call2_internal): New procedure.
(__raise): Use them.
(__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to...
* lib/linux/x86-mes-mescc/syscall.c: ...here.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 3ed3b51371
div: Add comment about __aeabi_idiv.
* lib/mes/div.c (__aeabi_idiv): Add comment.
2020-10-06 10:04:29 +02:00
Danny Milosavljevic 95c71f3178
div: Move __aeabi_idiv to __GNUC__; introduce __mesabi_idiv.
* lib/mes/div.c (__aeabi_idiv): Move for conditional compilation.
(__mesabi_idiv): New procedure.
* module/mescc/armv4/as.scm (armv4:r0/r1): Use __mesabi_idiv.
2020-10-06 10:04:28 +02:00
Danny Milosavljevic 931ae9280e
build: Make raise available in libc+tcc for libgcc.
* build-aux/configure-lib.sh (libc_gnu_SOURCES): Remove raise, getpid, kill.
(libc_tcc_SOURCES): Add raise, getpid, kill.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen eba5c15088
mescc: Add signed char.
* module/mescc/armv4/info.scm (armv4:type-alist): Add signed char.
* module/mescc/i386/info.scm (i386:type-alist): Likewise.
* module/mescc/x86_64/info.scm (x86_64:type-alist): Likewise.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen 3973e87219
ARM: Add missing instruction.
* lib/arm-mes/arm.M1: Add missing define.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen 1c06c0170a
ARM: as: Fix ldrsb_ typo.
(armv4:byte-r0-mem->r1-mem): : Add missing "_" to ldrsb_.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen a945bee494
ARM: as: Fix strh__ typo.
* module/mescc/armv4/as.scm (armv4:word-r0-mem->r1-mem): Add missing "_"
to strh__.
2020-10-06 10:04:28 +02:00
Jan (janneke) Nieuwenhuizen ddfdd1cb7f
mescc: Do not crash when attemting to link files without extension.
* module/mescc/mescc.scm (replace-suffix): Add ELSE clause to IF for
base; add IF for old-suffix.
2020-10-06 10:04:27 +02:00
Jan (janneke) Nieuwenhuizen ae14a08aad
doc: Fix typos in `HACKING`.
* HACKING (SETUP): Typos.
2020-10-06 10:03:21 +02:00
Jan (janneke) Nieuwenhuizen f3f405a83a
ARM: as: Guile compile fix.
* module/mescc/armv4/as.scm (optimize-immediate): Do not unquote compare
functions (and numbers).
2020-08-24 11:24:02 +02:00
Danny Milosavljevic e3aba5d464
test: Make 7l-struct-any-size-array-simple compatible with default ARM gcc.
* lib/tests/scaffold/7l-struct-any-size-array-simple.c: Make "signed"
explicit in signed char types.
2020-08-22 21:01:45 +02:00
Danny Milosavljevic 7e23d98494
test: Make 7r-sign-extend compatible with default ARM gcc.
* lib/tests/scaffold/7r-sign-extend.c: Make "signed" explicit in
signed char types.
2020-08-22 21:01:36 +02:00
Danny Milosavljevic 047014e704
build: Fixup cleaning of armv4.
* build-aux/GNUmakefile.in (clean): Clean armv4 go files.
2020-08-22 14:09:54 +02:00
Danny Milosavljevic acf86208ed
ARM: Support comparing 32 bit values.
* lib/arm-mes/arm.M1 (cmp____$i32,%r0): New macro.
(cmp____$i32,%r1): New macro.
(cmp____$i32,%r2): New macro.
2020-06-19 02:45:51 +02:00