| author | |
| committer | |
| log | 27253f09b6586ca602ebc64e21e48f5afa3464d9 |
| tree | a418075c7c76cb05d39cfe9d95cd37fc3ec1e5a0 |
| parent | 63a970a548c1973a216d9cf5109138451a0d214a |
| signature |
3 files changed, 31 insertions(+), 11 deletions(-)
src/all_types.hpp+1| ... | ... | @@ -1856,6 +1856,7 @@ struct CodeGen { |
| 1856 | 1856 | bool strip_debug_symbols; |
| 1857 | 1857 | bool is_test_build; |
| 1858 | 1858 | bool is_single_threaded; |
| 1859 | bool want_single_threaded; | |
| 1859 | 1860 | bool linker_rdynamic; |
| 1860 | 1861 | bool each_lib_rpath; |
| 1861 | 1862 | bool is_dummy_so; |
src/codegen.cpp+25-2| ... | ... | @@ -7337,9 +7337,26 @@ static bool detect_pic(CodeGen *g) { |
| 7337 | 7337 | zig_unreachable(); |
| 7338 | 7338 | } |
| 7339 | 7339 | |
| 7340 | static bool detect_single_threaded(CodeGen *g) { | |
| 7341 | if (g->want_single_threaded) | |
| 7342 | return true; | |
| 7343 | if (target_is_single_threaded(g->zig_target)) { | |
| 7344 | return true; | |
| 7345 | } | |
| 7346 | return false; | |
| 7347 | } | |
| 7348 | ||
| 7349 | static bool detect_err_ret_tracing(CodeGen *g) { | |
| 7350 | return !target_is_wasm(g->zig_target) && | |
| 7351 | g->build_mode != BuildModeFastRelease && | |
| 7352 | g->build_mode != BuildModeSmallRelease; | |
| 7353 | } | |
| 7354 | ||
| 7340 | 7355 | Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 7341 | 7356 | g->have_dynamic_link = detect_dynamic_link(g); |
| 7342 | 7357 | g->have_pic = detect_pic(g); |
| 7358 | g->is_single_threaded = detect_single_threaded(g); | |
| 7359 | g->have_err_ret_tracing = detect_err_ret_tracing(g); | |
| 7343 | 7360 | |
| 7344 | 7361 | Buf *contents = buf_alloc(); |
| 7345 | 7362 | |
| ... | ... | @@ -7844,6 +7861,12 @@ static void init(CodeGen *g) { |
| 7844 | 7861 | |
| 7845 | 7862 | g->have_dynamic_link = detect_dynamic_link(g); |
| 7846 | 7863 | g->have_pic = detect_pic(g); |
| 7864 | g->is_single_threaded = detect_single_threaded(g); | |
| 7865 | g->have_err_ret_tracing = detect_err_ret_tracing(g); | |
| 7866 | ||
| 7867 | if (target_is_single_threaded(g->zig_target)) { | |
| 7868 | g->is_single_threaded = true; | |
| 7869 | } | |
| 7847 | 7870 | |
| 7848 | 7871 | if (g->is_test_build) { |
| 7849 | 7872 | g->subsystem = TargetSubsystemConsole; |
| ... | ... | @@ -7953,8 +7976,6 @@ static void init(CodeGen *g) { |
| 7953 | 7976 | } |
| 7954 | 7977 | } |
| 7955 | 7978 | |
| 7956 | g->have_err_ret_tracing = !target_is_wasm(g->zig_target) && g->build_mode != BuildModeFastRelease && g->build_mode != BuildModeSmallRelease; | |
| 7957 | ||
| 7958 | 7979 | define_builtin_fns(g); |
| 7959 | 7980 | Error err; |
| 7960 | 7981 | if ((err = define_builtin_compile_vars(g))) { |
| ... | ... | @@ -9268,6 +9289,8 @@ void codegen_build_and_link(CodeGen *g) { |
| 9268 | 9289 | |
| 9269 | 9290 | g->have_dynamic_link = detect_dynamic_link(g); |
| 9270 | 9291 | g->have_pic = detect_pic(g); |
| 9292 | g->is_single_threaded = detect_single_threaded(g); | |
| 9293 | g->have_err_ret_tracing = detect_err_ret_tracing(g); | |
| 9271 | 9294 | detect_libc(g); |
| 9272 | 9295 | detect_dynamic_linker(g); |
| 9273 | 9296 |
src/main.cpp+5-9| ... | ... | @@ -450,7 +450,7 @@ int main(int argc, char **argv) { |
| 450 | 450 | int runtime_args_start = -1; |
| 451 | 451 | bool system_linker_hack = false; |
| 452 | 452 | TargetSubsystem subsystem = TargetSubsystemAuto; |
| 453 | bool is_single_threaded = false; | |
| 453 | bool want_single_threaded = false; | |
| 454 | 454 | bool disable_gen_h = false; |
| 455 | 455 | Buf *override_std_dir = nullptr; |
| 456 | 456 | Buf *main_pkg_path = nullptr; |
| ... | ... | @@ -590,7 +590,7 @@ int main(int argc, char **argv) { |
| 590 | 590 | CodeGen *g = codegen_create(main_pkg_path, fmt_runner_path, &target, OutTypeExe, |
| 591 | 591 | BuildModeDebug, get_zig_lib_dir(), nullptr, nullptr, cache_dir_buf); |
| 592 | 592 | g->valgrind_support = valgrind_support; |
| 593 | g->is_single_threaded = true; | |
| 593 | g->want_single_threaded = true; | |
| 594 | 594 | codegen_set_out_name(g, buf_create_from_str("fmt")); |
| 595 | 595 | g->enable_cache = true; |
| 596 | 596 | |
| ... | ... | @@ -671,7 +671,7 @@ int main(int argc, char **argv) { |
| 671 | 671 | } else if (strcmp(arg, "--system-linker-hack") == 0) { |
| 672 | 672 | system_linker_hack = true; |
| 673 | 673 | } else if (strcmp(arg, "--single-threaded") == 0) { |
| 674 | is_single_threaded = true; | |
| 674 | want_single_threaded = true; | |
| 675 | 675 | } else if (strcmp(arg, "--disable-gen-h") == 0) { |
| 676 | 676 | disable_gen_h = true; |
| 677 | 677 | } else if (strcmp(arg, "--test-cmd-bin") == 0) { |
| ... | ... | @@ -921,10 +921,6 @@ int main(int argc, char **argv) { |
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | if (target_is_single_threaded(&target)) { | |
| 925 | is_single_threaded = true; | |
| 926 | } | |
| 927 | ||
| 928 | 924 | if (output_dir != nullptr && enable_cache == CacheOptOn) { |
| 929 | 925 | fprintf(stderr, "`--output-dir` is incompatible with --cache on.\n"); |
| 930 | 926 | return print_error_usage(arg0); |
| ... | ... | @@ -966,7 +962,7 @@ int main(int argc, char **argv) { |
| 966 | 962 | out_type, build_mode, get_zig_lib_dir(), override_std_dir, nullptr, nullptr); |
| 967 | 963 | g->valgrind_support = valgrind_support; |
| 968 | 964 | g->want_pic = want_pic; |
| 969 | g->is_single_threaded = is_single_threaded; | |
| 965 | g->want_single_threaded = want_single_threaded; | |
| 970 | 966 | Buf *builtin_source = codegen_generate_builtin_source(g); |
| 971 | 967 | if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) { |
| 972 | 968 | fprintf(stderr, "unable to write to stdout: %s\n", strerror(ferror(stdout))); |
| ... | ... | @@ -1064,7 +1060,7 @@ int main(int argc, char **argv) { |
| 1064 | 1060 | codegen_set_out_name(g, buf_out_name); |
| 1065 | 1061 | codegen_set_lib_version(g, ver_major, ver_minor, ver_patch); |
| 1066 | 1062 | codegen_set_is_test(g, cmd == CmdTest); |
| 1067 | g->is_single_threaded = is_single_threaded; | |
| 1063 | g->want_single_threaded = want_single_threaded; | |
| 1068 | 1064 | codegen_set_linker_script(g, linker_script); |
| 1069 | 1065 | if (each_lib_rpath) |
| 1070 | 1066 | codegen_set_each_lib_rpath(g, each_lib_rpath); |