mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
organize how the single threaded option is passed around
This commit is contained in:
parent
63a970a548
commit
27253f09b6
@ -1856,6 +1856,7 @@ struct CodeGen {
|
|||||||
bool strip_debug_symbols;
|
bool strip_debug_symbols;
|
||||||
bool is_test_build;
|
bool is_test_build;
|
||||||
bool is_single_threaded;
|
bool is_single_threaded;
|
||||||
|
bool want_single_threaded;
|
||||||
bool linker_rdynamic;
|
bool linker_rdynamic;
|
||||||
bool each_lib_rpath;
|
bool each_lib_rpath;
|
||||||
bool is_dummy_so;
|
bool is_dummy_so;
|
||||||
|
|||||||
@ -7337,9 +7337,26 @@ static bool detect_pic(CodeGen *g) {
|
|||||||
zig_unreachable();
|
zig_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool detect_single_threaded(CodeGen *g) {
|
||||||
|
if (g->want_single_threaded)
|
||||||
|
return true;
|
||||||
|
if (target_is_single_threaded(g->zig_target)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool detect_err_ret_tracing(CodeGen *g) {
|
||||||
|
return !target_is_wasm(g->zig_target) &&
|
||||||
|
g->build_mode != BuildModeFastRelease &&
|
||||||
|
g->build_mode != BuildModeSmallRelease;
|
||||||
|
}
|
||||||
|
|
||||||
Buf *codegen_generate_builtin_source(CodeGen *g) {
|
Buf *codegen_generate_builtin_source(CodeGen *g) {
|
||||||
g->have_dynamic_link = detect_dynamic_link(g);
|
g->have_dynamic_link = detect_dynamic_link(g);
|
||||||
g->have_pic = detect_pic(g);
|
g->have_pic = detect_pic(g);
|
||||||
|
g->is_single_threaded = detect_single_threaded(g);
|
||||||
|
g->have_err_ret_tracing = detect_err_ret_tracing(g);
|
||||||
|
|
||||||
Buf *contents = buf_alloc();
|
Buf *contents = buf_alloc();
|
||||||
|
|
||||||
@ -7844,6 +7861,12 @@ static void init(CodeGen *g) {
|
|||||||
|
|
||||||
g->have_dynamic_link = detect_dynamic_link(g);
|
g->have_dynamic_link = detect_dynamic_link(g);
|
||||||
g->have_pic = detect_pic(g);
|
g->have_pic = detect_pic(g);
|
||||||
|
g->is_single_threaded = detect_single_threaded(g);
|
||||||
|
g->have_err_ret_tracing = detect_err_ret_tracing(g);
|
||||||
|
|
||||||
|
if (target_is_single_threaded(g->zig_target)) {
|
||||||
|
g->is_single_threaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (g->is_test_build) {
|
if (g->is_test_build) {
|
||||||
g->subsystem = TargetSubsystemConsole;
|
g->subsystem = TargetSubsystemConsole;
|
||||||
@ -7953,8 +7976,6 @@ static void init(CodeGen *g) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g->have_err_ret_tracing = !target_is_wasm(g->zig_target) && g->build_mode != BuildModeFastRelease && g->build_mode != BuildModeSmallRelease;
|
|
||||||
|
|
||||||
define_builtin_fns(g);
|
define_builtin_fns(g);
|
||||||
Error err;
|
Error err;
|
||||||
if ((err = define_builtin_compile_vars(g))) {
|
if ((err = define_builtin_compile_vars(g))) {
|
||||||
@ -9268,6 +9289,8 @@ void codegen_build_and_link(CodeGen *g) {
|
|||||||
|
|
||||||
g->have_dynamic_link = detect_dynamic_link(g);
|
g->have_dynamic_link = detect_dynamic_link(g);
|
||||||
g->have_pic = detect_pic(g);
|
g->have_pic = detect_pic(g);
|
||||||
|
g->is_single_threaded = detect_single_threaded(g);
|
||||||
|
g->have_err_ret_tracing = detect_err_ret_tracing(g);
|
||||||
detect_libc(g);
|
detect_libc(g);
|
||||||
detect_dynamic_linker(g);
|
detect_dynamic_linker(g);
|
||||||
|
|
||||||
|
|||||||
14
src/main.cpp
14
src/main.cpp
@ -450,7 +450,7 @@ int main(int argc, char **argv) {
|
|||||||
int runtime_args_start = -1;
|
int runtime_args_start = -1;
|
||||||
bool system_linker_hack = false;
|
bool system_linker_hack = false;
|
||||||
TargetSubsystem subsystem = TargetSubsystemAuto;
|
TargetSubsystem subsystem = TargetSubsystemAuto;
|
||||||
bool is_single_threaded = false;
|
bool want_single_threaded = false;
|
||||||
bool disable_gen_h = false;
|
bool disable_gen_h = false;
|
||||||
Buf *override_std_dir = nullptr;
|
Buf *override_std_dir = nullptr;
|
||||||
Buf *main_pkg_path = nullptr;
|
Buf *main_pkg_path = nullptr;
|
||||||
@ -590,7 +590,7 @@ int main(int argc, char **argv) {
|
|||||||
CodeGen *g = codegen_create(main_pkg_path, fmt_runner_path, &target, OutTypeExe,
|
CodeGen *g = codegen_create(main_pkg_path, fmt_runner_path, &target, OutTypeExe,
|
||||||
BuildModeDebug, get_zig_lib_dir(), nullptr, nullptr, cache_dir_buf);
|
BuildModeDebug, get_zig_lib_dir(), nullptr, nullptr, cache_dir_buf);
|
||||||
g->valgrind_support = valgrind_support;
|
g->valgrind_support = valgrind_support;
|
||||||
g->is_single_threaded = true;
|
g->want_single_threaded = true;
|
||||||
codegen_set_out_name(g, buf_create_from_str("fmt"));
|
codegen_set_out_name(g, buf_create_from_str("fmt"));
|
||||||
g->enable_cache = true;
|
g->enable_cache = true;
|
||||||
|
|
||||||
@ -671,7 +671,7 @@ int main(int argc, char **argv) {
|
|||||||
} else if (strcmp(arg, "--system-linker-hack") == 0) {
|
} else if (strcmp(arg, "--system-linker-hack") == 0) {
|
||||||
system_linker_hack = true;
|
system_linker_hack = true;
|
||||||
} else if (strcmp(arg, "--single-threaded") == 0) {
|
} else if (strcmp(arg, "--single-threaded") == 0) {
|
||||||
is_single_threaded = true;
|
want_single_threaded = true;
|
||||||
} else if (strcmp(arg, "--disable-gen-h") == 0) {
|
} else if (strcmp(arg, "--disable-gen-h") == 0) {
|
||||||
disable_gen_h = true;
|
disable_gen_h = true;
|
||||||
} else if (strcmp(arg, "--test-cmd-bin") == 0) {
|
} else if (strcmp(arg, "--test-cmd-bin") == 0) {
|
||||||
@ -921,10 +921,6 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target_is_single_threaded(&target)) {
|
|
||||||
is_single_threaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (output_dir != nullptr && enable_cache == CacheOptOn) {
|
if (output_dir != nullptr && enable_cache == CacheOptOn) {
|
||||||
fprintf(stderr, "`--output-dir` is incompatible with --cache on.\n");
|
fprintf(stderr, "`--output-dir` is incompatible with --cache on.\n");
|
||||||
return print_error_usage(arg0);
|
return print_error_usage(arg0);
|
||||||
@ -966,7 +962,7 @@ int main(int argc, char **argv) {
|
|||||||
out_type, build_mode, get_zig_lib_dir(), override_std_dir, nullptr, nullptr);
|
out_type, build_mode, get_zig_lib_dir(), override_std_dir, nullptr, nullptr);
|
||||||
g->valgrind_support = valgrind_support;
|
g->valgrind_support = valgrind_support;
|
||||||
g->want_pic = want_pic;
|
g->want_pic = want_pic;
|
||||||
g->is_single_threaded = is_single_threaded;
|
g->want_single_threaded = want_single_threaded;
|
||||||
Buf *builtin_source = codegen_generate_builtin_source(g);
|
Buf *builtin_source = codegen_generate_builtin_source(g);
|
||||||
if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) {
|
if (fwrite(buf_ptr(builtin_source), 1, buf_len(builtin_source), stdout) != buf_len(builtin_source)) {
|
||||||
fprintf(stderr, "unable to write to stdout: %s\n", strerror(ferror(stdout)));
|
fprintf(stderr, "unable to write to stdout: %s\n", strerror(ferror(stdout)));
|
||||||
@ -1064,7 +1060,7 @@ int main(int argc, char **argv) {
|
|||||||
codegen_set_out_name(g, buf_out_name);
|
codegen_set_out_name(g, buf_out_name);
|
||||||
codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);
|
codegen_set_lib_version(g, ver_major, ver_minor, ver_patch);
|
||||||
codegen_set_is_test(g, cmd == CmdTest);
|
codegen_set_is_test(g, cmd == CmdTest);
|
||||||
g->is_single_threaded = is_single_threaded;
|
g->want_single_threaded = want_single_threaded;
|
||||||
codegen_set_linker_script(g, linker_script);
|
codegen_set_linker_script(g, linker_script);
|
||||||
if (each_lib_rpath)
|
if (each_lib_rpath)
|
||||||
codegen_set_each_lib_rpath(g, each_lib_rpath);
|
codegen_set_each_lib_rpath(g, each_lib_rpath);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user