Tinycc - is my favorit compiler :) but I have something to say.
At first, some operating variables, like inc, loc, text_section, etc., declared as static to speed up compilation. But becouse of this nested or parallel compilation brokes. If we move this static global variables to non-static TCCState members we may enabling nested or parallel compilation. I wrote a patch. Lets see.
void comp_n_exec(const char *s) { TCCState *st = tcc_new(); int n; tcc_set_error_func(st, &n, err); tcc_compile_string(st, s, NULL); tcc_add_symbol(st, "printf", (void*)printf); tcc_add_symbol(st, "comp_n_exec", (void*)comp_n_exec); int rc = tcc_relocate(st); if (rc) printf("reloc error"); int (*cmain)(); cmain = (int(*)())tcc_get_symbol(st, "main"); cmain(); tcc_free(st,st);
}
int main() { comp_n_exec("int main()\n" "{\n" " printf(\"msg first\");\n" " comp_n_exec(\"int main() {printf(\\\"msg center\\\");}\");\n" " printf(\"msg last\");\n" "}"); return 0; } EOF $gcc ./nest.c -lm -ldl -o nest.out We'll see that al allright!! But excluding static variables makes new problem - how to transfer TCCState pointer to glibc baser sig_error function? Thats the problem. Mb someone wah ideas?
p.s. Many tcc type convertion a raw! at example: $cat > mchar.c <<"EOF" #define TCC_TARGET_X86_64 1 #include "tinycc_new/libtcc.c" #include <stdio.h>
int main() { TCCState *st = tcc_new(); int n; tcc_set_error_func(st, &n, err); tcc_compile_string(st, "int main() {long n=49; if (n>128) printf(\"sux\"); else printf(\"gut\");}", NULL); tcc_add_symbol(st, "printf", (void*)printf); int rc = tcc_relocate(st); if (rc) printf("reloc error"); int (*cmain)(); cmain = (int(*)())tcc_get_symbol(st, "main"); cmain(); tcc_free(st,st); return 0; } EOF If we $gcc ./mchar.c -lm -ldl -o mchar.out that we'll be all gut. Program prints gut, and that's Ok but If we $gcc ./mchar.c -lm -ldl -o mchar.out -funsigned-char The program prints sux, and it's not good not gut. It's SUXX :(
Where are a great more to do...
Best Regards, Archidemon mailto:address@hidden
---------------------------------------------------------------------- Zimbabwe CMS - best c script(tcc) based CMS ever!