| author | |
| committer | |
| log | e4edc6d118e0e0cd3510bbe89ca4a292436bb82f |
| tree | f2a90113d86d8157582e57a616b1bcfe2fedcb99 |
| parent | 4aa797b6bb3716759738e057e90ac607e81ce6e5 |
| signature |
Zig disables its caching and forwards these args when any are provided.
see #47847 files changed, 68 insertions(+), 21 deletions(-)
src-self-hosted/clang_options_data.zig+25-4| ... | @@ -26,12 +26,26 @@ flagpd1("H"), | ... | @@ -26,12 +26,26 @@ flagpd1("H"), |
| 26 | }, | 26 | }, |
| 27 | flagpd1("I-"), | 27 | flagpd1("I-"), |
| 28 | flagpd1("M"), | 28 | flagpd1("M"), |
| 29 | flagpd1("MD"), | 29 | .{ |
| 30 | .name = "MD", | ||
| 31 | .syntax = .flag, | ||
| 32 | .zig_equivalent = .dep_file, | ||
| 33 | .pd1 = true, | ||
| 34 | .pd2 = false, | ||
| 35 | .psl = false, | ||
| 36 | }, | ||
| 30 | flagpd1("MG"), | 37 | flagpd1("MG"), |
| 31 | flagpd1("MM"), | 38 | flagpd1("MM"), |
| 32 | flagpd1("MMD"), | 39 | flagpd1("MMD"), |
| 33 | flagpd1("MP"), | 40 | flagpd1("MP"), |
| 34 | flagpd1("MV"), | 41 | .{ |
| 42 | .name = "MV", | ||
| 43 | .syntax = .flag, | ||
| 44 | .zig_equivalent = .dep_file, | ||
| 45 | .pd1 = true, | ||
| 46 | .pd2 = false, | ||
| 47 | .psl = false, | ||
| 48 | }, | ||
| 35 | flagpd1("Mach"), | 49 | flagpd1("Mach"), |
| 36 | flagpd1("O0"), | 50 | flagpd1("O0"), |
| 37 | flagpd1("O4"), | 51 | flagpd1("O4"), |
| ... | @@ -490,7 +504,7 @@ sepd1("Zlinker-input"), | ... | @@ -490,7 +504,7 @@ sepd1("Zlinker-input"), |
| 490 | .{ | 504 | .{ |
| 491 | .name = "MD", | 505 | .name = "MD", |
| 492 | .syntax = .flag, | 506 | .syntax = .flag, |
| 493 | .zig_equivalent = .other, | 507 | .zig_equivalent = .dep_file, |
| 494 | .pd1 = true, | 508 | .pd1 = true, |
| 495 | .pd2 = false, | 509 | .pd2 = false, |
| 496 | .psl = true, | 510 | .psl = true, |
| ... | @@ -5434,7 +5448,14 @@ joinpd1("mtp="), | ... | @@ -5434,7 +5448,14 @@ joinpd1("mtp="), |
| 5434 | joinpd1("gz="), | 5448 | joinpd1("gz="), |
| 5435 | joinpd1("A-"), | 5449 | joinpd1("A-"), |
| 5436 | joinpd1("G="), | 5450 | joinpd1("G="), |
| 5437 | jspd1("MF"), | 5451 | .{ |
| 5452 | .name = "MF", | ||
| 5453 | .syntax = .joined_or_separate, | ||
| 5454 | .zig_equivalent = .dep_file, | ||
| 5455 | .pd1 = true, | ||
| 5456 | .pd2 = false, | ||
| 5457 | .psl = false, | ||
| 5458 | }, | ||
| 5438 | jspd1("MJ"), | 5459 | jspd1("MJ"), |
| 5439 | jspd1("MQ"), | 5460 | jspd1("MQ"), |
| 5440 | jspd1("MT"), | 5461 | jspd1("MT"), |
src-self-hosted/stage2.zig+1| ... | @@ -1290,6 +1290,7 @@ pub const ClangArgIterator = extern struct { | ... | @@ -1290,6 +1290,7 @@ pub const ClangArgIterator = extern struct { |
| 1290 | linker_input_z, | 1290 | linker_input_z, |
| 1291 | lib_dir, | 1291 | lib_dir, |
| 1292 | mcpu, | 1292 | mcpu, |
| 1293 | dep_file, | ||
| 1293 | }; | 1294 | }; |
| 1294 | 1295 | ||
| 1295 | const Args = struct { | 1296 | const Args = struct { |
src/all_types.hpp+2-1| ... | @@ -2230,6 +2230,7 @@ struct CodeGen { | ... | @@ -2230,6 +2230,7 @@ struct CodeGen { |
| 2230 | bool reported_bad_link_libc_error; | 2230 | bool reported_bad_link_libc_error; |
| 2231 | bool is_dynamic; // shared library rather than static library. dynamic musl rather than static musl. | 2231 | bool is_dynamic; // shared library rather than static library. dynamic musl rather than static musl. |
| 2232 | bool need_frame_size_prefix_data; | 2232 | bool need_frame_size_prefix_data; |
| 2233 | bool disable_c_depfile; | ||
| 2233 | 2234 | ||
| 2234 | //////////////////////////// Participates in Input Parameter Cache Hash | 2235 | //////////////////////////// Participates in Input Parameter Cache Hash |
| 2235 | /////// Note: there is a separate cache hash for builtin.zig, when adding fields, | 2236 | /////// Note: there is a separate cache hash for builtin.zig, when adding fields, |
| ... | @@ -2258,6 +2259,7 @@ struct CodeGen { | ... | @@ -2258,6 +2259,7 @@ struct CodeGen { |
| 2258 | const ZigTarget *zig_target; | 2259 | const ZigTarget *zig_target; |
| 2259 | TargetSubsystem subsystem; // careful using this directly; see detect_subsystem | 2260 | TargetSubsystem subsystem; // careful using this directly; see detect_subsystem |
| 2260 | ValgrindSupport valgrind_support; | 2261 | ValgrindSupport valgrind_support; |
| 2262 | CodeModel code_model; | ||
| 2261 | bool strip_debug_symbols; | 2263 | bool strip_debug_symbols; |
| 2262 | bool is_test_build; | 2264 | bool is_test_build; |
| 2263 | bool is_single_threaded; | 2265 | bool is_single_threaded; |
| ... | @@ -2278,7 +2280,6 @@ struct CodeGen { | ... | @@ -2278,7 +2280,6 @@ struct CodeGen { |
| 2278 | bool emit_asm; | 2280 | bool emit_asm; |
| 2279 | bool emit_llvm_ir; | 2281 | bool emit_llvm_ir; |
| 2280 | bool test_is_evented; | 2282 | bool test_is_evented; |
| 2281 | CodeModel code_model; | ||
| 2282 | 2283 | ||
| 2283 | Buf *root_out_name; | 2284 | Buf *root_out_name; |
| 2284 | Buf *test_filter; | 2285 | Buf *test_filter; |
src/codegen.cpp+19-16| ... | @@ -9803,7 +9803,7 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | ... | @@ -9803,7 +9803,7 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 9803 | exit(1); | 9803 | exit(1); |
| 9804 | } | 9804 | } |
| 9805 | } | 9805 | } |
| 9806 | bool is_cache_miss = (buf_len(&digest) == 0); | 9806 | bool is_cache_miss = g->disable_c_depfile || (buf_len(&digest) == 0); |
| 9807 | if (is_cache_miss) { | 9807 | if (is_cache_miss) { |
| 9808 | // we can't know the digest until we do the C compiler invocation, so we | 9808 | // we can't know the digest until we do the C compiler invocation, so we |
| 9809 | // need a tmp filename. | 9809 | // need a tmp filename. |
| ... | @@ -9822,9 +9822,10 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | ... | @@ -9822,9 +9822,10 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 9822 | args.append("-c"); | 9822 | args.append("-c"); |
| 9823 | } | 9823 | } |
| 9824 | 9824 | ||
| 9825 | Buf *out_dep_path = buf_sprintf("%s.d", buf_ptr(out_obj_path)); | 9825 | Buf *out_dep_path = g->disable_c_depfile ? nullptr : buf_sprintf("%s.d", buf_ptr(out_obj_path)); |
| 9826 | const char *out_dep_path_cstr = (out_dep_path == nullptr) ? nullptr : buf_ptr(out_dep_path); | ||
| 9826 | FileExt ext = classify_file_ext(buf_ptr(c_source_basename), buf_len(c_source_basename)); | 9827 | FileExt ext = classify_file_ext(buf_ptr(c_source_basename), buf_len(c_source_basename)); |
| 9827 | add_cc_args(g, args, buf_ptr(out_dep_path), false, ext); | 9828 | add_cc_args(g, args, out_dep_path_cstr, false, ext); |
| 9828 | 9829 | ||
| 9829 | args.append("-o"); | 9830 | args.append("-o"); |
| 9830 | args.append(buf_ptr(out_obj_path)); | 9831 | args.append(buf_ptr(out_obj_path)); |
| ... | @@ -9845,22 +9846,24 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { | ... | @@ -9845,22 +9846,24 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) { |
| 9845 | exit(1); | 9846 | exit(1); |
| 9846 | } | 9847 | } |
| 9847 | 9848 | ||
| 9848 | // add the files depended on to the cache system | 9849 | if (out_dep_path != nullptr) { |
| 9849 | if ((err = cache_add_dep_file(cache_hash, out_dep_path, true))) { | 9850 | // add the files depended on to the cache system |
| 9850 | // Don't treat the absence of the .d file as a fatal error, the | 9851 | if ((err = cache_add_dep_file(cache_hash, out_dep_path, true))) { |
| 9851 | // compiler may not produce one eg. when compiling .s files | 9852 | // Don't treat the absence of the .d file as a fatal error, the |
| 9853 | // compiler may not produce one eg. when compiling .s files | ||
| 9854 | if (err != ErrorFileNotFound) { | ||
| 9855 | fprintf(stderr, "Failed to add C source dependencies to cache: %s\n", err_str(err)); | ||
| 9856 | exit(1); | ||
| 9857 | } | ||
| 9858 | } | ||
| 9852 | if (err != ErrorFileNotFound) { | 9859 | if (err != ErrorFileNotFound) { |
| 9853 | fprintf(stderr, "Failed to add C source dependencies to cache: %s\n", err_str(err)); | 9860 | os_delete_file(out_dep_path); |
| 9854 | exit(1); | ||
| 9855 | } | 9861 | } |
| 9856 | } | ||
| 9857 | if (err != ErrorFileNotFound) { | ||
| 9858 | os_delete_file(out_dep_path); | ||
| 9859 | } | ||
| 9860 | 9862 | ||
| 9861 | if ((err = cache_final(cache_hash, &digest))) { | 9863 | if ((err = cache_final(cache_hash, &digest))) { |
| 9862 | fprintf(stderr, "Unable to finalize cache hash: %s\n", err_str(err)); | 9864 | fprintf(stderr, "Unable to finalize cache hash: %s\n", err_str(err)); |
| 9863 | exit(1); | 9865 | exit(1); |
| 9866 | } | ||
| 9864 | } | 9867 | } |
| 9865 | artifact_dir = buf_alloc(); | 9868 | artifact_dir = buf_alloc(); |
| 9866 | os_path_join(o_dir, &digest, artifact_dir); | 9869 | os_path_join(o_dir, &digest, artifact_dir); |
src/main.cpp+8| ... | @@ -458,6 +458,7 @@ static int main0(int argc, char **argv) { | ... | @@ -458,6 +458,7 @@ static int main0(int argc, char **argv) { |
| 458 | bool only_pp_or_asm = false; | 458 | bool only_pp_or_asm = false; |
| 459 | bool ensure_libc_on_non_freestanding = false; | 459 | bool ensure_libc_on_non_freestanding = false; |
| 460 | bool ensure_libcpp_on_non_freestanding = false; | 460 | bool ensure_libcpp_on_non_freestanding = false; |
| 461 | bool disable_c_depfile = false; | ||
| 461 | 462 | ||
| 462 | ZigList<const char *> llvm_argv = {0}; | 463 | ZigList<const char *> llvm_argv = {0}; |
| 463 | llvm_argv.append("zig (LLVM option parsing)"); | 464 | llvm_argv.append("zig (LLVM option parsing)"); |
| ... | @@ -741,6 +742,12 @@ static int main0(int argc, char **argv) { | ... | @@ -741,6 +742,12 @@ static int main0(int argc, char **argv) { |
| 741 | case Stage2ClangArgMCpu: | 742 | case Stage2ClangArgMCpu: |
| 742 | mcpu = it.only_arg; | 743 | mcpu = it.only_arg; |
| 743 | break; | 744 | break; |
| 745 | case Stage2ClangArgDepFile: | ||
| 746 | disable_c_depfile = true; | ||
| 747 | for (size_t i = 0; i < it.other_args_len; i += 1) { | ||
| 748 | clang_argv.append(it.other_args_ptr[i]); | ||
| 749 | } | ||
| 750 | break; | ||
| 744 | } | 751 | } |
| 745 | } | 752 | } |
| 746 | // Parse linker args | 753 | // Parse linker args |
| ... | @@ -1520,6 +1527,7 @@ static int main0(int argc, char **argv) { | ... | @@ -1520,6 +1527,7 @@ static int main0(int argc, char **argv) { |
| 1520 | g->system_linker_hack = system_linker_hack; | 1527 | g->system_linker_hack = system_linker_hack; |
| 1521 | g->function_sections = function_sections; | 1528 | g->function_sections = function_sections; |
| 1522 | g->code_model = code_model; | 1529 | g->code_model = code_model; |
| 1530 | g->disable_c_depfile = disable_c_depfile; | ||
| 1523 | 1531 | ||
| 1524 | if (override_soname) { | 1532 | if (override_soname) { |
| 1525 | g->override_soname = buf_create_from_str(override_soname); | 1533 | g->override_soname = buf_create_from_str(override_soname); |
src/stage2.h+1| ... | @@ -349,6 +349,7 @@ enum Stage2ClangArg { | ... | @@ -349,6 +349,7 @@ enum Stage2ClangArg { |
| 349 | Stage2ClangArgLinkerInputZ, | 349 | Stage2ClangArgLinkerInputZ, |
| 350 | Stage2ClangArgLibDir, | 350 | Stage2ClangArgLibDir, |
| 351 | Stage2ClangArgMCpu, | 351 | Stage2ClangArgMCpu, |
| 352 | Stage2ClangArgDepFile, | ||
| 352 | }; | 353 | }; |
| 353 | 354 | ||
| 354 | // ABI warning | 355 | // ABI warning |
tools/update_clang_options.zig+12| ... | @@ -194,6 +194,18 @@ const known_options = [_]KnownOpt{ | ... | @@ -194,6 +194,18 @@ const known_options = [_]KnownOpt{ |
| 194 | .name = "mtune", | 194 | .name = "mtune", |
| 195 | .ident = "mcpu", | 195 | .ident = "mcpu", |
| 196 | }, | 196 | }, |
| 197 | .{ | ||
| 198 | .name = "MD", | ||
| 199 | .ident = "dep_file", | ||
| 200 | }, | ||
| 201 | .{ | ||
| 202 | .name = "MV", | ||
| 203 | .ident = "dep_file", | ||
| 204 | }, | ||
| 205 | .{ | ||
| 206 | .name = "MF", | ||
| 207 | .ident = "dep_file", | ||
| 208 | }, | ||
| 197 | }; | 209 | }; |
| 198 | 210 | ||
| 199 | const blacklisted_options = [_][]const u8{}; | 211 | const blacklisted_options = [_][]const u8{}; |