diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-04-28 02:22:12 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-04-28 02:22:12 -0400 |
| commit | a147f065850af8f9422d19d14aec0476b641cb07 (patch) | |
| tree | 7a4a2393b18027ddc3cfd972ebe0dda9d0a89b50 /src/codegen.cpp | |
| parent | 458afb0ef9634b6a0480bcb6e07a92cd9a330d84 (diff) | |
| download | zig-a147f065850af8f9422d19d14aec0476b641cb07.tar.gz zig-a147f065850af8f9422d19d14aec0476b641cb07.zip | |
zig puts temporary object files in zig-cache folder
See #298
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 2b48450711..a57ff40be3 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -204,6 +204,10 @@ void codegen_set_out_name(CodeGen *g, Buf *out_name) { g->root_out_name = out_name; } +void codegen_set_cache_dir(CodeGen *g, Buf *cache_dir) { + g->cache_dir = cache_dir; +} + void codegen_set_libc_lib_dir(CodeGen *g, Buf *libc_lib_dir) { g->libc_lib_dir = libc_lib_dir; } @@ -3910,16 +3914,22 @@ static void do_code_gen(CodeGen *g) { codegen_add_time_event(g, "LLVM Emit Object"); char *err_msg = nullptr; - Buf *out_file_o = buf_create_from_buf(g->root_out_name); + Buf *o_basename = 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 (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(out_file_o), + buf_append_str(o_basename, o_ext); + Buf *output_path = buf_alloc(); + os_path_join(g->cache_dir, o_basename, output_path); + int err; + if ((err = os_make_path(g->cache_dir))) { + zig_panic("unable to make cache dir: %s", err_str(err)); + } + if (ZigLLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(output_path), LLVMObjectFile, &err_msg, !g->is_release_build)) { zig_panic("unable to write object file: %s", err_msg); } - g->link_objects.append(out_file_o); + g->link_objects.append(output_path); } static const uint8_t int_sizes_in_bits[] = { |
