| author | |
| committer | |
| log | ee263a15cc8fb52c2ac6053a29168fb15089839b |
| tree | 54f95fe907951f15648a157a03ad2c3835b6f0c6 |
| parent | 25466ffb71d653e3353bf6d86ef55bc2a4da1d59 |
| signature |
we need somewhere to put .o files and leave them while the user
executes their program, so that stack traces on MacOS can find
the .o files and get at the DWARF info.
if we try to clean up old global tmp dir files, first of all that's
a hard and complicated problem, and secondly it's not clear how
that is better than dumping the .o file inside zig-cache locally.5 files changed, 7 insertions(+), 24 deletions(-)
src/all_types.hpp+1| ... | @@ -1682,6 +1682,7 @@ struct CodeGen { | ... | @@ -1682,6 +1682,7 @@ struct CodeGen { |
| 1682 | Buf output_file_path; | 1682 | Buf output_file_path; |
| 1683 | Buf o_file_output_path; | 1683 | Buf o_file_output_path; |
| 1684 | Buf *wanted_output_file_path; | 1684 | Buf *wanted_output_file_path; |
| 1685 | Buf cache_dir; | ||
| 1685 | 1686 | ||
| 1686 | IrInstruction *invalid_instruction; | 1687 | IrInstruction *invalid_instruction; |
| 1687 | 1688 |
src/cache_hash.cpp-8| ... | @@ -467,11 +467,3 @@ void cache_release(CacheHash *ch) { | ... | @@ -467,11 +467,3 @@ void cache_release(CacheHash *ch) { |
| 467 | assert(ch->manifest_file_path != nullptr); | 467 | assert(ch->manifest_file_path != nullptr); |
| 468 | os_file_close(ch->manifest_file); | 468 | os_file_close(ch->manifest_file); |
| 469 | } | 469 | } |
| 470 | |||
| 471 | Buf *get_random_basename() { | ||
| 472 | Buf *result = buf_alloc(); | ||
| 473 | for (size_t i = 0; i < 16; i += 1) { | ||
| 474 | buf_append_char(result, base64_fs_alphabet[rand() % 64]); | ||
| 475 | } | ||
| 476 | return result; | ||
| 477 | } |
src/cache_hash.hpp-4| ... | @@ -68,8 +68,4 @@ Error ATTRIBUTE_MUST_USE cache_final(CacheHash *ch, Buf *out_b64_digest); | ... | @@ -68,8 +68,4 @@ Error ATTRIBUTE_MUST_USE cache_final(CacheHash *ch, Buf *out_b64_digest); |
| 68 | void cache_release(CacheHash *ch); | 68 | void cache_release(CacheHash *ch); |
| 69 | 69 | ||
| 70 | 70 | ||
| 71 | |||
| 72 | // Completely independent function. Just returns a random filename safe basename. | ||
| 73 | Buf *get_random_basename(); | ||
| 74 | |||
| 75 | #endif | 71 | #endif |
src/codegen.cpp+1-4| ... | @@ -8195,8 +8195,6 @@ void codegen_build_and_link(CodeGen *g) { | ... | @@ -8195,8 +8195,6 @@ void codegen_build_and_link(CodeGen *g) { |
| 8195 | } | 8195 | } |
| 8196 | 8196 | ||
| 8197 | os_path_join(stage1_dir, buf_create_from_str("artifact"), artifact_dir); | 8197 | os_path_join(stage1_dir, buf_create_from_str("artifact"), artifact_dir); |
| 8198 | } else { | ||
| 8199 | os_path_join(stage1_dir, buf_create_from_str("tmp"), artifact_dir); | ||
| 8200 | } | 8198 | } |
| 8201 | 8199 | ||
| 8202 | if (g->enable_cache && buf_len(&digest) != 0) { | 8200 | if (g->enable_cache && buf_len(&digest) != 0) { |
| ... | @@ -8217,8 +8215,7 @@ void codegen_build_and_link(CodeGen *g) { | ... | @@ -8217,8 +8215,7 @@ void codegen_build_and_link(CodeGen *g) { |
| 8217 | } | 8215 | } |
| 8218 | os_path_join(artifact_dir, &digest, &g->artifact_dir); | 8216 | os_path_join(artifact_dir, &digest, &g->artifact_dir); |
| 8219 | } else { | 8217 | } else { |
| 8220 | Buf *tmp_basename = get_random_basename(); | 8218 | buf_init_from_buf(&g->artifact_dir, &g->cache_dir); |
| 8221 | os_path_join(artifact_dir, tmp_basename, &g->artifact_dir); | ||
| 8222 | } | 8219 | } |
| 8223 | if ((err = os_make_path(&g->artifact_dir))) { | 8220 | if ((err = os_make_path(&g->artifact_dir))) { |
| 8224 | fprintf(stderr, "Unable to create artifact directory: %s\n", err_str(err)); | 8221 | fprintf(stderr, "Unable to create artifact directory: %s\n", err_str(err)); |
src/main.cpp+5-8| ... | @@ -353,7 +353,7 @@ int main(int argc, char **argv) { | ... | @@ -353,7 +353,7 @@ int main(int argc, char **argv) { |
| 353 | size_t ver_minor = 0; | 353 | size_t ver_minor = 0; |
| 354 | size_t ver_patch = 0; | 354 | size_t ver_patch = 0; |
| 355 | bool timing_info = false; | 355 | bool timing_info = false; |
| 356 | const char *cache_dir = nullptr; | 356 | const char *cache_dir = default_zig_cache_name; |
| 357 | CliPkg *cur_pkg = allocate<CliPkg>(1); | 357 | CliPkg *cur_pkg = allocate<CliPkg>(1); |
| 358 | BuildMode build_mode = BuildModeDebug; | 358 | BuildMode build_mode = BuildModeDebug; |
| 359 | ZigList<const char *> test_exec_args = {0}; | 359 | ZigList<const char *> test_exec_args = {0}; |
| ... | @@ -402,6 +402,7 @@ int main(int argc, char **argv) { | ... | @@ -402,6 +402,7 @@ int main(int argc, char **argv) { |
| 402 | os_path_join(special_dir, buf_create_from_str("build_runner.zig"), build_runner_path); | 402 | os_path_join(special_dir, buf_create_from_str("build_runner.zig"), build_runner_path); |
| 403 | 403 | ||
| 404 | CodeGen *g = codegen_create(build_runner_path, nullptr, OutTypeExe, BuildModeDebug, zig_lib_dir_buf); | 404 | CodeGen *g = codegen_create(build_runner_path, nullptr, OutTypeExe, BuildModeDebug, zig_lib_dir_buf); |
| 405 | buf_init_from_str(&g->cache_dir, cache_dir); | ||
| 405 | codegen_set_out_name(g, buf_create_from_str("build")); | 406 | codegen_set_out_name(g, buf_create_from_str("build")); |
| 406 | 407 | ||
| 407 | Buf *build_file_buf = buf_create_from_str(build_file); | 408 | Buf *build_file_buf = buf_create_from_str(build_file); |
| ... | @@ -410,13 +411,8 @@ int main(int argc, char **argv) { | ... | @@ -410,13 +411,8 @@ int main(int argc, char **argv) { |
| 410 | Buf build_file_dirname = BUF_INIT; | 411 | Buf build_file_dirname = BUF_INIT; |
| 411 | os_path_split(&build_file_abs, &build_file_dirname, &build_file_basename); | 412 | os_path_split(&build_file_abs, &build_file_dirname, &build_file_basename); |
| 412 | 413 | ||
| 413 | Buf full_cache_dir = BUF_INIT; | 414 | Buf *cache_dir_buf = buf_create_from_str(cache_dir); |
| 414 | if (cache_dir == nullptr) { | 415 | Buf full_cache_dir = os_path_resolve(&cache_dir_buf, 1); |
| 415 | os_path_join(&build_file_dirname, buf_create_from_str(default_zig_cache_name), &full_cache_dir); | ||
| 416 | } else { | ||
| 417 | Buf *cache_dir_buf = buf_create_from_str(cache_dir); | ||
| 418 | full_cache_dir = os_path_resolve(&cache_dir_buf, 1); | ||
| 419 | } | ||
| 420 | 416 | ||
| 421 | args.items[1] = buf_ptr(&build_file_dirname); | 417 | args.items[1] = buf_ptr(&build_file_dirname); |
| 422 | args.items[2] = buf_ptr(&full_cache_dir); | 418 | args.items[2] = buf_ptr(&full_cache_dir); |
| ... | @@ -832,6 +828,7 @@ int main(int argc, char **argv) { | ... | @@ -832,6 +828,7 @@ int main(int argc, char **argv) { |
| 832 | Buf *zig_lib_dir_buf = resolve_zig_lib_dir(); | 828 | Buf *zig_lib_dir_buf = resolve_zig_lib_dir(); |
| 833 | 829 | ||
| 834 | CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf); | 830 | CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, zig_lib_dir_buf); |
| 831 | buf_init_from_str(&g->cache_dir, cache_dir); | ||
| 835 | codegen_set_out_name(g, buf_out_name); | 832 | codegen_set_out_name(g, buf_out_name); |
| 836 | codegen_set_lib_version(g, ver_major, ver_minor, ver_patch); | 833 | codegen_set_lib_version(g, ver_major, ver_minor, ver_patch); |
| 837 | codegen_set_is_test(g, cmd == CmdTest); | 834 | codegen_set_is_test(g, cmd == CmdTest); |