ability to export .o file

This commit is contained in:
Andrew Kelley
2015-11-27 22:13:39 -07:00
parent 03f9922734
commit f6529341a2
4 changed files with 17 additions and 4 deletions

View File

@@ -994,7 +994,10 @@ void code_gen_link(CodeGen *g, const char *out_file) {
Buf out_file_o = BUF_INIT;
buf_init_from_str(&out_file_o, out_file);
buf_append_str(&out_file_o, ".o");
if (g->out_type != OutTypeObj) {
buf_append_str(&out_file_o, ".o");
}
char *err_msg = nullptr;
if (LLVMZigTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&out_file_o),
@@ -1003,6 +1006,17 @@ void code_gen_link(CodeGen *g, const char *out_file) {
zig_panic("unable to write object file: %s", err_msg);
}
if (g->out_type == OutTypeObj) {
return;
}
if (g->out_type == OutTypeLib && g->is_static) {
// invoke `ar`
zig_panic("TODO invoke ar");
return;
}
// invoke `ld`
ZigList<const char *> args = {0};
if (g->is_static) {
args.append("-static");