| ... | @@ -8283,7 +8283,7 @@ static Error get_tmp_filename(CodeGen *g, Buf *out, Buf *suffix) { | ... | @@ -8283,7 +8283,7 @@ static Error get_tmp_filename(CodeGen *g, Buf *out, Buf *suffix) { |
| 8283 | } | 8283 | } |
| 8284 | | 8284 | |
| 8285 | // returns true if it was a cache miss | 8285 | // returns true if it was a cache miss |
| 8286 | static bool gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | 8286 | static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 8287 | Error err; | 8287 | Error err; |
| 8288 | | 8288 | |
| 8289 | Buf *artifact_dir; | 8289 | Buf *artifact_dir; |
| ... | @@ -8501,23 +8501,16 @@ static bool gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | ... | @@ -8501,23 +8501,16 @@ static bool gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 8501 | os_path_join(artifact_dir, final_o_basename, o_final_path); | 8501 | os_path_join(artifact_dir, final_o_basename, o_final_path); |
| 8502 | } | 8502 | } |
| 8503 | | 8503 | |
| 8504 | if (g->enable_cache) { | | |
| 8505 | cache_buf(&g->cache_hash, &digest); | | |
| 8506 | } | | |
| 8507 | | | |
| 8508 | g->link_objects.append(o_final_path); | 8504 | g->link_objects.append(o_final_path); |
| 8509 | g->caches_to_release.append(cache_hash); | 8505 | g->caches_to_release.append(cache_hash); |
| 8510 | | | |
| 8511 | return is_cache_miss; | | |
| 8512 | } | 8506 | } |
| 8513 | | 8507 | |
| 8514 | // returns true if we had any cache misses | 8508 | // returns true if we had any cache misses |
| 8515 | static bool gen_c_objects(CodeGen *g) { | 8509 | static void gen_c_objects(CodeGen *g) { |
| 8516 | Error err; | 8510 | Error err; |
| 8517 | bool any_cache_misses = false; | | |
| 8518 | | 8511 | |
| 8519 | if (g->c_source_files.length == 0) | 8512 | if (g->c_source_files.length == 0) |
| 8520 | return any_cache_misses; | 8513 | return; |
| 8521 | | 8514 | |
| 8522 | Buf *self_exe_path = buf_alloc(); | 8515 | Buf *self_exe_path = buf_alloc(); |
| 8523 | if ((err = os_self_exe_path(self_exe_path))) { | 8516 | if ((err = os_self_exe_path(self_exe_path))) { |
| ... | @@ -8529,10 +8522,8 @@ static bool gen_c_objects(CodeGen *g) { | ... | @@ -8529,10 +8522,8 @@ static bool gen_c_objects(CodeGen *g) { |
| 8529 | | 8522 | |
| 8530 | for (size_t c_file_i = 0; c_file_i < g->c_source_files.length; c_file_i += 1) { | 8523 | for (size_t c_file_i = 0; c_file_i < g->c_source_files.length; c_file_i += 1) { |
| 8531 | CFile *c_file = g->c_source_files.at(c_file_i); | 8524 | CFile *c_file = g->c_source_files.at(c_file_i); |
| 8532 | bool is_cache_miss = gen_c_object(g, self_exe_path, c_file); | 8525 | gen_c_object(g, self_exe_path, c_file); |
| 8533 | any_cache_misses = any_cache_misses || is_cache_miss; | | |
| 8534 | } | 8526 | } |
| 8535 | return any_cache_misses; | | |
| 8536 | } | 8527 | } |
| 8537 | | 8528 | |
| 8538 | void codegen_add_object(CodeGen *g, Buf *object_path) { | 8529 | void codegen_add_object(CodeGen *g, Buf *object_path) { |
| ... | @@ -9030,7 +9021,7 @@ static void add_cache_pkg(CodeGen *g, CacheHash *ch, ZigPackage *pkg) { | ... | @@ -9030,7 +9021,7 @@ static void add_cache_pkg(CodeGen *g, CacheHash *ch, ZigPackage *pkg) { |
| 9030 | | 9021 | |
| 9031 | // Called before init() | 9022 | // Called before init() |
| 9032 | // is_cache_hit takes into account gen_c_objects | 9023 | // is_cache_hit takes into account gen_c_objects |
| 9033 | static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_objects_generated) { | 9024 | static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { |
| 9034 | Error err; | 9025 | Error err; |
| 9035 | | 9026 | |
| 9036 | Buf *compiler_id; | 9027 | Buf *compiler_id; |
| ... | @@ -9052,7 +9043,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj | ... | @@ -9052,7 +9043,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj |
| 9052 | cache_list_of_buf(ch, g->darwin_frameworks.items, g->darwin_frameworks.length); | 9043 | cache_list_of_buf(ch, g->darwin_frameworks.items, g->darwin_frameworks.length); |
| 9053 | cache_list_of_buf(ch, g->rpath_list.items, g->rpath_list.length); | 9044 | cache_list_of_buf(ch, g->rpath_list.items, g->rpath_list.length); |
| 9054 | cache_list_of_buf(ch, g->forbidden_libs.items, g->forbidden_libs.length); | 9045 | cache_list_of_buf(ch, g->forbidden_libs.items, g->forbidden_libs.length); |
| 9055 | cache_list_of_file(ch, g->link_objects.items, g->link_objects.length); | | |
| 9056 | cache_list_of_file(ch, g->assembly_files.items, g->assembly_files.length); | 9046 | cache_list_of_file(ch, g->assembly_files.items, g->assembly_files.length); |
| 9057 | cache_int(ch, g->emit_file_type); | 9047 | cache_int(ch, g->emit_file_type); |
| 9058 | cache_int(ch, g->build_mode); | 9048 | cache_int(ch, g->build_mode); |
| ... | @@ -9067,6 +9057,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj | ... | @@ -9067,6 +9057,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj |
| 9067 | cache_bool(ch, g->is_static); | 9057 | cache_bool(ch, g->is_static); |
| 9068 | cache_bool(ch, g->strip_debug_symbols); | 9058 | cache_bool(ch, g->strip_debug_symbols); |
| 9069 | cache_bool(ch, g->is_test_build); | 9059 | cache_bool(ch, g->is_test_build); |
| | 9060 | if (g->is_test_build) { |
| | 9061 | cache_buf_opt(ch, g->test_filter); |
| | 9062 | cache_buf_opt(ch, g->test_name_prefix); |
| | 9063 | } |
| 9070 | cache_bool(ch, g->is_single_threaded); | 9064 | cache_bool(ch, g->is_single_threaded); |
| 9071 | cache_bool(ch, g->linker_rdynamic); | 9065 | cache_bool(ch, g->linker_rdynamic); |
| 9072 | cache_bool(ch, g->each_lib_rpath); | 9066 | cache_bool(ch, g->each_lib_rpath); |
| ... | @@ -9078,8 +9072,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj | ... | @@ -9078,8 +9072,6 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj |
| 9078 | cache_usize(ch, g->version_major); | 9072 | cache_usize(ch, g->version_major); |
| 9079 | cache_usize(ch, g->version_minor); | 9073 | cache_usize(ch, g->version_minor); |
| 9080 | cache_usize(ch, g->version_patch); | 9074 | cache_usize(ch, g->version_patch); |
| 9081 | cache_buf_opt(ch, g->test_filter); | | |
| 9082 | cache_buf_opt(ch, g->test_name_prefix); | | |
| 9083 | cache_list_of_str(ch, g->llvm_argv, g->llvm_argv_len); | 9075 | cache_list_of_str(ch, g->llvm_argv, g->llvm_argv_len); |
| 9084 | cache_list_of_str(ch, g->clang_argv, g->clang_argv_len); | 9076 | cache_list_of_str(ch, g->clang_argv, g->clang_argv_len); |
| 9085 | cache_list_of_str(ch, g->lib_dirs.items, g->lib_dirs.length); | 9077 | cache_list_of_str(ch, g->lib_dirs.items, g->lib_dirs.length); |
| ... | @@ -9092,7 +9084,9 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj | ... | @@ -9092,7 +9084,9 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest, bool *c_obj |
| 9092 | } | 9084 | } |
| 9093 | cache_buf_opt(ch, g->dynamic_linker_path); | 9085 | cache_buf_opt(ch, g->dynamic_linker_path); |
| 9094 | | 9086 | |
| 9095 | *c_objects_generated = gen_c_objects(g); | 9087 | // gen_c_objects appends objects to g->link_objects which we want to include in the hash |
| | 9088 | gen_c_objects(g); |
| | 9089 | cache_list_of_file(ch, g->link_objects.items, g->link_objects.length); |
| 9096 | | 9090 | |
| 9097 | buf_resize(digest, 0); | 9091 | buf_resize(digest, 0); |
| 9098 | if ((err = cache_hit(ch, digest))) | 9092 | if ((err = cache_hit(ch, digest))) |
| ... | @@ -9199,12 +9193,11 @@ void codegen_build_and_link(CodeGen *g) { | ... | @@ -9199,12 +9193,11 @@ void codegen_build_and_link(CodeGen *g) { |
| 9199 | | 9193 | |
| 9200 | Buf *artifact_dir = buf_alloc(); | 9194 | Buf *artifact_dir = buf_alloc(); |
| 9201 | Buf digest = BUF_INIT; | 9195 | Buf digest = BUF_INIT; |
| 9202 | bool any_c_objects_generated; | | |
| 9203 | if (g->enable_cache) { | 9196 | if (g->enable_cache) { |
| 9204 | Buf *manifest_dir = buf_alloc(); | 9197 | Buf *manifest_dir = buf_alloc(); |
| 9205 | os_path_join(g->cache_dir, buf_create_from_str("h"), manifest_dir); | 9198 | os_path_join(g->cache_dir, buf_create_from_str("h"), manifest_dir); |
| 9206 | | 9199 | |
| 9207 | if ((err = check_cache(g, manifest_dir, &digest, &any_c_objects_generated))) { | 9200 | if ((err = check_cache(g, manifest_dir, &digest))) { |
| 9208 | if (err == ErrorCacheUnavailable) { | 9201 | if (err == ErrorCacheUnavailable) { |
| 9209 | // message already printed | 9202 | // message already printed |
| 9210 | } else if (err == ErrorNotDir) { | 9203 | } else if (err == ErrorNotDir) { |
| ... | @@ -9219,10 +9212,10 @@ void codegen_build_and_link(CodeGen *g) { | ... | @@ -9219,10 +9212,10 @@ void codegen_build_and_link(CodeGen *g) { |
| 9219 | os_path_join(g->cache_dir, buf_create_from_str("artifact"), artifact_dir); | 9212 | os_path_join(g->cache_dir, buf_create_from_str("artifact"), artifact_dir); |
| 9220 | } else { | 9213 | } else { |
| 9221 | // There is a call to this in check_cache | 9214 | // There is a call to this in check_cache |
| 9222 | any_c_objects_generated = gen_c_objects(g); | 9215 | gen_c_objects(g); |
| 9223 | } | 9216 | } |
| 9224 | | 9217 | |
| 9225 | if (g->enable_cache && buf_len(&digest) != 0 && !any_c_objects_generated) { | 9218 | if (g->enable_cache && buf_len(&digest) != 0) { |
| 9226 | os_path_join(artifact_dir, &digest, &g->artifact_dir); | 9219 | os_path_join(artifact_dir, &digest, &g->artifact_dir); |
| 9227 | resolve_out_paths(g); | 9220 | resolve_out_paths(g); |
| 9228 | } else { | 9221 | } else { |