![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
If you can stand the quirks/don't need C++, Tiny C is amazing. Where GCC takes entire seconds per file on my machine, a Makefile running TCC spills output faster than the xterm can display. I only wish I was kidding!
TCC also comes in a library form that you can plug into your apps to compile C "scripts", can do optional bounds and pointer checking at runtime, and it even squeezes onto a floppy. Mind, it doesn't generate the best code, but then again, most isn't time-sensitive—and if your algorithms depend on a clever optimizer to be usable, they probably won't scale as it is... But I digress. In fact, there was a problem...
Talarubi@FRANCIS /c/Code/Magenta_bloo $ make run tcc -g -o build/magenta.exe Fuschia.o Cyan.o White.o -L/Dev/gc6.6 -lkernel32 -luser32 -lgdi32 -lgc build/magenta.exe Segmentation fault make: *** [run] error 5 Talarubi@FRANCIS /c/Code/Magenta $ gdb build/Magenta.exe The debugging information in `c:\Code\Magenta_bloo/build/Magenta.exe' is corrupted. The file has a `.stabs' section, but no `.stabstr' section. (gdb) break main No symbol table is loaded. Use the "file" command. (gdb) . o O ( wtf? )Further investigation revealed that compiling *.c to a binary worked, but compiling to *.o and linking these somehow mangled the debug symbols. And sure enough, an incriminating remark in tcc/src/tccelf.c:
/* load an object file and merge it with current files */ /* XXX: handle correctly stab (debug) info */ static int tcc_load_object_file( TCCState *s1, int fd, unsigned long file_offset) {
"Correctly?" Erk!! Well they don't call it v0.9 for nothing, but it's not the sort of commentary one wants to see in a compiler!
But with the company of lazyweb, and some quick if mind-numbing research, things are looking up. Many hours later:
# Why not? Btw, no visible delay here Talarubi@FRANCIS /Dev/tcc/src $ ../tcc -g tcc.c -lkernel32 Talarubi@FRANCIS /Dev/tcc/src $ ./tcc -g mathtest.o win32/lib/crt1.o -L./win32/lib -B./win32/lib Talarubi@FRANCIS /Dev/tcc/src $ gdb mathtest.exe (gdb) break main Breakpoint 1 at 0x4011da: file c:/Code/Magenta_bloo/scraps/mathtest.c, line 94. (gdb) list 85 unsigned overflow = xor & (x ^ modulo) & 0x80808080; 86 unsigned over_p = overflow & modulo; 87 over_p = over_p - (over_p >> 7); 88 unsigned over_np = overflow - (overflow >> 7); 89 return (modulo ^ overflow) & ~over_np | over_p; 90 } 91 92 int main(int argc, char**argv) 93 { 94 if( argc < 4 ) (gdb)
And right now this is the most gratifying thing, being able to go and hack on the compiler, and even sort of comprehend what I'm doing. It's the wonderful feeling of a warm light shown on things that are black magic to most people...
Or maybe the feeling I might take over the world next Tuesday. That doesn't seem substantiated, though.
Hi.
Date: 2006-07-28 03:47 am (UTC)