rework the progress module and integrate with stage1
This commit is contained in:
@@ -7610,7 +7610,7 @@ static void zig_llvm_emit_output(CodeGen *g) {
|
||||
if (g->bundle_compiler_rt && (g->out_type == OutTypeObj ||
|
||||
(g->out_type == OutTypeLib && !g->is_dynamic)))
|
||||
{
|
||||
zig_link_add_compiler_rt(g);
|
||||
zig_link_add_compiler_rt(g, g->progress_node);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -9453,7 +9453,7 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose
|
||||
}
|
||||
|
||||
// returns true if it was a cache miss
|
||||
static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
||||
static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file, Stage2ProgressNode *parent_prog_node) {
|
||||
Error err;
|
||||
|
||||
Buf *artifact_dir;
|
||||
@@ -9464,6 +9464,10 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
||||
Buf *c_source_file = buf_create_from_str(c_file->source_path);
|
||||
Buf *c_source_basename = buf_alloc();
|
||||
os_path_split(c_source_file, nullptr, c_source_basename);
|
||||
|
||||
Stage2ProgressNode *child_prog_node = stage2_progress_start(parent_prog_node, buf_ptr(c_source_basename),
|
||||
buf_len(c_source_basename), 0);
|
||||
|
||||
Buf *final_o_basename = buf_alloc();
|
||||
os_path_extname(c_source_basename, final_o_basename, nullptr);
|
||||
buf_append_str(final_o_basename, target_o_file_ext(g->zig_target));
|
||||
@@ -9580,6 +9584,8 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
||||
|
||||
g->link_objects.append(o_final_path);
|
||||
g->caches_to_release.append(cache_hash);
|
||||
|
||||
stage2_progress_end(child_prog_node);
|
||||
}
|
||||
|
||||
// returns true if we had any cache misses
|
||||
@@ -9596,11 +9602,16 @@ static void gen_c_objects(CodeGen *g) {
|
||||
}
|
||||
|
||||
codegen_add_time_event(g, "Compile C Code");
|
||||
const char *c_prog_name = "compiling C objects";
|
||||
Stage2ProgressNode *c_prog_node = stage2_progress_start(g->progress_node, c_prog_name, strlen(c_prog_name),
|
||||
g->c_source_files.length);
|
||||
|
||||
for (size_t c_file_i = 0; c_file_i < g->c_source_files.length; c_file_i += 1) {
|
||||
CFile *c_file = g->c_source_files.at(c_file_i);
|
||||
gen_c_object(g, self_exe_path, c_file);
|
||||
gen_c_object(g, self_exe_path, c_file, c_prog_node);
|
||||
}
|
||||
|
||||
stage2_progress_end(c_prog_node);
|
||||
}
|
||||
|
||||
void codegen_add_object(CodeGen *g, Buf *object_path) {
|
||||
@@ -10320,6 +10331,10 @@ void codegen_build_and_link(CodeGen *g) {
|
||||
init(g);
|
||||
|
||||
codegen_add_time_event(g, "Semantic Analysis");
|
||||
const char *progress_name = "Semantic Analysis";
|
||||
Stage2ProgressNode *child_progress_node = stage2_progress_start(g->progress_node,
|
||||
progress_name, strlen(progress_name), 0);
|
||||
(void)child_progress_node;
|
||||
|
||||
gen_root_source(g);
|
||||
|
||||
@@ -10343,13 +10358,31 @@ void codegen_build_and_link(CodeGen *g) {
|
||||
|
||||
if (need_llvm_module(g)) {
|
||||
codegen_add_time_event(g, "Code Generation");
|
||||
{
|
||||
const char *progress_name = "Code Generation";
|
||||
Stage2ProgressNode *child_progress_node = stage2_progress_start(g->progress_node,
|
||||
progress_name, strlen(progress_name), 0);
|
||||
(void)child_progress_node;
|
||||
}
|
||||
|
||||
do_code_gen(g);
|
||||
codegen_add_time_event(g, "LLVM Emit Output");
|
||||
{
|
||||
const char *progress_name = "LLVM Emit Output";
|
||||
Stage2ProgressNode *child_progress_node = stage2_progress_start(g->progress_node,
|
||||
progress_name, strlen(progress_name), 0);
|
||||
(void)child_progress_node;
|
||||
}
|
||||
zig_llvm_emit_output(g);
|
||||
|
||||
if (!g->disable_gen_h && (g->out_type == OutTypeObj || g->out_type == OutTypeLib)) {
|
||||
codegen_add_time_event(g, "Generate .h");
|
||||
{
|
||||
const char *progress_name = "Generate .h";
|
||||
Stage2ProgressNode *child_progress_node = stage2_progress_start(g->progress_node,
|
||||
progress_name, strlen(progress_name), 0);
|
||||
(void)child_progress_node;
|
||||
}
|
||||
gen_h_file(g);
|
||||
}
|
||||
}
|
||||
@@ -10446,10 +10479,15 @@ ZigPackage *codegen_create_package(CodeGen *g, const char *root_src_dir, const c
|
||||
}
|
||||
|
||||
CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType out_type,
|
||||
ZigLibCInstallation *libc)
|
||||
ZigLibCInstallation *libc, const char *name, Stage2ProgressNode *child_progress_node)
|
||||
{
|
||||
if (!child_progress_node) {
|
||||
child_progress_node = stage2_progress_start(parent_gen->progress_node, name, strlen(name), 0);
|
||||
}
|
||||
|
||||
CodeGen *child_gen = codegen_create(nullptr, root_src_path, parent_gen->zig_target, out_type,
|
||||
parent_gen->build_mode, parent_gen->zig_lib_dir, libc, get_stage1_cache_path(), false);
|
||||
parent_gen->build_mode, parent_gen->zig_lib_dir, libc, get_stage1_cache_path(), false, child_progress_node);
|
||||
child_gen->root_out_name = buf_create_from_str(name);
|
||||
child_gen->disable_gen_h = true;
|
||||
child_gen->want_stack_check = WantStackCheckDisabled;
|
||||
child_gen->verbose_tokenize = parent_gen->verbose_tokenize;
|
||||
@@ -10478,9 +10516,10 @@ CodeGen *create_child_codegen(CodeGen *parent_gen, Buf *root_src_path, OutType o
|
||||
|
||||
CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget *target,
|
||||
OutType out_type, BuildMode build_mode, Buf *override_lib_dir,
|
||||
ZigLibCInstallation *libc, Buf *cache_dir, bool is_test_build)
|
||||
ZigLibCInstallation *libc, Buf *cache_dir, bool is_test_build, Stage2ProgressNode *progress_node)
|
||||
{
|
||||
CodeGen *g = allocate<CodeGen>(1);
|
||||
g->progress_node = progress_node;
|
||||
|
||||
codegen_add_time_event(g, "Initialize");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user