| author | |
| committer | |
| log | f6529341a2413a3eb72920418d19ea7d2aca089b |
| tree | a861b3c8e2397029c8a6d3039e98c4caa4af6f3b |
| parent | 03f992273493ef1e635a7a3bb3de9c5cd5182789 |
4 files changed, 17 insertions(+), 4 deletions(-)
README.md-1| ... | @@ -34,7 +34,6 @@ readable, safe, optimal, and concise code to solve any computing problem. | ... | @@ -34,7 +34,6 @@ readable, safe, optimal, and concise code to solve any computing problem. |
| 34 | 34 | ||
| 35 | * Math expression | 35 | * Math expression |
| 36 | * Export .so library | 36 | * Export .so library |
| 37 | * Export .o file | ||
| 38 | * Multiple files | 37 | * Multiple files |
| 39 | * inline assembly and syscalls | 38 | * inline assembly and syscalls |
| 40 | * running code at compile time | 39 | * running code at compile time |
src/codegen.cpp+15-1| ... | @@ -994,7 +994,10 @@ void code_gen_link(CodeGen *g, const char *out_file) { | ... | @@ -994,7 +994,10 @@ void code_gen_link(CodeGen *g, const char *out_file) { |
| 994 | 994 | ||
| 995 | Buf out_file_o = BUF_INIT; | 995 | Buf out_file_o = BUF_INIT; |
| 996 | buf_init_from_str(&out_file_o, out_file); | 996 | buf_init_from_str(&out_file_o, out_file); |
| 997 | buf_append_str(&out_file_o, ".o"); | 997 | |
| 998 | if (g->out_type != OutTypeObj) { | ||
| 999 | buf_append_str(&out_file_o, ".o"); | ||
| 1000 | } | ||
| 998 | 1001 | ||
| 999 | char *err_msg = nullptr; | 1002 | char *err_msg = nullptr; |
| 1000 | if (LLVMZigTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&out_file_o), | 1003 | 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) { | ... | @@ -1003,6 +1006,17 @@ void code_gen_link(CodeGen *g, const char *out_file) { |
| 1003 | zig_panic("unable to write object file: %s", err_msg); | 1006 | zig_panic("unable to write object file: %s", err_msg); |
| 1004 | } | 1007 | } |
| 1005 | 1008 | ||
| 1009 | if (g->out_type == OutTypeObj) { | ||
| 1010 | return; | ||
| 1011 | } | ||
| 1012 | |||
| 1013 | if (g->out_type == OutTypeLib && g->is_static) { | ||
| 1014 | // invoke `ar` | ||
| 1015 | zig_panic("TODO invoke ar"); | ||
| 1016 | return; | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | // invoke `ld` | ||
| 1006 | ZigList<const char *> args = {0}; | 1020 | ZigList<const char *> args = {0}; |
| 1007 | if (g->is_static) { | 1021 | if (g->is_static) { |
| 1008 | args.append("-static"); | 1022 | args.append("-static"); |
src/zig_llvm.cpp+1-1| ... | @@ -156,7 +156,7 @@ static LLVMBool LLVMZigTargetMachineEmit(LLVMTargetMachineRef targ_machine_ref, | ... | @@ -156,7 +156,7 @@ static LLVMBool LLVMZigTargetMachineEmit(LLVMTargetMachineRef targ_machine_ref, |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, | 158 | LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref, |
| 159 | char* filename, LLVMCodeGenFileType codegen, char** err_msg) | 159 | const char* filename, LLVMCodeGenFileType codegen, char** err_msg) |
| 160 | { | 160 | { |
| 161 | std::error_code error_code; | 161 | std::error_code error_code; |
| 162 | raw_fd_ostream dest(filename, error_code, sys::fs::F_None); | 162 | raw_fd_ostream dest(filename, error_code, sys::fs::F_None); |
src/zig_llvm.hpp+1-1| ... | @@ -22,7 +22,7 @@ char *LLVMZigGetHostCPUName(void); | ... | @@ -22,7 +22,7 @@ char *LLVMZigGetHostCPUName(void); |
| 22 | char *LLVMZigGetNativeFeatures(void); | 22 | char *LLVMZigGetNativeFeatures(void); |
| 23 | 23 | ||
| 24 | LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef target_machine, LLVMModuleRef module, | 24 | LLVMBool LLVMZigTargetMachineEmitToFile(LLVMTargetMachineRef target_machine, LLVMModuleRef module, |
| 25 | char* filename, LLVMCodeGenFileType codegen, char** error_msg); | 25 | const char* filename, LLVMCodeGenFileType codegen, char** error_msg); |
| 26 | 26 | ||
| 27 | void LLVMZigOptimizeModule(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref); | 27 | void LLVMZigOptimizeModule(LLVMTargetMachineRef targ_machine_ref, LLVMModuleRef module_ref); |
| 28 | 28 |