Commit Graph

803 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen bb0f82d5aa build: Add stage0 hex2 test.
* configure (HEX2): Check for hex2 from MESCC_tools.
* INSTALL: Mention it.
* GNUmakefile (SUBDIRS): Add stage0.
* make/check-cc.make: New file.
* make/check.make: Remove CC-not-empty guard.
* scaffold/scaffold.make: Update CC check targets.
2017-06-23 20:18:09 +02:00
Jan Nieuwenhuizen afb5c207a9 stage0: Move to-be-generated part of body to footer.
* stage0/elf32-footer-exit-42.hex2: Add ELF_str, ELF_sym from body.
* stage0/elf32-body-exit-42.hex2: Remove ELF_str, ELF_sym.
2017-06-21 07:05:26 +02:00
Jan Nieuwenhuizen cfca4c5cc1 stage0: Leverage label>base in stage0 gdb header.
* stage0/elf32-header-exit-42.hex2: Replace calculated addresses with label>base.
* stage0/elf32-body-exit-42.hex2: Likewise.
2017-06-19 22:45:51 +02:00
Jan Nieuwenhuizen f63d278cec stage0: Move stage0's section-headers before text.
* stage0/elf32-header-exit-42.hex2: Add section-headers.
* stage0/elf32-body-exit-42.hex2: Update.
* stage0/elf32-footer-exit-42.hex2: Remove section-headers.
2017-06-19 09:52:27 +02:00
Jan Nieuwenhuizen 3b82abdfa5 stage0: Add stage0 hex2 gdb header and footer example.
* stage0/elf32-header-exit-42.hex2: New file.
* stage0/elf32-footer-exit-42.hex2: New file.
2017-06-18 21:06:27 +02:00
Jan Nieuwenhuizen 77dfdd44b7 mescc: Remove jump calculation, use labels: rename jumps.
* module/mes/as-i386.mes (i386:jump, i386:jump-byte-z, i386:jump-g,
  i386:jump-ge, i386:jump-nc, i386:jump-ncz, i386:jump-nz,
  i386:jump-z): Rename from i386:jump-label*.
* module/mes/as-i386.scm (mes): Update exports.
* module/language/c99/compiler.mes (ast->info): Update callers.
2017-06-13 20:31:03 +02:00
Jan Nieuwenhuizen 5bbcce7c67 mescc: Remove jump calculation, use labels: remove offset-jumps.
* module/mes/as-i386.mes (i386:XXjump, i386:Xjump, i386:Xjump-c,
  i386:Xjump-cz, i386:Xjump-g, i386:Xjump-ge, i386:Xjump-l,
  i386:Xjump-le, i386:Xjump-nc, i386:Xjump-ncz, i386:Xjump-ncz",
  i386:Xjump-nz, i386:Xjump-z, i386:jump, i386:jump-byte-nz,
  i386:jump-byte-z, i386:jump-c, i386:jump-cz, i386:jump-le,
  i386:jump-nc, i386:jump-ncz, i386:jump-nz, i386:jump-z,
  i386:test-jump-z): Remove.
* module/mes/as-i386.scm: Remove export.
2017-06-13 20:27:40 +02:00
Jan Nieuwenhuizen bdd80babb8 mescc: Remove jump calculation, use labels: cleanup.
* module/language/c99/compiler.mes (test->jump->info): Remove.
2017-06-12 20:58:49 +02:00
Jan Nieuwenhuizen 7d7126bf0d mescc: Remove jump calculation, use labels: switch.
* module/language/c99/compiler.mes (expr->accu): Refactor (switch ...).
  (clause->info): Refactor.
2017-06-13 20:20:38 +02:00
Jan Nieuwenhuizen 36e0219af3 mescc: Remove jump calculation, use labels: and, or.
* module/language/c99/compiler.mes (expr->accu): Refactor (and
  ...), (or ...).
2017-06-12 22:11:19 +02:00
Jan Nieuwenhuizen 0a94b499fa mescc: Remove jump calculation, use labels: if.
* module/language/c99/compiler.mes (ast->info): Refactor (if ...)
  using test-jump-label->info.
2017-06-12 20:11:37 +02:00
Jan Nieuwenhuizen 4e564c3ce3 mescc: Remove jump calculation, use labels: for.
* module/language/c99/compiler.mes (ast->info): Refactor (for ...)
  using test-jump-label->info.
2017-06-12 19:46:35 +02:00
Jan Nieuwenhuizen 0f19aba1a8 mescc: Remove jump calculation, use labels: do while.
* module/language/c99/compiler.mes (ast->info): Refactor (do-while
  ...)  using test-jump-label->info.
2017-06-12 19:00:24 +02:00
Jan Nieuwenhuizen 42ca62b075 mescc: Remove jump calculation, use labels: ?.
* module/language/c99/compiler.mes (ast->info): Refactor (cond-expr
  ...)  using test-jump-label->info.
2017-06-12 18:43:25 +02:00
Jan Nieuwenhuizen 44a97b03d9 mescc: Support continue in while.
* module/language/c99/compiler.mes (make): Add continue field.
  (.continue): New function.
  (clone): Support continue field.
  (ast->info): Support continue.
* scaffold/t.c (test): Test it.
2017-06-12 17:10:29 +02:00
Jan Nieuwenhuizen 9843f88d74 mescc: Remove jump calculation, use labels: while.
* module/language/c99/compiler.mes (ast->info): Refactor (while ...)
  using test-jump-label->info.
2017-06-12 21:06:12 +02:00
Jan Nieuwenhuizen 5bf3c92938 mescc: Remove jump calculation, use labels: prepare.
* module/language/c99/compiler.mes (test-jump-label->info): New
  function.
* module/mes/as-i386.mes (i386:jump-label-z,i386:jump-label-byte-z,
  i386:jump-label-g, i386:jump-label-ge,i386:jump-label-nz): New
  functions.
* module/mes/as-i386.scm: Export them.
2017-06-12 21:00:50 +02:00
Jan Nieuwenhuizen 7cce8c6090 mescc: Remove duplication of string globals.
* module/language/c99/compiler.mes (expr->global): Curry-in globals.
  Update callers.
  (initzer->global): Likewise.
2017-06-12 10:49:31 +02:00
Jan Nieuwenhuizen d46994f2fe mescc: Unify labels.
* module/language/c99/compiler.mes: Use (#:address label) (#local
  label) (#:relative label) thoughout.
* module/mes/elf-util.mes (add-s:-prefix, drop-s:-prefix): Remove.
  (function->text): Update.
* module/mes/hex2.mes (write-hex2): Update.
2017-06-11 18:05:56 +02:00
Jan Nieuwenhuizen 1263d6e278 mescc: Write object files in hex2 or hex3 format.
* stage0/elf32.hex2: New file.
* module/mes/hex2.mes: New file.
* module/mes/hex2.scm: New file.
* module/language/c99/compiler.mes: Eradicate object lamdas.
  (current-eval, dec-xhex, function:-object->text, object->elf,
  object->objects, merge-objects, alist-add): Remove.
* module/mes/elf.mes (object->elf): New function, move from compiler.mes.
* module/mes/elf.scm: Export it.
* guile/mescc.scm (parse-opts): Add -g.
  (main): Use it.
* scripts/mescc.mes: Likewise.
* scripts/mescc-guile.make (MESCC.scm, MESLD.scm): Add -g flag.
* scripts/mescc-mes.make (MESCC.mes, MESLD.mes): Likewise.
* scaffold/m.c: Add proper includes.
* scaffold/argv.c: New file.
* scaffold/hello.c: Simplify.
* scaffold/micro-mes.c: Add proper includes.
* scaffold/t.c: Add proper includes.
2017-06-11 13:11:40 +02:00
Jan Nieuwenhuizen 766cfeab9a core: %moduledir ends with /.
* make/install.make (MODULEDIR): Append /.
  (install): Remove /.
* src/mes.c (load_env, bload_env): Update.
2017-06-12 17:18:31 +02:00
Jan Nieuwenhuizen 4479540aed mescc: Put _start at top of mlibc.
* mlibc/libc-mes.c (_start): Move to top.
* mlibc/mini-libc-mes.c (_start): Likewise.
* module/mes/elf-util.mes (function-prefix): Update for _start == 0.
  (function-offset): Likewise.
2017-06-11 13:01:46 +02:00
Jan Nieuwenhuizen 01b4c0846b mes: Add list-index.
* module/srfi/srfi-1.scm (list-index): New function.
2017-06-11 14:45:01 +02:00
Jan Nieuwenhuizen 2c0f5c346c build: Bugfix add prepocess dependency on snarfing mes.
* src/src.make ($(OUT)/$(DIR)/mes.guile-E, $(OUT)/$(DIR)/mes.mes-E):
  Depend on mes snarfing.
2017-06-08 06:57:24 +02:00
Jan Nieuwenhuizen d148f78a5c test: Support for non-Guix[SD]: cater for missing CC/CC32 compilers.
* make/check.make: Skip if CC is not set.
* make/check-mlibc.make: New file.
* scaffold/scaffold.make: Use it for mlibc targets.
* tinycc/tinycc.make: Skip mlibc targets if CC32 not set.
2017-06-20 19:47:15 +02:00
Jan Nieuwenhuizen c1d91c722d mescc: Support for non-Guix[SD] builds.
* module/language/c99/compiler.mes (c99-input->full-ast): Cater for
  C_INCLUDE_PATH not set.  Fixes non-Guix[SD] builds.
2017-06-20 19:42:37 +02:00
Jan Nieuwenhuizen 19bed9b466 build: Support for non-Guix[SD]: make CC/CC32 optional in configure too.
* configure (optional): New global.
  (BUILD_TRIPLET): Use Guile value.
  (check-version): Add keyword argument #:optional.
  (main): Make CC optional (--with-courage).  Only check for stdio.h,
  limits.h if CC is found.
  Make CC32 check optional.
* scripts/scripts.make: Skip if CC is not set.
2017-06-20 19:42:33 +02:00
Jan Nieuwenhuizen 86b891ecb6 mescc: Bugfix for merging objects.
* mlibc/libc-mes.c (main): Declare.
* mlibc/mini-libc-mes.c (g_stdin): Define.
  (main): Declare.
* module/language/c99/compiler.mes (alist-add): Thinko.  Fixes merging
  objects when first declares function of next.
2017-06-05 11:42:15 +02:00
Jan Nieuwenhuizen 5267247991 guix hash: 0fvzr1ai2rmi46zdi5b2bdjb6s8ip78mkmsk02yxl46rajmp2pb1 2017-06-03 21:53:56 +02:00
Jan Nieuwenhuizen 7fdca75d21 Release 0.7.
* configure (VERSION): Bump.
2017-06-03 21:38:39 +02:00
Jan Nieuwenhuizen 18e7d97b23 doc: Release update.
* AUTHORS: Remove module/nyacc.
* HACKING: Release uppdate.
* NEWS: Release uppdate.
* doc/ANNOUNCE-0.7: New file.
2017-06-03 21:38:39 +02:00
Jan Nieuwenhuizen 993181ad65 guix: mes.git: Add git hash to version.
* guix.scm (mes.git): Add git hash to version.
2017-06-03 21:21:06 +02:00
Jan Nieuwenhuizen 4d1df9cbcb mescc: move include into share/mlibc, allows installing alongside gcc.
* mlibc: Rename from libc.
* HACKING: Update for name change.
* make/bin.make: Likewise.
* make/mescc-guile.make: Likewise.
* make/mescc-mes.make: Likewise.
* scaffold/scaffold.make: Likewise.
* make/install.make: Likewise.
  (install): Install mlibc into share/mlibc.
2017-06-03 12:27:53 +02:00
Jan Nieuwenhuizen 0a07a01b29 mescc: Handle any const, by ignoring.
* module/language/c99/compiler.mes (ast-strip-const): New function.
  (c99-input->ast): Use it.
  (type->size, type->description, ast->info): Remove const handling.
2017-06-02 13:12:56 +02:00
Jan Nieuwenhuizen 6f842c6051 mescc: Support array in struct.
* module/language/c99/compiler.mes: (field:size, field-offset): New
  functions.  Update callers, use them throughout.
  (ast->info): Support declaration of struct and typedef'ed struct
  variable with array fields.
  (expr->accu, expr->accu*): Support foo.bar[baz], foo->bar[baz].
* scaffold/t-tcc.c: Test it.
2017-05-31 20:52:48 +02:00
Jan Nieuwenhuizen 3a240221f0 build: Skip gcc, mlibc, guile or mes builds using CC=, CC32=, GUILE= or MES=.
* GNUmakefile (build-scripts): New target
  (HELP_TOP): Mention it.
* configure (main): Write GUILE_FOR_BUILD.
* make/bin-mlibc.make: Skip if CC32 is not set.
* make/bin.make: Skip if CC is not set.
* make/install.make (install): Only install $(OUT)/mes.mes if
  MES_BOOTSTRAP is set.
* make/mescc-guile.make: Skip if GUILE is not set.
* make/mescc-mes.make: Skip if MES is not set.
* HACKING: write something about
2017-05-28 18:32:53 +02:00
Jan Nieuwenhuizen 9f56b8b102 core: Always include reader.c, drop binary read-0-32.mo dependency.
* module/language/c99/compiler.mes (c99-input->full-ast): Remove
  obsolete __NYACC__ and MES_FULL defines.
* src/mes.c [!MES_FULL]: Include reader-mes.h.
  (mes_builtins) [!MES_FULL]: Include reader.mes.i, reader.me.environment.i.
  [!MES_FULL]: Include reader.c.
  (main) [!MES_FULL]: By default call load_env, only call bload_env
  when --load is supplied.  WAS: Always bload read-0-32.mo.
* src/reader.c (__end_of__mes_): Remove.
  (dump): Remove option of dumping tiny test program.
* make/mescc-mes.make ($(OUT)/$(TARGET), mescc.mes-ccompile,
  mescc.mes.c-compile-E): Depend on $(OUT)/mes, scripts/mes.
* src/src.make (mes.guile): Remove module/mes/read-32-0 dependency.
  Do not build $(OUT)/mes.mes.
* module/module.make (module/mes/read-0.mo, module/mes/read-0-32.mo,
  module/mes/tiny-0-32.mo): Remove targets.
  (CLEAN): Do not add them.  Neither install $(OUT)/mes.mes.
* .gitignore: Remove exceptions for them.
* make/install.make (install): Do not install them.
* HACKING: Update info about creating module/mes/read-32-0.mo.
* scaffold/mini-mes.c: Remove.
* scaffold/tiny-mes.c: Remove.
* scaffold/cons-mes.c: Remove.
* scaffold/scaffold.make (tiny-mes.libc, tiny-mes.guile, tiny-mes.mes,
  mini-mes.libc, mini-mes.guile, mini-mes.mes): Reemove targets.
2017-05-28 16:03:45 +02:00
Jan Nieuwenhuizen f6671eaf3e mescc: Add missing builtins.
* module/language/c99/compiler.mes (i386:type-alist): Add missing
  builtins.  TODO: identify and handle unsigned.
2017-05-27 09:28:08 +02:00
Jan Nieuwenhuizen bade7d5519 mescc: Support typedef and many TCC declaration variants.
* module/language/c99/compiler.mes (ast->info): Register typedefs in types.
  (enum-def-list->constants): Support addition and substraction in
  enum field values.
  (get-type): New function.  Use throughout.
2017-05-25 07:32:29 +02:00
Jan Nieuwenhuizen 3b4e7cd8a8 mescc: Handle comments anywhere.
* module/language/c99/compiler.mes (c99-input->full-ast): Rename from c99-input->full-ast.
  (ast-strip-comment, c99-input->ast): New functions.
  (ast->info): Remove comment exceptions.
2017-05-25 19:48:26 +02:00
Jan Nieuwenhuizen 92a330ff07 mescc: Support anonymous enums.
* module/language/c99/compiler.mes (enum-def-list->constants): New function.
  (ast->info): Support anonymous enum.
2017-05-25 07:57:26 +02:00
Jan Nieuwenhuizen 6af7556d51 mescc: C99 header files and declaraions.
* libc/include/assert.h (assert_fail):
* libc/include/stdio.h:
+int eputs (char const* s);
+int fputs (char const* s);
+int puts (char const* s);
+int putchar (int c);
+int fputc (int c, int fd);
+int getchar ();
* libc/include/stdlib.h:
+char* getenv (char const* s)
+int atoi (char const *s);
+int *malloc (size_t);
+int *realloc (int *p, int size);
* libc/include/unistd.h (access):
* src/lib.c (display_helper):
* src/mes.c (read_input_file_env):
* src/posix.c: Include unistd.h.
2017-05-23 07:16:08 +02:00
Jan Nieuwenhuizen 174c7a5e22 guix: Update from Guix.
* guix.scm (mes): Update from Guix.
2017-05-23 20:11:51 +02:00
Jan Nieuwenhuizen 73b31ae00b build: Use separate preprocessing stage for mescc.
* make/mescc-guile.make (mescc.scm-c-preprocess, (mescc.scm-compile-E):
  New defines.
  [!MESC_DIRECT]Compile .o via separate preprocessed .E stage.
2017-05-22 21:15:58 +02:00
Jan Nieuwenhuizen cf51f3f5bd mescc: support -E.
* guile/mescc.scm (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.
* scripts/mescc.mes (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.
2017-05-22 19:22:18 +02:00
Jan Nieuwenhuizen 3c880bbb56 mescc: Refactor mlibc compilation.
* libc/libc-mes.c: New file.  Contents from module/mes/libc.mes, module/mes/libc-i386.mes.
* libc/libc-gcc.c: Rename from libc/mlibc.c, include libc/mstart.c
* libc/mstart.c: Remove.
* module/mes/libc-i386.mes: Remove.
* module/mes/libc-i386.scm: Remove.
* module/mes/libc.mes: Remove.
* module/mes/libc.scm: Remove.
* GNUmakefile (CFLAGS): Include libc-gcc.c (WAS: mlibc.c).
* make/bin-mlibc.make (C_FLAGS): Remove start.c include.
* make/mescc-guile.make: Rewrite using compile, link.
* make/mescc-mes.make: Likewise.
* scaffold/m.c: Update.
2017-05-21 22:25:02 +02:00
Jan Nieuwenhuizen 2027754a59 mescc: support -c, -o.
* module/language/c99/compiler.mes: Throughout: quote lambda's.
  (current-eval): New function.
  Thanks Andy!
  (object->list): New function.  Update callers.
  (c99-input->info): Dump a.o.
  (initzer->non-const, function:object->list): New functions.
  (info:object->list): New function.
  (c99-input->elf): Call it.
* module/mes/as-i386: Throughout: quote lambda's.
* scripts/mescc.mes (main): Rewrite.
* guile/mescc.scm (main): Likewise.
2017-05-17 13:56:25 +02:00
Jan Nieuwenhuizen bdd160241b mes: Bugifx for number->string radix > 10.
* module/mes/scm.mes (number->string): Bugfix for `10' -> hex/radix > 10.
2017-05-23 06:28:37 +02:00
Jan Nieuwenhuizen 21aff4c7ad mes: Simplify read-string.
* module/mes/guile.mes (read-string): Simplify, probably fix even.
2017-05-21 12:21:07 +02:00
Jan Nieuwenhuizen 78a066ff3f mescc: Remove LALR C frontend prototype.
* module/language/c/compiler.mes: Remove.
* module/language/c/lexer.mes: Remove.
* module/language/c/parser.mes: Remove.
2017-05-21 12:38:29 +02:00