Jan Nieuwenhuizen
350d94aa77
build: Support tcc, create tinycc-seed with tcc.
...
* configure: check for tcc.
* build-aux/cc32-mes.sh: Rename from cc-mes-gcc.sh. Support
tcc. Update users.
* build-aux/build-cc32-mes.sh: Rename from build-mes-gcc.sh. Update users.
* GNUmakefile (mes-tcc): New target.
* .gitignore: Ignore mes-tcc arch output.
* lib/crt1.c (_start): Add "rm" constraint so satisfy tcc.
* lib/linux-gcc.c (_sys_call, _sys_call1 _sys_call2 _sys_call3): Likewise.
2018-06-24 09:28:23 +02:00
Jan Nieuwenhuizen
41a6585295
mescc: Support binutils 2.20.1: vfprint, vsprintf: %llx.
...
* lib/libc+tcc.c (vfprintf, vsprintf): Handle %%llx. Print error:
should we skip another int, va_arg a long long?
2018-06-24 17:26:53 +02:00
Jan Nieuwenhuizen
2551eef953
mescc: Support binutils 2.14: vfprint, vsprintf: %12.10d.
...
* lib/libc+tcc.c (vfprintf, vsprintf): Handle %12.10d.
* scaffold/tests/70-printf.c: Test it.
2018-06-21 00:27:49 +02:00
Jan Nieuwenhuizen
f245237f83
mescc: Support gnu toolchain: libtcc1.
...
* lib/libtcc1.c: New file.
* lib/libc+tcc-gcc.c: Remove libtcc1 stubs.
2018-06-19 20:29:25 +02:00
Jan Nieuwenhuizen
63bf9bb2f7
mescc: Support Tinycc 0.9.27: Drop dlclose, dlopen.
...
* lib/libc+tcc.c (dlclose, dlopen): Remove.
* include/dlfcn.h (RTLD_DEFAULT): Add.
2018-06-18 22:56:06 +02:00
Jan Nieuwenhuizen
22a22c1de8
mescc: Support binutils 2.25: fseek: Add debug printing.
...
* lib/libc+tcc.c (fseek): Add debug printing.
2018-06-17 14:17:39 +02:00
Jan Nieuwenhuizen
2062826435
mescc: Tinycc support: bcopy: Do not return void.
...
* lib/m4.c (bcopy): Do not return void. Helps tcc.
2018-06-17 14:16:05 +02:00
Jan Nieuwenhuizen
c6ae0f41a3
mescc: Support binutils 2.25: memcmp: Support size 0.
...
* lib/libc+tcc.c (memcmp): Support size 0.
2018-06-17 10:18:59 +02:00
Jan Nieuwenhuizen
0639e3faf1
mescc: Support binutils 2.25: vsscanf: Skip `l'.
...
* lib/libc+tcc.c (vsscanf): Skip `l'.
2018-06-17 09:26:34 +02:00
Jan Nieuwenhuizen
49bcea84fd
mescc: Debugging oops.
...
* lib/libc.c (__mes_debug): Oops, wrong direction.
2018-06-17 08:39:31 +02:00
Jan Nieuwenhuizen
a9215931e8
mescc: Support binutils 2.15a: fread: read ungetc'd chars too.
...
* lib/libmes.c (_ungetc_fd): New variable.
(fdgetc): Use it.
(_fdungetc_p): New function.
* lib/libc+tcc.c (_fungetc_p): New function.
* lib/libc+tcc.c (fread): Use it to read ungetc'd chars too.
2018-06-16 20:51:16 +02:00
Jan Nieuwenhuizen
65d530f4ec
mescc: Support binutils-2.14: fopen: Return 0 upon failure.
...
* lib/libc+tcc.c (fopen): Return 0 upon failure.
2018-06-16 10:54:59 +02:00
Jan Nieuwenhuizen
125b43acc8
mescc: Update elf32-header for linux-4.17.
...
Previously, our binaries showed this
$ readelf -s scaffold/main.mes-out
There are 2 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x01000000 0x01000000 0x0557c 0x0557c RWE 0x1
LOAD 0x000000 0x01000000 0x01000000 0x0557c 0x0557c RWE 0x1
Section to Segment mapping:
Segment Sections...
00 .text .data
01 .text .data
Linux-4.17 refuses to run this and says
Uhuuh, elf segment at 0000000001000000 requested but the memory is mapped already
Segmentation fault
* lib/x86-mes/elf32-header.hex2: Remove unused data program header.
2018-06-16 08:32:12 +02:00
Jan Nieuwenhuizen
c086f67cec
mescc: Support less-patched tcc/gcc: Add crti and crtn.
...
* lib/crt0.c[__MESC__]: Support MesCC.
* lib/crti.c: New file.
* lib/crtn.c: New file.
* build-aux/build-mes-gcc.sh: Build them.
2018-06-10 16:03:18 +02:00
Jan Nieuwenhuizen
c2c3554884
mescc: Refactor debug and stub printing.
...
* lib/libc.c (__mes_debug): New function. Use it for debug printing
and in stubs throughout.
2018-06-10 14:07:19 +02:00
Jan Nieuwenhuizen
18194b1ae4
mescc: Support binutils-2.30: fopen fix.
...
* lib/libc+tcc.c (fopen): Set O_APPEND for 'a'.
2018-06-10 13:33:30 +02:00
Jan Nieuwenhuizen
c349f6fdd8
mescc: Support binutils-2.30.
...
* lib/binutils.c (raise, strdup): New function.
(mbstowcs): New stub.
* include/fcntl.h (O_APPEND, FD_CLOEXEC): New define.
2018-06-09 17:58:47 +02:00
Jan Nieuwenhuizen
53dd76ffc0
mescc: Support binutils-2.10.1: Stubs set errno to 0.
2018-06-09 11:28:31 +02:00
Jan Nieuwenhuizen
bb3353a272
mescc: Silence some stubs.
...
* lib/libc+tcc.c: [!NOISY_FLOATS, !NOISY_TIMES]: Silence stubs.
* lib/gcc.c: Likewise.
* lib/binutils.c: Likewise.
2018-06-09 07:40:07 +02:00
Jan Nieuwenhuizen
a744fd9ba4
mescc: Add debug printing: fopen, fwrite.
...
* lib/libc+tcc.c (fopen, fwrite)[MESC_DEBUG]: Print debug info.
2018-06-10 07:51:56 +02:00
Jan Nieuwenhuizen
3ba5b23dab
mescc: Support binutils-2.10.1: opentype `r+'.
...
* lib/libc+tcc.c (fopen): Support opentype `r+'.
2018-06-10 07:51:10 +02:00
Jan Nieuwenhuizen
831bd71a14
mescc: syscall: return only ever error -1, set errno.
2018-06-08 07:17:51 +02:00
Jan Nieuwenhuizen
b7d913d7a0
mescc: Support gcc-2.95: Add getpwnam stub.
...
* lib/gcc.c (getpwnam): New stub.
2018-06-07 18:04:17 +02:00
Jan Nieuwenhuizen
a70bc92857
mescc: Support gcc-3.0: Implement alarm, setitimer.
2018-06-07 18:03:51 +02:00
Jan Nieuwenhuizen
ef0a39547c
mescc: Support gcc-3.0: Implement atexit.
2018-06-07 18:02:21 +02:00
Jan Nieuwenhuizen
93cb6375ae
mescc: Support gcc-3.0: Implement dup2, fcntl, getrusage.
...
* include/sys/resource.h: New file.
* lib/linux+gnu.c (fcntl, dup2, getrusage): New function.
* lib/binutils.c (fcntl): Remove stub.
2018-06-07 08:02:32 +02:00
Jan Nieuwenhuizen
b7c35dad69
mescc: Support gcc-3.2: Implement getuid, getgid.
...
* lib/linux+gnu.c (getuid, getdid): New function.
* lib/binutils.c (getuid, getdid): Remove stub.
2018-06-07 07:19:01 +02:00
Jan Nieuwenhuizen
d1e3a786aa
mescc: Support gcc-3.2: Reset errno.
...
* lib/linux-gcc.c (_sys_call, _sys_call1, _sys_call2, _sys_call3):
Reset errno.
* lib/linux-mes.c (__sys_call, __sys_call1, __sys_call2 ,
__sys_call3): Rename from _*.
(_sys_call, _sys_call1, _sys_call2, _sys_call3): New function.
Reset errno.
2018-06-07 07:16:43 +02:00
Jan Nieuwenhuizen
cc466662b9
mescc: Support gcc-3.2: Implement integer strto*.
...
* lib/libc+tcc.c (strtoll, strtoul): Call strtoul.
2018-06-06 22:39:57 +02:00
Jan Nieuwenhuizen
04302b3fe4
mescc: Support gcc-3.2: Add getpid, signal.
...
* lib/linux+gnu.c (getpid, signal): New function.
* include/signal.h: Declare signal.
* include/unistd.h: Declare getpid.
* scaffold/tests/95-signal.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-06-06 22:14:35 +02:00
Jan Nieuwenhuizen
7c4a6a88ed
mescc: Support gcc-3.4.0: *printf: Support `%n'.
...
* lib/libc+tcc.c (vfprintf, vsprintf): Support `%n'. For Gcc 3.4.0.
* scaffold/tests/70-printf.c: Test it.
2018-06-06 19:29:32 +02:00
Jan Nieuwenhuizen
f4616dfef1
mescc: Support gcc-3.4.0: alloca.
...
* lib/alloca.c: New file.
* AUTHORS: Mention it.
* lib/libc+gnu.c: Add it.
* include/stdlib.h: Declare alloca.
2018-06-06 19:44:29 +02:00
Jan Nieuwenhuizen
f60cac6e1d
mescc: Support gcc-3.4.0: unsetenv.
...
* lib/gcc.c (unsetenv): New function.
2018-06-06 19:43:32 +02:00
Jan Nieuwenhuizen
4f6f79973e
mescc: Support gcc-3.2: Add __divdi3, __moddi3 stubs.
...
* lib/gcc.c (__divdi3, __moddi3): New stubs.
2018-06-06 17:02:01 +02:00
Jan Nieuwenhuizen
0f3856f7b4
mescc: Support gcc-3.2: puts with newline.
...
* lib/libc-mini.c (oputs): Rename from puts.
(puts): New function: Add newline.
2018-06-06 15:55:03 +02:00
Jan Nieuwenhuizen
eb939b11b8
mescc: Support binutils-2.10.1.
...
xx
2018-06-06 13:16:25 +02:00
Jan Nieuwenhuizen
635dfd03a2
mescc: Support glibc-1.06.4.
...
* lib/glibc.c: New file.
* lib/libc+gnu.c: Include it.
2018-06-03 18:54:26 +02:00
Jan Nieuwenhuizen
de964f3e1f
mescc: Support gcc-2.6.3.
...
* TODO
2018-06-02 11:41:06 +02:00
Jan Nieuwenhuizen
f1efaa0e93
mescc: Support binutils-2.5.1.
...
* include/stdint.h: #undef types before typedef'ing them.
* include/sys/types.h: Likewise.
* include/string.h (NULL): New define.
* include/stdio.h (BUFSIZ): New define.
2018-05-30 21:55:39 +02:00
Jan Nieuwenhuizen
a3a3654d54
mescc: Implement fflush, sscanf, vsscanf.
...
* lib/libc+tcc.c (vsscanf): New function.
(sscanf): Use it.
(fflush): Remove stub notice; we have no buffering.
* include/stdarg.h: Declare it.
* scaffold/tests/87-sscanf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-05-30 21:49:40 +02:00
Jan Nieuwenhuizen
272b522962
build: Use arch-dir.
...
* lib/x86-mes: Move from stage0.
* build-aux/build-cc.sh: Create libraries in lib/gcc. Update users.
* build-aux/build-mes.sh: Create libraries in lib/x86-mes. Update users.
* build-aux/build-mes-gcc.sh: Rename from build-mlibc.sh. Create
libraries in lib/x86-mes-gcc. Update callers.
* build-aux/cc-mes-gcc.sh: Rename from cc-mlibc.sh. Update callers.
2018-05-29 20:07:46 +02:00
Jan Nieuwenhuizen
9f90960392
mlibc: Implement strstr.
...
* lib/libc+tcc.c (_memmem, memmem): New function. Import from GNU
LilyPond.
(strstr): Implement using memmem.
* include/string.h (_memmem, memmem): Declare.
* AUTHORS: Add Han-Wen Nienhuys.
2018-05-29 19:35:20 +02:00
Jan Nieuwenhuizen
26e1876d12
mlibc: Implement ftell, fseek.
...
* lib/libc+tcc.c (ftell, fseek): Implement.
2018-05-29 19:33:32 +02:00
Jan Nieuwenhuizen
2cda87257a
mlibc: Cleanup.
2018-05-29 18:15:22 +02:00
Jan Nieuwenhuizen
559699969c
mescc: m4 support: WIP
2018-05-27 10:28:30 +02:00
Jan Nieuwenhuizen
a10c48735d
mescc: Posixify interface.
...
* module/mescc/compile.mes: Move from language/c99/compiler.mes.
* module/mescc: New module..
* module/mescc/M1.scm: Move from mes/M1.mes.
* module/mescc/as.scm: Likewise.
* module/mescc/bytevectors.scm: Likewise.
* module/mescc/mescc.scm: New file.
* scripts/mescc: Update to new layout and posixy interface.
* GNUmakefile: Likewise.
* build-aux/build-cc.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-mlibc.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc-mlibc.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/test.sh: Likewise.
* build.sh: Likewise.
* .gitignore: Update for posixy extensions.
2018-05-25 08:05:02 +02:00
Jan Nieuwenhuizen
e4d0298d1b
core: Support fork, waitpid, execve.
...
* stage0/x86.M1 (SYS_fork, SYS_waitpid, SYS_execve): New define.
* lib/linux-gcc.c (fork, waitpid, execve): New function.
* lib/linux-mes.c (fork, waitpid, execve): New function.
* lib/libc.c (wait): New function.
* include/unistd.h (fork, execve): Declare.
* include/sys/wait.h (waitpid, wait): Declare.
* module/mes/posix.mes (search-path, execlp, system*, waitpid): New function.
* src/posix.c (primitive_fork, execl): New function.
2018-05-24 19:54:42 +02:00
Jeremiah Orians
43a74e382a
mescc: Add fopen.
...
* lib/libc+tcc.c (fopen)[!POSIX]: Remove stub.
* lib/libc.c (fopen)[!POSIX]: New function.
* AUTHORS: Add Jeremiah.
2018-05-26 16:33:00 -04:00
Jan Nieuwenhuizen
948fbf9743
mescc: Tinycc support: strncpy.
...
* lib/libc+tcc.c (strncpy): New function.
* scaffold/tests/86-strncpy.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
* build-aux/cc-mlibc.sh (LIBC): Acknowlegde.
* build-aux/test.sh (LIBC): Export it.
2018-05-20 10:55:44 +02:00
Jan Nieuwenhuizen
8f1a26b40a
tinycc: Add stubs: __fixdfdi, __fixxfdi, __fixsfdi.
...
* lib/libc+tcc-gcc.c (__fixdfdi, __fixxfdi, __fixsfdi): New stub.
2018-05-21 08:43:58 +02:00