authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-29 00:34:53-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-29 00:34:53-07:00
logcfbcb4116017a27a403f8be11a32f25f6c1c8671
tree2f4e7267a066e70adf4f1f17520220e5e42bfce5
parent750b00c642782127736eb378ec9583db2d680bb6

stage2: add CLI option for -fstack-report


3 files changed, 10 insertions(+), 4 deletions(-)

BRANCH_TODO+1-3
......@@ -1,10 +1,8 @@
11 * audit the CLI options for stage2
22 * audit the base cache hash
3 * On operating systems that support it, do an execve for `zig test` and `zig run` rather than child process.
4 * `-ftime-report`
5 * -fstack-report print stack size diagnostics\n"
63 * try building some software with zig cc to make sure it didn't regress
74
5 * On operating systems that support it, do an execve for `zig test` and `zig run` rather than child process.
86 * implement proper parsing of clang stderr/stdout and exposing compile errors with the Compilation API
97 * implement proper parsing of LLD stderr/stdout and exposing compile errors with the Compilation API
108 * support cross compiling stage2 with `zig build`
src/Compilation.zig+4-1
......@@ -61,6 +61,7 @@ verbose_cimport: bool,
6161verbose_llvm_cpu_features: bool,
6262disable_c_depfile: bool,
6363time_report: bool,
64stack_report: bool,
6465
6566c_source_files: []const CSourceFile,
6667clang_argv: []const []const u8,
......@@ -348,6 +349,7 @@ pub const InitOptions = struct {
348349 single_threaded: bool = false,
349350 is_native_os: bool,
350351 time_report: bool = false,
352 stack_report: bool = false,
351353 link_eh_frame_hdr: bool = false,
352354 linker_script: ?[]const u8 = null,
353355 version_script: ?[]const u8 = null,
......@@ -821,6 +823,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
821823 .owned_link_dir = owned_link_dir,
822824 .color = options.color,
823825 .time_report = options.time_report,
826 .stack_report = options.stack_report,
824827 .test_filter = options.test_filter,
825828 .test_name_prefix = options.test_name_prefix,
826829 .test_evented_io = options.test_evented_io,
......@@ -2670,7 +2673,7 @@ fn updateStage1Module(comp: *Compilation) !void {
26702673 .function_sections = comp.bin_file.options.function_sections,
26712674 .enable_stack_probing = comp.bin_file.options.stack_check,
26722675 .enable_time_report = comp.time_report,
2673 .enable_stack_report = false,
2676 .enable_stack_report = comp.stack_report,
26742677 .test_is_evented = comp.test_evented_io,
26752678 .verbose_tokenize = comp.verbose_tokenize,
26762679 .verbose_ast = comp.verbose_ast,
src/main.zig+5
......@@ -284,6 +284,7 @@ const usage_build_generic =
284284 \\
285285 \\Debug Options (Zig Compiler Development):
286286 \\ -ftime-report Print timing diagnostics
287 \\ -fstack-report Print stack size diagnostics
287288 \\ --verbose-link Display linker invocations
288289 \\ --verbose-cc Display C compiler invocations
289290 \\ --verbose-tokenize Enable compiler debug output for tokenization
......@@ -390,6 +391,7 @@ fn buildOutputType(
390391 var verbose_cimport = false;
391392 var verbose_llvm_cpu_features = false;
392393 var time_report = false;
394 var stack_report = false;
393395 var show_builtin = false;
394396 var emit_bin: Emit = .yes_default_path;
395397 var emit_asm: Emit = .no;
......@@ -728,6 +730,8 @@ fn buildOutputType(
728730 watch = true;
729731 } else if (mem.eql(u8, arg, "-ftime-report")) {
730732 time_report = true;
733 } else if (mem.eql(u8, arg, "-fstack-report")) {
734 stack_report = true;
731735 } else if (mem.eql(u8, arg, "-fPIC")) {
732736 want_pic = true;
733737 } else if (mem.eql(u8, arg, "-fno-PIC")) {
......@@ -1568,6 +1572,7 @@ fn buildOutputType(
15681572 .machine_code_model = machine_code_model,
15691573 .color = color,
15701574 .time_report = time_report,
1575 .stack_report = stack_report,
15711576 .is_test = arg_mode == .zig_test,
15721577 .each_lib_rpath = each_lib_rpath,
15731578 .test_evented_io = test_evented_io,