Commit graph

1932 commits

Author SHA1 Message Date
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
Danny Milosavljevic d9bda45853
ARM: Handle signed values in r-byte-mem-add, r-word-mem-add.
* lib/arm-mes/arm.M1 (ldrb___%r0,(%r1)): Delete macro.
(ldrh___%r0,(%r0)): Delete macro.
(ldrsh__%r0,(%r0)): New macro.
(ldrh___%r0,(%r1)): Delete macro.
(ldrsh__%r0,(%r1)): New macro.
(ldrh___%r1,(%r1)): Delete macro.
(ldrsh__%r1,(%r1)): New macro.
(ldrh___%r2,(%r2)): Delete macro.
(ldrsh__%r2,(%r2)): New macro.
(ldrh___%r3,(%r3)): Delete macro.
(ldrsh__%r3,(%r3)): New macro.
(ldrsb__%r0,(%r1)): New macro.
* module/mescc/armv4/as.scm (armv4:r-byte-mem-add): Use ldrsb.
(armv4:r-word-mem-add): Use ldrsh, add____$i32,(%r0).
(armv4:word-mem->r): Use ldrsh.
2020-06-19 02:45:33 +02:00
Danny Milosavljevic 821d1b8fe9
ntoab: Simplify LONG_MIN case.
* lib/mes/ntoab.c (ntoab): Simplify LONG_MIN case.

Co-Authored-By: Nathalie Kopaczewski <natkopa@gmail.com>
2020-06-17 00:21:57 +02:00
Danny Milosavljevic aaa174382e
ARM: Factor out optimize-immediate.
* module/mescc/armv4/as.scm (optimize-immediate): New macro.
(immediate->r0): Use it.
(armv4:value->r): Use it.
(armv4:local->r): Use it.
(armv4:r->local+n): Use it.
(armv4:r-byte-mem-add): Use it.
(armv4:r-word-mem-add): Use it.
(armv4:local-ptr->r): Use it.
(armv4:r+value): Use it.
(armv4:r-cmp-value): Use it.
(armv4:r0+value): Use it.
(armv4:byte-r->local+n): Use it.
(armv4:word-r->local+n): Use it.
2020-06-16 21:07:23 +02:00
Danny Milosavljevic 341682f474
ARM: Avoid using (abs INT_MIN) and (- INT_MIN).
* module/mescc/armv4/as.scm (immediate->r0): Inline abs.
(armv4:value->r): Inline abs.
(armv4:local->r): Inline abs.
(armv4:r->local+n): Inline abs.
(armv4:r-byte-mem-add): Inline abs.
(armv4:r-word-mem-add): Inline abs.
(armv4:local-ptr->r): Inline abs.
(armv4:r+value): Inline abs.
(armv4:r-cmp-value): Inline abs.
(armv4:r0+value): Inline abs.
(armv4:byte-r->local+n): Inline abs.
(armv4:word-r->local+n): Inline abs.
2020-06-16 17:31:59 +02:00
Danny Milosavljevic 073cfca2b4
build-aux: Increase test timeout to 20 s. 2020-06-16 14:00:10 +02:00
Danny Milosavljevic b11510f4da
ntoab: Handle LONG_MIN case.
* lib/mes/ntoab.c (ntoab): Handle LONG_MIN case.
* lib/tests/scaffold/60-math.c (main): Add test for INT_MIN and hex.
2020-06-15 11:26:43 +02:00
Danny Milosavljevic 3b312ca983
core: Fix unreadchar on string port when unreading EOF.
* src/posix.c (unreadchar): Fix on string port when unreading EOF.
2020-06-14 22:41:31 +02:00
Danny Milosavljevic 449f3c7e00
Add ARM gcc scaffold assembly.
* lib/linux/arm-mes-gcc/exit-42.S: New file.
* lib/linux/arm-mes-gcc/hello-mes.S: New file.
2020-06-13 19:44:29 +02:00
Danny Milosavljevic 451274bc80
mescc: Add modules for armv4.
* mes/module/mescc/armv4/as.mes: New file.
* mes/module/mescc/armv4/info.mes: New file.
* mes/module/mescc/mescc.mes: Use them.
2020-06-13 19:07:32 +02:00
Danny Milosavljevic 6478476ed7
Implement setjmp for ARM mescc.
* include/setjmp.h: Add ARM case.
* lib/arm-mes-mescc/setjmp.c: New file.
2020-06-12 23:20:17 +02:00
Danny Milosavljevic 48ecb2f29e
test: Test signed division.
* lib/tests/scaffold/36-compare-arithmetic.c (main): Test signed division.
2020-06-10 17:04:55 +02:00
Danny Milosavljevic 3f03574050
ldiv: Work around missing struct return feature.
* lib/mes/div.c (__mesabi_ldiv): Remove return type.
(__mesabi_imod): Adapt call site.
(__aeabi_idiv): Adapt call site and move it to conditional compilation.
(__aeabi_idivmod): Adapt call site.
2020-06-10 15:46:12 +02:00
Jan Nieuwenhuizen 40aa190459
guix: mescc-tools: Update to 0.7.0, adding ARM support.
This brings arm-linux-gnueabihf, aarch64-linux-gnu support.

* guix/git/mes.scm (mescc-tools): Update to 0.7.0.
2020-06-10 15:36:18 +02:00
Jan (janneke) Nieuwenhuizen e9672324f3
dir-locals.el: Add indentation for Guix keywords.
* .dir-locals.el (scheme-mode): Add indentation rules for Guix package
definitions.
2020-06-10 15:34:06 +02:00
Danny Milosavljevic d42f99e6cf
mescc: Mes C Library: Hang at the end if necessary.
* lib/linux/arm-mes-mescc/crt1.c (_start): Hang at the end if necessary.
2020-06-10 13:14:33 +02:00