add support to use zig as a linker driver

closes #243

I also added --grep to ./run_tests if you want to single out
some specific tests
This commit is contained in:
Andrew Kelley
2017-04-05 07:46:50 -04:00
parent 8c10b6dcbd
commit d65cd73a8b
9 changed files with 237 additions and 92 deletions

View File

@@ -3743,6 +3743,18 @@ static void do_code_gen(CodeGen *g) {
char *error = nullptr;
LLVMVerifyModule(g->module, LLVMAbortProcessAction, &error);
#endif
char *err_msg = nullptr;
Buf *out_file_o = buf_create_from_buf(g->root_out_name);
const char *o_ext = target_o_file_ext(&g->zig_target);
buf_append_str(out_file_o, o_ext);
if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(out_file_o),
LLVMObjectFile, &err_msg))
{
zig_panic("unable to write object file: %s", err_msg);
}
g->link_objects.append(out_file_o);
}
static const size_t int_sizes_in_bits[] = {
@@ -4550,6 +4562,10 @@ void codegen_add_root_assembly(CodeGen *g, Buf *src_dir, Buf *src_basename, Buf
do_code_gen(g);
}
void codegen_add_object(CodeGen *g, Buf *object_path) {
g->link_objects.append(object_path);
}
static const char *c_int_type_names[] = {
[CIntTypeShort] = "short",