ability to export .o file
parent
03f9922734
commit
f6529341a2
|
@ -34,7 +34,6 @@ readable, safe, optimal, and concise code to solve any computing problem.
|
|||
|
||||
* Math expression
|
||||
* Export .so library
|
||||
* Export .o file
|
||||
* Multiple files
|
||||
* inline assembly and syscalls
|
||||
* running code at compile time
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -156,7 +156,7 @@ static LLVMBool LLVMZigTargetMachineEmit(LLVMTargetMachineRef targ_machine_ref,
|
|||
}
|
||||
|
||||
LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref,
|
||||
char* filename, LLVMCodeGenFileType codegen, char** err_msg)
|
||||
const char* filename, LLVMCodeGenFileType codegen, char** err_msg)
|
||||
{
|
||||
std::error_code error_code;
|
||||
raw_fd_ostream dest(filename, error_code, sys::fs::F_None);
|
||||
|
|
|
@ -22,7 +22,7 @@ char *LLVMZigGetHostCPUName(void);
|
|||
char *LLVMZigGetNativeFeatures(void);
|
||||
|
||||
LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef target_machine, LLVMModuleRef module,
|
||||
char* filename, LLVMCodeGenFileType codegen, char** error_msg);
|
||||
const char* filename, LLVMCodeGenFileType codegen, char** error_msg);
|
||||
|
||||
void LLVMZigOptimizeModule(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref);
|
||||
|
||||
|
|
Loading…
Reference in New Issue