symbol_new(p, 0, "String", SYM_TYPE, 0)->type = &StringType;
}
-static void compile_module(Parser* p, char* path, bool genmain)
+static bool compile_module(Parser* p, char* path, bool genmain)
{
- /* parser the file and generate the code */
+ /* parse the file and generate the code */
init_parser(p, path, genmain);
codegen_init(p);
module(p);
char* asm_path = get_fpath(path, 's');
char* obj_path = get_fpath(path, 'o');
- if (fs_modtime(obj_path) < fs_modtime(path))
+ bool dirty = fs_modtime(obj_path) < fs_modtime(path);
+ if (p->dirty || dirty)
{
/* run llc to generate assembly listing */
char* llc_cmd = strmcat("llc -opaque-pointers -o \"", asm_path , "\" \"", p->outpath, "\"", 0);
// remove(p->outpath);
/* compile the object file now */
- char* as_cmd = strmcat("clang -static -c -o \"", obj_path, "\" \"", asm_path, "\"", 0);
+ char* as_cmd = strmcat("clang -nostdlib -flto -static -O2 -c -o \"", obj_path, "\" \"", asm_path, "\"", 0);
printf("%s\n", as_cmd);
if (system(as_cmd) != 0)
{
}
remove(asm_path);
}
+ return dirty;
}
void add_module(Parser* p, char* modname, char* modpath)
/* parse the module */
Parser p = {0};
- compile_module(&p, path, false);
+ curr->dirty = compile_module(&p, path, false) || curr->dirty;
(void)alias;
/* copy module references over */
{
Parser p = {0};
compile_module(&p, path, true);
- char* link_cmd = strmcat("clang -static -g -o ", p.name, " ", 0);
+ char* link_cmd = strmcat("clang -O2 -g -nostdlib -static -flto -o ", p.name, " ", 0);
for (size_t i = 0; i < p.nmods; i++)
{
+ printf("%lu: %s\n", i, p.mods[i].path);
if (!p.mods[i].path) continue;
char* object = strdup(p.mods[i].path);
object[strlen(object)-1] = 'o';
}
char* object = strdup(p.outpath);
object[strlen(object)-1] = 'o';
- link_cmd = strmcat(link_cmd, "\"", object, "\" ", "-L. ", "-lm ", "-lcerise", 0);
+ link_cmd = strmcat(link_cmd, "\"", object, "\" ", "-L. ", " ", "-lcerise", 0);
puts(link_cmd);
if (system(link_cmd) != 0)
{