mes.git
2 months agoRelease 0.20. master v0.20
Jan Nieuwenhuizen [Sun, 8 Sep 2019 07:31:38 +0000 (09:31 +0200)]
Release 0.20.

* configure (VERSION): Update to 0.20.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.

2 months agodoc: Release update.
Jan Nieuwenhuizen [Thu, 20 Dec 2018 06:44:18 +0000 (07:44 +0100)]
doc: Release update.

* BLURB: New file.
* AUTHORS: Update.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/images/gcc-mesboot-graph.dot: Update.
* doc/mes.texi: Update.
* simple.sh: Update.
* doc/announce/ANNOUNCE-0.20: New file.

2 months agoguix: Update mescc-tools to 0.6.1.
Jan Nieuwenhuizen [Mon, 9 Sep 2019 14:39:08 +0000 (16:39 +0200)]
guix: Update mescc-tools to 0.6.1.

* guix/git/mes.scm (mescc-tools): Update to 0.6.1.
* configure: Check for mescc-tools versions 0.6 or higher.

2 months agobuild: Create ascii signature.
Jan Nieuwenhuizen [Sun, 8 Sep 2019 09:10:45 +0000 (11:10 +0200)]
build: Create ascii signature.

* build-aux/GNUmakefile.in (sign): Create ascii signature.

2 months agoguix: Update Nyacc to 0.99.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 15:15:05 +0000 (17:15 +0200)]
guix: Update Nyacc to 0.99.

* guix/git/mes.scm (nyacc): Update to 0.99.

2 months agodoc: Add PORTING.
Jan Nieuwenhuizen [Sun, 3 Mar 2019 19:19:42 +0000 (20:19 +0100)]
doc: Add PORTING.

* PORTING: New file.

2 months agodoc: Typos. Thanks, dddddd.
Jan Nieuwenhuizen [Mon, 22 Apr 2019 17:21:41 +0000 (19:21 +0200)]
doc: Typos. Thanks, dddddd.

* doc/announce/ANNOUNCE-0.11: Typo.
* doc/announce/ANNOUNCE-0.12: Typo.
* doc/announce/ANNOUNCE-0.13: Typo.
* doc/announce/ANNOUNCE-0.14: Typo.

2 months agomescc: Remove dead code. Thanks Mark Weaver.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 14:17:03 +0000 (16:17 +0200)]
mescc: Remove dead code. Thanks Mark Weaver.

* module/mescc/compile.scm (field-size): Remove dead function.

2 months agoguix: Update packaging.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 14:49:00 +0000 (16:49 +0200)]
guix: Update packaging.

* build-aux/manifest.scm (string-append):
* guix/git/mes.scm (nyacc, git-file?): Remove.
(mescc-tools): Bump to 0.6.0.
(%source-dir): New variable.
(mes.git): Ues it.
* guix.scm: Rename from .guix.scm.

2 months agobuild: Do not generate ChangeLog from tarball.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 15:13:39 +0000 (17:13 +0200)]
build: Do not generate ChangeLog from tarball.

* configure (main): Set .git-for-build.
* build-aux/install.sh.in (DESTDIR): Use it as canary to skip
ChangeLog rebuild.

2 months agobuild: Use mesar instead of ar.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 14:44:54 +0000 (16:44 +0200)]
build: Use mesar instead of ar.

* scripts/mesar.in: Rename from ar.in.  Update users.
* build-aux/build.sh.in (LIBS): Update.
* build-aux/check.sh.in (recheck): Likwise.
* build-aux/install.sh.in (DESTDIR): Likwise.
* configure (main): Likwise.
* configure.sh (mes_system): Likwise.
* .gitignore: Update.

2 months agogetopt: Remove old FSF address, thanks Vagrant.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 13:55:07 +0000 (15:55 +0200)]
getopt: Remove old FSF address, thanks Vagrant.

* lib/posix/getopt.c: Remove old FSF address.

2 months agoAdd missing #include.
Danny Milosavljevic [Fri, 5 Jul 2019 15:13:16 +0000 (17:13 +0200)]
Add missing #include.

* lib/tests/scaffold/55-char-array.c: Add missing #include.

2 months agoAdd missing #include.
Danny Milosavljevic [Fri, 5 Jul 2019 15:12:54 +0000 (17:12 +0200)]
Add missing #include.

* lib/tests/io/90-stat.c: Add missing #include.

2 months agoAdd missing #include.
Danny Milosavljevic [Fri, 5 Jul 2019 15:12:28 +0000 (17:12 +0200)]
Add missing #include.

* lib/posix/getcwd.c: Add missing #include.

2 months agosignal: Use SA_RESTORER on x86-64.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 16:52:09 +0000 (18:52 +0200)]
signal: Use SA_RESTORER on x86-64.

* lib/linux/signal.c (signal)[x86_64]: Avoid segfault by setting
SA_RESTORER flag.

2 months agosignal: Add comment on why we don't use the restorer.
Danny Milosavljevic [Thu, 4 Jul 2019 11:22:42 +0000 (13:22 +0200)]
signal: Add comment on why we don't use the restorer.

* lib/linux/signal.c: Add comment on why we don't use the restorer.

2 months agosignal: Remove SA_SIGINFO.
Danny Milosavljevic [Thu, 4 Jul 2019 01:43:32 +0000 (03:43 +0200)]
signal: Remove SA_SIGINFO.

* lib/linux/signal.c (signal): Remove SA_SIGINFO.

2 months agosignal: Don't use custom restorer.
Danny Milosavljevic [Thu, 4 Jul 2019 01:36:19 +0000 (03:36 +0200)]
signal: Don't use custom restorer.

* lib/linux/signal.c (signal): Don't use custom restorer.

2 months agosignal: Use SA_SIGINFO (like glibc).
Danny Milosavljevic [Thu, 4 Jul 2019 01:25:59 +0000 (03:25 +0200)]
signal: Use SA_SIGINFO (like glibc).

* lib/linux/signal.c (_restorer): Rename to...
(_restorer_for_siginfo): ...this.
(signal): Use it.  Use SA_SIGINFO.

2 months agosignal: Make sure that the signal mask is actually unsigned long.
Danny Milosavljevic [Thu, 4 Jul 2019 00:39:11 +0000 (02:39 +0200)]
signal: Make sure that the signal mask is actually unsigned long.

* lib/linux/signal.c (signal): Make sure that the signal mask is actually
unsigned long.

2 months agoDelete "__sigmask".
Danny Milosavljevic [Thu, 4 Jul 2019 00:38:06 +0000 (02:38 +0200)]
Delete "__sigmask".

Follow-up to 6d95b89759d3c598fc84194429ae8c57249daa1a

* lib/linux/signal.c (__sigmask): Delete definition.

2 months agoFix "struct sigaction" structure for rt_sigaction.
Danny Milosavljevic [Thu, 4 Jul 2019 00:21:24 +0000 (02:21 +0200)]
Fix "struct sigaction" structure for rt_sigaction.

* include/signal.h (sigset_t): Increase size.
* lib/linux/signal.c (signal): Use new sigset_t.

2 months agoInherit CFLAGS for mes.
Danny Milosavljevic [Wed, 3 Jul 2019 14:47:42 +0000 (16:47 +0200)]
Inherit CFLAGS for mes.

* build-aux/check.sh.in: Inherit CFLAGS for mes.

2 months agoFix typo.
Danny Milosavljevic [Tue, 2 Jul 2019 23:07:05 +0000 (01:07 +0200)]
Fix typo.

* build-aux/build.sh.in: Fix typo in "CFLAGS".

2 months agotests: Fail early on nonexistent file.
Danny Milosavljevic [Tue, 2 Jul 2019 11:39:41 +0000 (13:39 +0200)]
tests: Fail early on nonexistent file.

* lib/tests/io/90-stat.c (main): Fail early on nonexistent file.

2 months agoopen: Check flags, and use _open2 if applicable.
Danny Milosavljevic [Tue, 2 Jul 2019 01:36:18 +0000 (03:36 +0200)]
open: Check flags, and use _open2 if applicable.

* lib/linux/open.c (open): Check flags; use _open2.

2 months agoldiv: Make rem < 0 if a < 0.
Danny Milosavljevic [Mon, 1 Jul 2019 21:02:19 +0000 (23:02 +0200)]
ldiv: Make rem < 0 if a < 0.

* lib/mes/div.c (ldiv): Make rem < 0 if a < 0.

2 months agoldiv: Handle a == LONG_MIN.
Danny Milosavljevic [Mon, 1 Jul 2019 20:14:11 +0000 (22:14 +0200)]
ldiv: Handle a == LONG_MIN.

* lib/mes/div.c (ldiv): Handle a == LONG_MIN.

2 months agontoab: Use __mesabi_uldiv only for arm.
Jan Nieuwenhuizen [Mon, 9 Sep 2019 14:01:40 +0000 (16:01 +0200)]
ntoab: Use __mesabi_uldiv only for arm.

* lib/mes/ntoab.c (ntoab)[__MESC__ && __arm__]: Use __mesabi_uldiv.
* build-aux/check-mescc.sh (XFAIL_TESTS): 70-printf-simple.c and
70-printf.c now pass for x86_64 mescc.

4 months agoFix ntoab.
Danny Milosavljevic [Mon, 1 Jul 2019 18:04:26 +0000 (20:04 +0200)]
Fix ntoab.

Follow-up to b5b19304b59fefbed923b146ec8c8d495556fa76.

* lib/mes/ntoab.c (ntoab): Fix non-MESC case.

5 months agosignal: Define "_restorer" everywhere except on i386.
Danny Milosavljevic [Tue, 18 Jun 2019 17:26:45 +0000 (19:26 +0200)]
signal: Define "_restorer" everywhere except on i386.

* lib/linux/signal.c: Define "_restorer" everywhere except on i386.

5 months agoClarify our data type choices in "struct stat".
Danny Milosavljevic [Tue, 18 Jun 2019 15:37:10 +0000 (17:37 +0200)]
Clarify our data type choices in "struct stat".

* include/sys/stat.h: Clarify our data type choices in "struct stat".

2 months agotest: Bump timeout.
Jan Nieuwenhuizen [Sat, 7 Sep 2019 17:55:12 +0000 (19:55 +0200)]
test: Bump timeout.

* build-aux/test-c.sh: Bump timeout to 10s, __mesabi_uldiv can be slow.

5 months agontoab: Use __mesabi_uldiv only on __MESC__.
Danny Milosavljevic [Fri, 14 Jun 2019 15:45:32 +0000 (17:45 +0200)]
ntoab: Use __mesabi_uldiv only on __MESC__.

* lib/mes/ntoab.c (ntoab): Use __mesabi_uldiv only on __MESC__.

5 months agomescc: Mes C Library: Include mes/div.c for mescc builds.
Jan Nieuwenhuizen [Fri, 14 Jun 2019 08:02:49 +0000 (10:02 +0200)]
mescc: Mes C Library: Include mes/div.c for mescc builds.

* build-aux/configure-lib.sh (libmes_SOURCES): Add mes/div.c.
* simple.sh: Likewise.

5 months agontoab: Include "assert.h".
Danny Milosavljevic [Thu, 13 Jun 2019 23:27:15 +0000 (01:27 +0200)]
ntoab: Include "assert.h".

* lib/mes/ntoab.c: #include "assert.h".

5 months agomescc: Mes C Library: Use __mesabi_uldiv.
Danny Milosavljevic [Thu, 13 Jun 2019 23:02:40 +0000 (01:02 +0200)]
mescc: Mes C Library: Use __mesabi_uldiv.

* lib/mes/ntoab.c (ntoab): Use __mesabi_uldiv.

5 months agomescc: Mes C Library: Add integer division algorithm.
Danny Milosavljevic [Thu, 13 Jun 2019 22:57:43 +0000 (00:57 +0200)]
mescc: Mes C Library: Add integer division algorithm.

* lib/mes/div.c: New file.

3 months agomescc: Mes C Library: Have write behave well with buffered reads.
Jan Nieuwenhuizen [Sun, 28 Jul 2019 11:01:37 +0000 (13:01 +0200)]
mescc: Mes C Library: Have write behave well with buffered reads.

* lib/mes/write.c: New file.
* build-aux/configure-lib.sh (libc_mini_SOURCES): Add it.
(libc_mini_shared_SOURCES): New variable.
(libc_mini_SOURCES, libmes_SOURCES): Use it.
(libmes_SOURCES): Add lib/linux/lseek.c, lib/posix/write.c.
(libc_tcc_SOURCES): Remove lib/linux/lseek.c.
* lib/posix/write.c (write): Correct for read buffer.
* lib/stdio/fwrite.c (fwrite): Remove read buffer correction.
* simple.sh: Update.

3 months agomescc: Mes C Library: Add buffered read.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 20:58:49 +0000 (22:58 +0200)]
mescc: Mes C Library: Add buffered read.

* lib/mes/__buffered_read.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES): Add it.  Also add memmove.c.
(libc_tcc_SOURCES): Remove memmove.c
* lib/linux/close.c (close): Clear read buffer.
* lib/linux/_open3.c (_open3): Likewise.
* lib/linux/lseek.c (lseek): Correct for read buffer.
* lib/stdio/fwrite.c (fwrite): Likewise.
* lib/posix/read.c (read): Call __buffered_read.
* lib/posix/write.c (write): Add FIXME note about buffered reads.
* simple.sh: Update.

5 months agotests: Disable 70-extern.c for x86_64-gcc.
Jan Nieuwenhuizen [Mon, 10 Jun 2019 21:13:50 +0000 (23:13 +0200)]
tests: Disable 70-extern.c for x86_64-gcc.

* build-aux/check-mescc.sh (XFAIL_TESTS)[x86_64-gcc]: Add
70-extern.c.

5 months agomescc: Put char's ASCII code into register, not char.
Danny Milosavljevic [Thu, 30 May 2019 20:11:37 +0000 (22:11 +0200)]
mescc: Put char's ASCII code into register, not char.

* module/mescc/compile.scm (expr-register): Put char's ASCII code into
register, not char.

5 months agomes: Update to Nyacc 0.93.
Jan Nieuwenhuizen [Sun, 9 Jun 2019 17:42:42 +0000 (19:42 +0200)]
mes: Update to Nyacc 0.93.

* mes/module/nyacc/lang/c99/util.mes: New file.
* mes/module/nyacc/lang/c99/parser.mes: Use it.
* module/mescc/compile.scm (ast->info): Update for Nyacc 0.93.0.
* module/mescc/preprocess.scm (need-progress):  Likewise.
(ast-strip-comment): Likewise.

3 months agomes: string->number: Support #x-prefixed hex numbers.
Jan Nieuwenhuizen [Fri, 2 Aug 2019 20:52:46 +0000 (22:52 +0200)]
mes: string->number: Support #x-prefixed hex numbers.

* mes/module/mes/scm.mes (string->number): Support "#x"-prefix.
* tests/math.test ("string->number #hex"): Test it.

3 months agomescc: Do not dump variables with extern storage.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 15:22:00 +0000 (17:22 +0200)]
mescc: Do not dump variables with extern storage.

* lib/tests/scaffold/70-extern.stdout: New file.
* lib/tests/scaffold/70-extern.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it..
* module/mescc/M1.scm (global-string?, global-extern?): New function.
(info->M1): Dump strings first.  Skip extern symbols.
* module/mescc/info.scm (<global>): Add storage field.
(make-global): Add storage parameter.  Pass it.
* module/mescc/compile.scm (make-global-entry): Likewise.
(global->info): Likewise.
(init-declr->info): Likewise.
(decl->info): Pass storage.

3 months agobuild: ./pre-inst-env MES_PREFIX fixup.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 07:19:53 +0000 (09:19 +0200)]
build: ./pre-inst-env MES_PREFIX fixup.

* build-aux/pre-inst-env.in: Set MES_PREFIX to abs_top_srcdir.
* src/mes.c (open_boot): Cater for MES_PREFIX/mes and ${srcdest}.

3 months agomescc: Be silent.
Jan Nieuwenhuizen [Sat, 27 Jul 2019 07:51:21 +0000 (09:51 +0200)]
mescc: Be silent.

* module/mescc/M1.scm (infos->M1, info->M1): Add verbose?.  Move
debugging into verbose? > 1.
* module/mescc/compile.scm (c99-input->info, c99-ast->info): Likewise.
(mescc:trace-verbose): Rename from mescc:trace.
(mescc:trace): New function.
* module/mescc.scm (mescc:main): Likewise.
* module/mescc/mescc.scm (mescc:preprocess, c->ast mescc:compile,
c->info, E->info): Likewise.
* module/mescc/preprocess.scm (c99-input->full-ast, c99-input->ast):
Likewise.

3 months agomescc: Add <include>/<kernel>/<arch> to include path.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 20:44:04 +0000 (22:44 +0200)]
mescc: Add <include>/<kernel>/<arch> to include path.

* module/mescc/preprocess.scm (c99-input->full-ast): Add
<include>/<kernel>/<arch> to include path.
* module/mescc/compile.scm (c99-input->info): Pass arch.
* module/mescc/mescc.scm (mescc:preprocess): Likewise.
(c->info): Likewise.
(c->ast): Likewise.

3 months agomescc: Add 70-function-destruct-declare.c test.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 17:09:12 +0000 (19:09 +0200)]
mescc: Add 70-function-destruct-declare.c test.

* module/mescc/compile.scm (init-declr->info): Do not attempt to
re-calculate function type.
(ftn-declr:get-type): Remove.
* lib/tests/scaffold/70-function-destruct-declare.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.

3 months agomescc: Resurrect --write.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:57:45 +0000 (18:57 +0200)]
mescc: Resurrect --write.

* module/mescc/mescc.scm (mescc:preprocess): Pass pretty-print/write
to c->ast.

3 months agobuild: Distribute crt*.c, libc+gnu.c for tcc, gcc bootstrap build.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:36:07 +0000 (18:36 +0200)]
build: Distribute crt*.c, libc+gnu.c for tcc, gcc bootstrap build.

* build-aux/build-lib.sh (libc_gnu_SOURCES): Build libc+gnu.c.  Copy
crt*.c, libc+gnu.c for distribution.

3 months agobuild: Uniquify config macros.
Jan Nieuwenhuizen [Fri, 26 Jul 2019 16:20:32 +0000 (18:20 +0200)]
build: Uniquify config macros.

* configure (main): Rename VERSION to MES_VERSION, pkgdatadir to
MES_PKGDATADIR.  Update users.
* configure.sh (mes_system): Likewise.
* src/mes.c (mes_symbols): Update.
(open_boot): Update.
* scaffold/cons-mes.c (main): Update.
* simple.sh: Update.

4 months agobuild: Resurrect --with-cheating.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 16:56:58 +0000 (18:56 +0200)]
build: Resurrect --with-cheating.

* build-aux/config.sh.in (SCHEME): New substitute.
* build-aux/config.make.in: Likewise.
* configure: Substitute them.

3 months agomescc: Support tcc: libtcc1 build fixes.
Jan Nieuwenhuizen [Tue, 23 Jul 2019 18:38:29 +0000 (20:38 +0200)]
mescc: Support tcc: libtcc1 build fixes.

* lib/libtcc1.c: Support building without long long, float support.

5 months agomescc: Mes C Library: Avoid type/size_t conflicts.
Jan Nieuwenhuizen [Sat, 1 Jun 2019 06:44:18 +0000 (08:44 +0200)]
mescc: Mes C Library: Avoid type/size_t conflicts.

* include/alloca.h: Remove typedefs, include sys/types.h.
* include/stdint.h: Likewise.
* include/string.h: Likewise.

4 months agomescc: Support tcc: Add intptr_t, uintptr_t.
Jan Nieuwenhuizen [Wed, 17 Jul 2019 20:54:13 +0000 (22:54 +0200)]
mescc: Support tcc: Add intptr_t, uintptr_t.

* include/sys/types.h (intptr_t, uintptr_t): Add typedef.

3 months agomescc: Add 70-struct-post.c test with fix.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 20:40:42 +0000 (22:40 +0200)]
mescc: Add 70-struct-post.c test with fix.

* lib/tests/scaffold/70-struct-post.c: New file.
* build-aux/check-mescc.sh (TESTS): Add it.
* module/mescc/compile.scm (expr->register): Use type size for rank
0 (WAS: 1).

3 months agomescc: Add 70-struct-short-enum-init.c test with fix.
Jan Nieuwenhuizen [Sun, 21 Jul 2019 14:48:26 +0000 (16:48 +0200)]
mescc: Add 70-struct-short-enum-init.c test with fix.

* module/mescc/compile.scm (init->data): Respect type of size.
* lib/tests/scaffold/70-struct-short-enum-init.c: New file.
* lib/tests/scaffold/70-struct-short-enum-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.

4 months agomescc: Add 70-array-in-struct-init.c test with fix.
Jan Nieuwenhuizen [Sat, 20 Jul 2019 15:14:55 +0000 (17:14 +0200)]
mescc: Add 70-array-in-struct-init.c test with fix.

* lib/tests/scaffold/70-array-in-struct-init.c: New file.
* lib/tests/scaffold/70-array-in-struct-init.stdout: New file.
* build-aux/check-mescc.sh (TESTS): Add test.
* module/mescc/compile.scm (array-init-element->data): Recurse for
elements instead of using init->data.  Support array fields.

4 months agomes: Remove broken copy of simple-format.
Jan Nieuwenhuizen [Fri, 19 Jul 2019 13:36:36 +0000 (15:36 +0200)]
mes: Remove broken copy of simple-format.

* mes/module/mes/simple-format.mes: New file.
* mes/module/mes/guile.mes: Use it.
(with-output-to-string, simple-format): Remove broken copies.
* mes/module/mes/display.mes (with-output-to-string, simple-format,
format): Remove.

4 months agoFix remainder handling.
Danny Milosavljevic [Fri, 5 Jul 2019 13:52:04 +0000 (15:52 +0200)]
Fix remainder handling.

* mes/module/mes/scm.mes (number->string): Fix remainder handling.
* build-aux/check-mescc.sh (XFAIL_TESTS): Remove
lib/tests/scaffold/60-math.c.

4 months agoRevert "test: Disable 60-math.c test."
Jan Nieuwenhuizen [Tue, 9 Jul 2019 20:01:24 +0000 (22:01 +0200)]
Revert "test: Disable 60-math.c test."

This reverts commit bbe6576a66a520d429bb3ec84120ffcce88480bf.

4 months agotest: Disable 60-math.c test.
Jan Nieuwenhuizen [Tue, 9 Jul 2019 19:57:00 +0000 (21:57 +0200)]
test: Disable 60-math.c test.

* build-aux/check-mescc.sh (TESTS): Remove
lib/tests/scaffold/60-math.c.
(BROKEN_TESTS): Add it.

4 months agobuild: Resurrect bootstrap.sh.
Jan Nieuwenhuizen [Sun, 7 Jul 2019 10:17:03 +0000 (12:17 +0200)]
build: Resurrect bootstrap.sh.

* build-aux/connfigure-lib.sh: Split from build-lib.sh
* build-aux/build-lib.sh: Include it.
* build-aux/bootstrap.sh.in: New file.
* configure.sh: Substitute it.

4 months agomescc: Use basename of input as default output name.
Jan Nieuwenhuizen [Mon, 8 Jul 2019 17:42:31 +0000 (19:42 +0200)]
mescc: Use basename of input as default output name.

* module/mescc/mescc.scm (mescc:preprocess, mescc:compile,
mescc:assemble, M1->hex2): Use basename of input as default output name.

4 months agobuild: Handle gcc with --pie-by-default.
Jan Nieuwenhuizen [Sat, 6 Jul 2019 11:57:30 +0000 (13:57 +0200)]
build: Handle gcc with --pie-by-default.

This fixes upgrading to debian-hurd-20190220.img.

* build-aux/build.sh.in (CFLAGS): Add -static.  Fixes using gcc
compiled with --pie-by-default
* build-aux/check.sh.in (CFLAGS): Likewise.
* module/mescc.scm (parse-opts): Ignore -no-pie, -static.

4 months agotest: Split-off broken 72-typedef-struct-def-local.
Jan Nieuwenhuizen [Mon, 8 Jul 2019 07:04:01 +0000 (09:04 +0200)]
test: Split-off broken 72-typedef-struct-def-local.

* lib/tests/scaffold/72-typedef-struct-def-local.c: New file.
* lib/tests/scaffold/72-typedef-struct-def.c: Remove local bit.
* build-aux/check-mescc.sh (TESTS): Add it.
(XFAIL_TESTS)[mescc]: Add lib/tests/scaffold/72-typedef-struct-def.c.

4 months agotest: Fix open-read test.
Jan Nieuwenhuizen [Fri, 28 Jun 2019 18:37:47 +0000 (20:37 +0200)]
test: Fix open-read test.

* build-aux/pre-inst-env.in (srcdir): Remove.
(abs_top_srcdir, abs_top_builddir): Export.
* lib/tests/posix/50-open-read.c (main): Use abs_top_srcdir.

4 months agotest: Add open-read test.
Jan Nieuwenhuizen [Wed, 26 Jun 2019 19:55:44 +0000 (21:55 +0200)]
test: Add open-read test.

* build-aux/test-c.sh: Support running by hand.
* lib/tests/posix/50-open-read.c: New test.
* lib/tests/posix/data/open-read: New file.
* build-aux/check-mescc.sh (TESTS): Add it.

4 months agotest: Enable argv test, run tests with arguments.
Jan Nieuwenhuizen [Wed, 26 Jun 2019 17:49:36 +0000 (19:49 +0200)]
test: Enable argv test, run tests with arguments.

* build-aux/check-mescc.sh (TESTS): Enable 54-argv.c
(XFAIL_TESTS): Remove it.
* build-aux/test-c.sh: Invoke test with options.
* lib/tests/scaffold/54-argc.c: Update.

4 months agomescc: Mes C library: Move common getcwd, open bits to posix.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 21:10:52 +0000 (23:10 +0200)]
mescc: Mes C library: Move common getcwd, open bits to posix.

* lib/linux/_getcwd.c: Rename from getcwd.c.
* lib/linux/_open3.c: Rename from open.c.
* lib/posix/getcwd.c: New file with bits from ../linux/getcwd.c.
* lib/posix/open.c: New file with bits ../linux/getcwd.c.
* build-aux/build-lib.sh (libc_SOURCES): Update.

4 months agomescc: Mes C Library: Move posix bits to read.
Jan Nieuwenhuizen [Mon, 24 Jun 2019 23:58:15 +0000 (01:58 +0200)]
mescc: Mes C Library: Move posix bits to read.

* lib/linux/_read.c: Rename from read.
* lib/posix/read.c: New file.
* build-aux/build-lib.sh (libc_SOURCES): Update.
* include/mes/lib.h (_read): Declare.

4 months agoporting: Avoid failing in scaffold build.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 19:45:46 +0000 (21:45 +0200)]
porting: Avoid failing in scaffold build.

* build-aux/build-scaffold.sh: Do not fail when using courage.

4 months agobuild: Use bash if available to avoid dash problems.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 19:40:43 +0000 (21:40 +0200)]
build: Use bash if available to avoid dash problems.

* configure: Set SHELL to bash.
* configure.sh: Likewise.
* build-aux/test-suite.sh (TEST_LOGS):
* build-aux/export.make: Export SHELL.
* build-aux/config.sh.in (SHELL): New substitute, export.
* build-aux/config.make.in (SHELL): New substitute.
* build-aux/GNUmakefile.in (build, check, install, uninstall): Use
$SHELL to avoid dash problems.
* build-aux/check-mescc.sh: Likewise.
* build-aux/build.sh.in: Likewise.
* build-aux/check-mes.sh: Likewise.
* build-aux/check.sh.in: Likewise.

4 months agotest: Oops, uncomment some commented-out tests.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 18:11:57 +0000 (20:11 +0200)]
test: Oops, uncomment some commented-out tests.

* lib/tests/scaffold/55-char-array.c: Uncomment.
* lib/tests/scaffold/72-typedef-struct-def.c: Likewise.

4 months agobuild: Improve --with-system-libc support.
Jan Nieuwenhuizen [Tue, 25 Jun 2019 17:05:58 +0000 (19:05 +0200)]
build: Improve --with-system-libc support.

* build-aux/build-lib.sh: Avoid building libc for --with-system-libc.
Make libmes richer.
build-aux/check-mescc.sh: Enable 50-malloc test.
* include/dirstream.h: Use HAVE_DIRSTREAM_H to cater for non-existing
dirstream.h.
* include/grp.h[SYSTEM_LIBC]: Typo.
* include/mes/lib.h (__brk, __call_at_exit)[SYSTEM_LIBC]: Declare.
* include/stdlib.h (comparison_fn_t)[SYSTEM_LIBC]: Declare.
* include/time.h (mktime): Return time_t.
* lib/posix/isatty.c [SYSTEM_LIBC]: Do not (re)declare termios.
* lib/stub/mktime.c (mktime): Return time_t.
* lib/tests/scaffold/41-ternary.c (main): Remove assumption that
locals are initialized.
* lib/tests/scaffold/70-stdarg.c: Cater for SYSTEM_LIBC.
* lib/tests/setjmp/80-setjmp.c: Declare jmp buf.
* lib/*/*.c: Add missing mes/lib.h, errno.h includes.

4 months agoporting: Add x86_64 scaffold: exit and write in assembly.
Jan Nieuwenhuizen [Sun, 23 Jun 2019 19:23:34 +0000 (21:23 +0200)]
porting: Add x86_64 scaffold: exit and write in assembly.

* lib/x86_64-mes-gcc/exit-42.S: New file.
* lib/x86_64-mes-gcc/hello-mes.S: New file.
* lib/x86_64-mes/elf64-0exit-42.hex2: New file.
* lib/x86_64-mes/elf64-0hello-mes.hex2: New file.
* lib/x86_64-mes/elf64-body-exit-42.hex2: Rewrite..
* lib/x86_64-mes/elf64-body-hello-mes.hex2:
* lib/x86_64-mes/elf64-0header.hex2: Fix copyright header.
* lib/x86_64-mes/elf64-header.hex2: Likewise.
* lib/x86_64-mes/elf-0footer.hex2: Remove.

5 months agoporting: Add x86 scaffold: exit and write in assembly.
Jan Nieuwenhuizen [Thu, 13 Jun 2019 12:19:59 +0000 (14:19 +0200)]
porting: Add x86 scaffold: exit and write in assembly.

* lib/x86-mes-gcc/exit-42.S: New file.
* lib/x86-mes-gcc/hello-mes.S: New file.
* lib/x86-mes/elf32-0exit-42.hex2: New file.
* lib/x86-mes/elf32-0hello-mes.hex2: New file.
* lib/x86-mes/elf32-body-hello-mes.hex2: New file.
* lib/x86-mes/elf32-body-exit-42.hex2: Rewrite.
* lib/x86-mes/elf32-header.hex2: Fix copyright header.
* lib/x86-mes/elf32-0header.hex2: Likewise.
* lib/x86-mes/elf-0footer.hex2: Remove.
* build-aux/build-scaffold.sh: Build them.
* .dir-locals.el (asm-mode): Allow TABs.
* .gitignore: Reserve .S assembly sources, i.e. manual written
assembly.  Update build system.
* module/mescc/mescc.scm: Update.
* build-aux/build-lib.sh: Update.
* scripts/ar.in: Update.

5 months agomake check: Do not re-check unless recheck=true.
Jan Nieuwenhuizen [Mon, 10 Jun 2019 09:39:31 +0000 (11:39 +0200)]
make check: Do not re-check unless recheck=true.

* build-aux/check-mescc.sh (recheck): New variable.
* build-aux/check.sh.in (recheck): New variable.
* build-aux/test-suite.sh (TEST_LOGS): Use it.

5 months agobuild: Cater for ARM.
Jan Nieuwenhuizen [Wed, 22 May 2019 15:55:20 +0000 (17:55 +0200)]
build: Cater for ARM.

* configure: Cater for ARM.
* configure.sh: Likewise
* build-aux/GNUmakefile.in: Likewise.
* build-aux/bootstrap.sh.in: Likewise.
* module/mescc.scm (parse-opts): Likewise.
* src/mes.c (mes_environment): Likewise.
* build-aux/build.sh.in: Likewise.
* build-aux/config.sh Likewise.
* build-aux/install.sh.in: Likewise.
* module/mes/guile.scm: Likewise.
* scripts/mescc.scm.in: Likewise.
* module/mescc/mescc.scm (arch-get): New function.
(arch-get-info): New function.
(arch-get-define): New function.
(arch-get-m1-options): New function.
(arch-get-Architecture): New function.
(mescc:preprocess c->info, E->info, M1->hex2, hex2->elf,
M1->blood-elf, arch-find): Use them.

5 months agomescc: Drop $@-workaround.
Jan Nieuwenhuizen [Mon, 10 Jun 2019 21:43:35 +0000 (23:43 +0200)]
mescc: Drop $@-workaround.

* scripts/mescc.in: Drop $@-workaround.

5 months agobuild: Simplify.
Jan Nieuwenhuizen [Sat, 8 Jun 2019 13:36:22 +0000 (15:36 +0200)]
build: Simplify.

    core: Make mes src/ c files separate compilation units.

* include/mes/constants.h: New file.
* include/mes/macros.h: New file.
* include/mes/mes.h: New file.
* src/gc.c: Update.
* src/hash.c: Update.
* src/lib.c: Update.
* src/math.c: Update.
* src/mes.c: Update.
* src/module.c: Update.
* src/posix.c: Update.
* src/reader.c: Update.
* src/string.c: Update.
* src/struct.c: Update.
* src/vector.c: Update.

    mes: Update datadir.

* src/mes.c (g_datadir): New global.
(open_boot): Rename from read_boot.
(read_boot): New function.
* mes/module/mes/boot-0.scm: Move from boot-0.scm.in
* configure: Update.
* configure.sh: Update.

    mescc: Create libraries from separate files.

* .gitignore: Update.
* build-aux/bootstrap-mes.sh: Remove.
* build-aux/bootstrap.sh.in: Remove.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build-scaffold.sh: New file.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-tcc.sh: Remove.
* build-aux/config.sh.in: New file.
* build-aux/config.sh: Remove.
* build-aux/install.sh.in: Update.
* build-aux/test-boot.sh: New file.
* build-aux/test-c.sh: New file.
* build-aux/test-driver: New file.
* build-aux/test-suite.sh: New file.
* build-aux/trace.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* lib/linux/x86-mes-mescc/crt1.c: Move from lib/linux/x86-mes.
* lib/linux/x86-mes-mescc/mini.c: Likewise.
* lib/linux/x86_64-mes-mescc/crt1.c: Move from lib/linux/x86_64-mes.
* lib/linux/x86_64-mes-mescc/mini.c: Likewise.
* lib/linux/x86-mes-gcc/syscall.c: Rename from mes.c.
* lib/linux/x86-mes-mescc/syscall.c: Likewise.
* lib/linux/x86_64-mes-gcc/syscall.c: Likewise.
* lib/linux/x86_64-mes-mescc/syscall.c: Likewise.
* lib/mes/mes_open.c: Include config.h.
* lib/tests/stdio/70-printf-hello.c: Likewise.
* lib/tests/stdio/70-printf-simple.c: Likewise.
* scaffold/gc-test.sh: New file.
* simple.sh: Update.

5 months agotest: Move scaffold/tests into lib.
Jan Nieuwenhuizen [Sat, 8 Jun 2019 13:34:44 +0000 (15:34 +0200)]
test: Move scaffold/tests into lib.

* lib/tests/scaffold: Move from scaffold/tests.
* scaffold/tests: Remove.
* build-aux/check-mescc.sh: Update.

6 months agobuild: Make "GUILEC" compilation status output more verbose (print full path).
Danny Milosavljevic [Fri, 10 May 2019 14:38:05 +0000 (16:38 +0200)]
build: Make "GUILEC" compilation status output more verbose (print full path).

* build-aux/build-guile.sh: Make "GUILEC" compilation status output more
verbose (print full path).

5 months agobuild: Fix --disable-silent-rules. Thanks ng0!
Jan Nieuwenhuizen [Wed, 29 May 2019 14:55:57 +0000 (16:55 +0200)]
build: Fix --disable-silent-rules. Thanks ng0!

* configure (main): Substitute V as string value.
* build-aux/trace.sh: Typo.  Fixes using V=0.
* build-aux/config.status.in (V): New substitute.
* build-aux/config.make.in (V): New substiute.

5 months agomescc: Use a.out as default executable name.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:49:22 +0000 (16:49 +0200)]
mescc: Use a.out as default executable name.

* module/mescc/mescc.scm (hex2->elf): Use a.out as default executable
name.

5 months agomescc: Robustify against empty `V' in environment.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:47:54 +0000 (16:47 +0200)]
mescc: Robustify against empty `V' in environment.

* module/mescc.scm: Robustify against empty V in environment.

5 months agomescc: Fix -dumpmachine to respect -m bits selection.
Jan Nieuwenhuizen [Tue, 28 May 2019 22:04:47 +0000 (00:04 +0200)]
mescc: Fix -dumpmachine to respect -m bits selection.

* module/mescc.scm (parse-opts): Fix -dumpmachine to respect -m bits
selection.  Also display kernel.

5 months agomescc: Support single-dash options on Mes too.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:45:28 +0000 (16:45 +0200)]
mescc: Support single-dash options on Mes too.

* scripts/mescc.in[MES]: Add -- as separator, fixes using single-dash
options on Mes too.

5 months agomescc: Ignore -fnobuiltin, -nostdinc for GCC compatibility.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:44:31 +0000 (16:44 +0200)]
mescc: Ignore -fnobuiltin, -nostdinc for GCC compatibility.

* module/mescc.scm (parse-opts): Add -fnobuiltin, -nostdinc.
(mescc:main): Ignore them.

5 months agotest: Resurrect running boot tests on Guile.
Jan Nieuwenhuizen [Mon, 27 May 2019 20:57:44 +0000 (22:57 +0200)]
test: Resurrect running boot tests on Guile.

* module/mes/guile.scm (keyword->string): New function.
* scaffold/boot/43-or.scm (foo): Add quoting.
* scaffold/boot/45-pass-if.scm (pass-if): Likewise.
* scaffold/boot/46-report.scm (pass-if): Likewise.
* scaffold/boot/47-pass-if-eq.scm (pass-if): Likewise.
* scaffold/boot/48-let.scm (map): Rename from map1.
* scaffold/boot/60-let-syntax-expanded.scm: Some work.

5 months agomescc: Mes C Library: Fix compile warnings.
Jan Nieuwenhuizen [Sun, 26 May 2019 11:41:00 +0000 (13:41 +0200)]
mescc: Mes C Library: Fix compile warnings.

* lib/stdio/fputc.c (fputc): Oops, stream is a long.
* lib/stdlib/malloc.c (malloc): Cast to char *. FIXME
* lib/string/memchr.c (memchr): Cast to void *.
* lib/string/memcmp.c (memcmp): Add const cast.

5 months agomescc: Mes C Library: Fixes for x86_64 crt1.c
Jan Nieuwenhuizen [Sun, 26 May 2019 07:36:57 +0000 (09:36 +0200)]
mescc: Mes C Library: Fixes for x86_64 crt1.c

* lib/linux/x86_64-mes/crt1.c (_start): Write only 4 bytes to int
variables __stdin, __stdout, __stderr.

5 months agotest: Move srfi-1 for-each and map tests to tests/srfi-1.test.
Jan Nieuwenhuizen [Wed, 29 May 2019 14:30:25 +0000 (16:30 +0200)]
test: Move srfi-1 for-each and map tests to tests/srfi-1.test.

This fixes: `make check MES=guile'.

* tests/srfi-1.test ("map 1,2", "map 2,1", "for-each 1,2",
for-each 2,1"): Move from scm.test.
* tests/scm.test ("map 1,2", "map 2,1", "for-each 1,2",
for-each 2,1"): Remove.

5 months agomescc: Mes C Library: Use SYSTEM_LIBC [WAS: WITH_GLIBC].
Jan Nieuwenhuizen [Wed, 29 May 2019 14:15:12 +0000 (16:15 +0200)]
mescc: Mes C Library: Use SYSTEM_LIBC [WAS: WITH_GLIBC].

Run: sed -i 's,WITH_GLIBC,SYSTEM_LIBC,g' $(git grep -l WITH_GLIBC)

* build-aux/config.sh: Update.
* include/alloca.h: Likewise.
* include/ar.h: Likewise.
* include/argz.h: Likewise.
* include/assert.h: Likewise.
* include/ctype.h: Likewise.
* include/dirent.h: Likewise.
* include/dirstream.h: Likewise.
* include/dlfcn.h: Likewise.
* include/endian.h: Likewise.
* include/errno.h: Likewise.
* include/fcntl.h: Likewise.
* include/features.h: Likewise.
* include/float.h: Likewise.
* include/getopt.h: Likewise.
* include/inttypes.h: Likewise.
* include/libgen.h: Likewise.
* include/limits.h: Likewise.
* include/linux/x86_64/syscall.h: Likewise.
* include/locale.h: Likewise.
* include/math.h: Likewise.
* include/memory.h: Likewise.
* include/mes/lib-mini.h: Likewise.
* include/pwd.h: Likewise.
* include/setjmp.h: Likewise.
* include/signal.h: Likewise.
* include/stdarg.h: Likewise.
* include/stdbool.h: Likewise.
* include/stddef.h: Likewise.
* include/stdint.h: Likewise.
* include/stdio.h: Likewise.
* include/stdlib.h: Likewise.
* include/stdnoreturn.h: Likewise.
* include/string.h: Likewise.
* include/strings.h: Likewise.
* include/sys/cdefs.h: Likewise.
* include/sys/dir.h: Likewise.
* include/sys/file.h: Likewise.
* include/sys/ioctl.h: Likewise.
* include/sys/mman.h: Likewise.
* include/sys/param.h: Likewise.
* include/sys/resource.h: Likewise.
* include/sys/select.h: Likewise.
* include/sys/stat.h: Likewise.
* include/sys/time.h: Likewise.
* include/sys/timeb.h: Likewise.
* include/sys/times.h: Likewise.
* include/sys/types.h: Likewise.
* include/sys/ucontext.h: Likewise.
* include/sys/user.h: Likewise.
* include/sys/wait.h: Likewise.
* include/termio.h: Likewise.
* include/time.h: Likewise.
* include/unistd.h: Likewise.
* lib/libmes.c: Likewise.
* lib/tests/stdio/70-printf-hello.c: Likewise.
* lib/tests/stdio/70-printf-simple.c: Likewise.
* lib/tests/stdio/80-sscanf.c: Likewise.
* lib/tests/stdlib/50-malloc.c: Likewise.
* module/mescc/preprocess.scm: Likewise.
* scaffold/cons-mes.c: Likewise.
* scaffold/lib/stdlib/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/tests/61-array.c: Likewise.
* scaffold/tiny-mes.c: Likewise.
* simple.sh: Likewise.
* src/mes.c: Likewise.

5 months agomes: Bugfix for search-path. Fixes running MesCC on Guile.
Jan Nieuwenhuizen [Mon, 27 May 2019 19:51:37 +0000 (21:51 +0200)]
mes: Bugfix for search-path. Fixes running MesCC on Guile.

* module/mescc/mescc.scm (arch-find): Also look in cwd.
* mes/module/mes/posix.mes (search-path): Do not look in cwd.

5 months agomescc: Use named --architecture switch for upcoming mescc-tools 0.6.
Jan Nieuwenhuizen [Sat, 25 May 2019 14:01:39 +0000 (16:01 +0200)]
mescc: Use named --architecture switch for upcoming mescc-tools 0.6.

* module/mescc/mescc.scm (M1->hex2): Use named --architecture switch for
upcoming mescc-tools 0.6.
(hex2->elf): Likewise.
* build-aux/bootstrap-mes.sh: Likewise.
* build-aux/bootstrap.sh.in: Likewise.
* build-aux/config.sh: Likewise.

5 months agomes: Identify 64-bit bug when compiled with MesCC.
Jan Nieuwenhuizen [Mon, 27 May 2019 19:33:20 +0000 (21:33 +0200)]
mes: Identify 64-bit bug when compiled with MesCC.

* src/math.c (divide): Add divide-by-zero error.
(modulo): Likewise.
* module/mes/guile.scm (%compiler): New variable.
* module/mescc/M1.scm (mesc?): New variable.
(hex2:immediate8): Use it to avoid divide-by-zero error.
* HACKING (Bugs): Add it.

5 months agomes: Make debug levels 4 and 5 usable.
Jan Nieuwenhuizen [Mon, 27 May 2019 19:30:48 +0000 (21:30 +0200)]
mes: Make debug levels 4 and 5 usable.

* HACKING: Update debug policy.
* lib/linux/read.c (read): Print read in level 5.
* src/mes.c (eval_apply): Print module in level 6.
(main): Likewise.  Remove redundant module printing.
* src/gc.c (gc): Print symbols in level 6.