authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-14 11:00:37-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-14 11:01:01-04:00
log27253f09b6586ca602ebc64e21e48f5afa3464d9
treea418075c7c76cb05d39cfe9d95cd37fc3ec1e5a0
parent63a970a548c1973a216d9cf5109138451a0d214a
signaturelock-open Commit is signed but in an unrecognized format.

organize how the single threaded option is passed around


3 files changed, 31 insertions(+), 11 deletions(-)

src/all_types.hpp+1
......@@ -1856,6 +1856,7 @@ struct CodeGen {
18561856 bool strip_debug_symbols;
18571857 bool is_test_build;
18581858 bool is_single_threaded;
1859 bool want_single_threaded;
18591860 bool linker_rdynamic;
18601861 bool each_lib_rpath;
18611862 bool is_dummy_so;
src/codegen.cpp+25-2
......@@ -7337,9 +7337,26 @@ static bool detect_pic(CodeGen *g) {
73377337 zig_unreachable();
73387338}
73397339
7340static 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
7349static 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
73407355Buf *codegen_generate_builtin_source(CodeGen *g) {
73417356 g->have_dynamic_link = detect_dynamic_link(g);
73427357 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);
73437360
73447361 Buf *contents = buf_alloc();
73457362
......@@ -7844,6 +7861,12 @@ static void init(CodeGen *g) {
78447861
78457862 g->have_dynamic_link = detect_dynamic_link(g);
78467863 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 }
78477870
78487871 if (g->is_test_build) {
78497872 g->subsystem = TargetSubsystemConsole;
......@@ -7953,8 +7976,6 @@ static void init(CodeGen *g) {
79537976 }
79547977 }
79557978
7956 g->have_err_ret_tracing = !target_is_wasm(g->zig_target) && g->build_mode != BuildModeFastRelease && g->build_mode != BuildModeSmallRelease;
7957
79587979 define_builtin_fns(g);
79597980 Error err;
79607981 if ((err = define_builtin_compile_vars(g))) {
......@@ -9268,6 +9289,8 @@ void codegen_build_and_link(CodeGen *g) {
92689289
92699290 g->have_dynamic_link = detect_dynamic_link(g);
92709291 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);
92719294 detect_libc(g);
92729295 detect_dynamic_linker(g);
92739296
src/main.cpp+5-9
......@@ -450,7 +450,7 @@ int main(int argc, char **argv) {
450450 int runtime_args_start = -1;
451451 bool system_linker_hack = false;
452452 TargetSubsystem subsystem = TargetSubsystemAuto;
453 bool is_single_threaded = false;
453 bool want_single_threaded = false;
454454 bool disable_gen_h = false;
455455 Buf *override_std_dir = nullptr;
456456 Buf *main_pkg_path = nullptr;
......@@ -590,7 +590,7 @@ int main(int argc, char **argv) {
590590 CodeGen *g = codegen_create(main_pkg_path, fmt_runner_path, &target, OutTypeExe,
591591 BuildModeDebug, get_zig_lib_dir(), nullptr, nullptr, cache_dir_buf);
592592 g->valgrind_support = valgrind_support;
593 g->is_single_threaded = true;
593 g->want_single_threaded = true;
594594 codegen_set_out_name(g, buf_create_from_str("fmt"));
595595 g->enable_cache = true;
596596
......@@ -671,7 +671,7 @@ int main(int argc, char **argv) {
671671 } else if (strcmp(arg, "--system-linker-hack") == 0) {
672672 system_linker_hack = true;
673673 } else if (strcmp(arg, "--single-threaded") == 0) {
674 is_single_threaded = true;
674 want_single_threaded = true;
675675 } else if (strcmp(arg, "--disable-gen-h") == 0) {
676676 disable_gen_h = true;
677677 } else if (strcmp(arg, "--test-cmd-bin") == 0) {
......@@ -921,10 +921,6 @@ int main(int argc, char **argv) {
921921 }
922922 }
923923
924 if (target_is_single_threaded(&target)) {
925 is_single_threaded = true;
926 }
927
928924 if (output_dir != nullptr && enable_cache == CacheOptOn) {
929925 fprintf(stderr, "`--output-dir` is incompatible with --cache on.\n");
930926 return print_error_usage(arg0);
......@@ -966,7 +962,7 @@ int main(int argc, char **argv) {
966962 out_type, build_mode, get_zig_lib_dir(), override_std_dir, nullptr, nullptr);
967963 g->valgrind_support = valgrind_support;
968964 g->want_pic = want_pic;
969 g->is_single_threaded = is_single_threaded;
965 g->want_single_threaded = want_single_threaded;
970966 Buf *builtin_source = codegen_generate_builtin_source(g);
971967 if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) {
972968 fprintf(stderr, "unable to write to stdout: %s\n", strerror(ferror(stdout)));
......@@ -1064,7 +1060,7 @@ int main(int argc, char **argv) {
10641060 codegen_set_out_name(g, buf_out_name);
10651061 codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);
10661062 codegen_set_is_test(g, cmd == CmdTest);
1067 g->is_single_threaded = is_single_threaded;
1063 g->want_single_threaded = want_single_threaded;
10681064 codegen_set_linker_script(g, linker_script);
10691065 if (each_lib_rpath)
10701066 codegen_set_each_lib_rpath(g, each_lib_rpath);