authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-03-16 01:32:43-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-17 01:57:14-04:00
logcfcd6698cd9385938df27a2052c2309229171e4f
tree3ac0ce351109462a9f0e96c5f06fe94737be48a8
parent4ec299007a6a183edddfcb0505a9c1501da7ad0c

main: add debug option to dump unoptimized llvm ir


12 files changed, 75 insertions(+), 19 deletions(-)

lib/build_runner.zig+7-2
...@@ -204,7 +204,11 @@ pub fn main() !void {...@@ -204,7 +204,11 @@ pub fn main() !void {
204 } else if (mem.eql(u8, arg, "--verbose-air")) {204 } else if (mem.eql(u8, arg, "--verbose-air")) {
205 builder.verbose_air = true;205 builder.verbose_air = true;
206 } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {206 } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
207 builder.verbose_llvm_ir = true;207 builder.verbose_llvm_ir = "-";
208 } else if (mem.startsWith(u8, arg, "--verbose-llvm-ir=")) {
209 builder.verbose_llvm_ir = arg["--verbose-llvm-ir=".len..];
210 } else if (mem.eql(u8, arg, "--verbose-llvm-bc=")) {
211 builder.verbose_llvm_bc = arg["--verbose-llvm-bc=".len..];
208 } else if (mem.eql(u8, arg, "--verbose-cimport")) {212 } else if (mem.eql(u8, arg, "--verbose-cimport")) {
209 builder.verbose_cimport = true;213 builder.verbose_cimport = true;
210 } else if (mem.eql(u8, arg, "--verbose-cc")) {214 } else if (mem.eql(u8, arg, "--verbose-cc")) {
...@@ -990,7 +994,8 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi...@@ -990,7 +994,8 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi
990 \\ --debug-pkg-config Fail if unknown pkg-config flags encountered994 \\ --debug-pkg-config Fail if unknown pkg-config flags encountered
991 \\ --verbose-link Enable compiler debug output for linking995 \\ --verbose-link Enable compiler debug output for linking
992 \\ --verbose-air Enable compiler debug output for Zig AIR996 \\ --verbose-air Enable compiler debug output for Zig AIR
993 \\ --verbose-llvm-ir Enable compiler debug output for LLVM IR997 \\ --verbose-llvm-ir[=file] Enable compiler debug output for LLVM IR
998 \\ --verbose-llvm-bc=[file] Enable compiler debug output for LLVM BC
994 \\ --verbose-cimport Enable compiler debug output for C imports999 \\ --verbose-cimport Enable compiler debug output for C imports
995 \\ --verbose-cc Enable compiler debug output for C compilation1000 \\ --verbose-cc Enable compiler debug output for C compilation
996 \\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features1001 \\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features
lib/std/Build.zig+5-2
...@@ -54,7 +54,8 @@ verbose: bool,...@@ -54,7 +54,8 @@ verbose: bool,
54verbose_link: bool,54verbose_link: bool,
55verbose_cc: bool,55verbose_cc: bool,
56verbose_air: bool,56verbose_air: bool,
57verbose_llvm_ir: bool,57verbose_llvm_ir: ?[]const u8,
58verbose_llvm_bc: ?[]const u8,
58verbose_cimport: bool,59verbose_cimport: bool,
59verbose_llvm_cpu_features: bool,60verbose_llvm_cpu_features: bool,
60reference_trace: ?u32 = null,61reference_trace: ?u32 = null,
...@@ -204,7 +205,8 @@ pub fn create(...@@ -204,7 +205,8 @@ pub fn create(
204 .verbose_link = false,205 .verbose_link = false,
205 .verbose_cc = false,206 .verbose_cc = false,
206 .verbose_air = false,207 .verbose_air = false,
207 .verbose_llvm_ir = false,208 .verbose_llvm_ir = null,
209 .verbose_llvm_bc = null,
208 .verbose_cimport = false,210 .verbose_cimport = false,
209 .verbose_llvm_cpu_features = false,211 .verbose_llvm_cpu_features = false,
210 .invalid_user_input = false,212 .invalid_user_input = false,
...@@ -292,6 +294,7 @@ fn createChildOnly(parent: *Build, dep_name: []const u8, build_root: Cache.Direc...@@ -292,6 +294,7 @@ fn createChildOnly(parent: *Build, dep_name: []const u8, build_root: Cache.Direc
292 .verbose_cc = parent.verbose_cc,294 .verbose_cc = parent.verbose_cc,
293 .verbose_air = parent.verbose_air,295 .verbose_air = parent.verbose_air,
294 .verbose_llvm_ir = parent.verbose_llvm_ir,296 .verbose_llvm_ir = parent.verbose_llvm_ir,
297 .verbose_llvm_bc = parent.verbose_llvm_bc,
295 .verbose_cimport = parent.verbose_cimport,298 .verbose_cimport = parent.verbose_cimport,
296 .verbose_llvm_cpu_features = parent.verbose_llvm_cpu_features,299 .verbose_llvm_cpu_features = parent.verbose_llvm_cpu_features,
297 .reference_trace = parent.reference_trace,300 .reference_trace = parent.reference_trace,
lib/std/Build/CompileStep.zig+2-1
...@@ -1438,7 +1438,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -1438,7 +1438,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
14381438
1439 if (b.verbose_cimport) try zig_args.append("--verbose-cimport");1439 if (b.verbose_cimport) try zig_args.append("--verbose-cimport");
1440 if (b.verbose_air) try zig_args.append("--verbose-air");1440 if (b.verbose_air) try zig_args.append("--verbose-air");
1441 if (b.verbose_llvm_ir) try zig_args.append("--verbose-llvm-ir");1441 if (b.verbose_llvm_ir) |path| try zig_args.append(b.fmt("--verbose-llvm-ir={s}", .{path}));
1442 if (b.verbose_llvm_bc) |path| try zig_args.append(b.fmt("--verbose-llvm-bc={s}", .{path}));
1442 if (b.verbose_link or self.verbose_link) try zig_args.append("--verbose-link");1443 if (b.verbose_link or self.verbose_link) try zig_args.append("--verbose-link");
1443 if (b.verbose_cc or self.verbose_cc) try zig_args.append("--verbose-cc");1444 if (b.verbose_cc or self.verbose_cc) try zig_args.append("--verbose-cc");
1444 if (b.verbose_llvm_cpu_features) try zig_args.append("--verbose-llvm-cpu-features");1445 if (b.verbose_llvm_cpu_features) try zig_args.append("--verbose-llvm-cpu-features");
src/Compilation.zig+7-2
...@@ -86,7 +86,8 @@ clang_preprocessor_mode: ClangPreprocessorMode,...@@ -86,7 +86,8 @@ clang_preprocessor_mode: ClangPreprocessorMode,
86/// Whether to print clang argvs to stdout.86/// Whether to print clang argvs to stdout.
87verbose_cc: bool,87verbose_cc: bool,
88verbose_air: bool,88verbose_air: bool,
89verbose_llvm_ir: bool,89verbose_llvm_ir: ?[]const u8,
90verbose_llvm_bc: ?[]const u8,
90verbose_cimport: bool,91verbose_cimport: bool,
91verbose_llvm_cpu_features: bool,92verbose_llvm_cpu_features: bool,
92disable_c_depfile: bool,93disable_c_depfile: bool,
...@@ -585,7 +586,8 @@ pub const InitOptions = struct {...@@ -585,7 +586,8 @@ pub const InitOptions = struct {
585 verbose_cc: bool = false,586 verbose_cc: bool = false,
586 verbose_link: bool = false,587 verbose_link: bool = false,
587 verbose_air: bool = false,588 verbose_air: bool = false,
588 verbose_llvm_ir: bool = false,589 verbose_llvm_ir: ?[]const u8 = null,
590 verbose_llvm_bc: ?[]const u8 = null,
589 verbose_cimport: bool = false,591 verbose_cimport: bool = false,
590 verbose_llvm_cpu_features: bool = false,592 verbose_llvm_cpu_features: bool = false,
591 is_test: bool = false,593 is_test: bool = false,
...@@ -1559,6 +1561,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1559,6 +1561,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1559 .verbose_cc = options.verbose_cc,1561 .verbose_cc = options.verbose_cc,
1560 .verbose_air = options.verbose_air,1562 .verbose_air = options.verbose_air,
1561 .verbose_llvm_ir = options.verbose_llvm_ir,1563 .verbose_llvm_ir = options.verbose_llvm_ir,
1564 .verbose_llvm_bc = options.verbose_llvm_bc,
1562 .verbose_cimport = options.verbose_cimport,1565 .verbose_cimport = options.verbose_cimport,
1563 .verbose_llvm_cpu_features = options.verbose_llvm_cpu_features,1566 .verbose_llvm_cpu_features = options.verbose_llvm_cpu_features,
1564 .disable_c_depfile = options.disable_c_depfile,1567 .disable_c_depfile = options.disable_c_depfile,
...@@ -5342,6 +5345,7 @@ fn buildOutputFromZig(...@@ -5342,6 +5345,7 @@ fn buildOutputFromZig(
5342 .verbose_link = comp.bin_file.options.verbose_link,5345 .verbose_link = comp.bin_file.options.verbose_link,
5343 .verbose_air = comp.verbose_air,5346 .verbose_air = comp.verbose_air,
5344 .verbose_llvm_ir = comp.verbose_llvm_ir,5347 .verbose_llvm_ir = comp.verbose_llvm_ir,
5348 .verbose_llvm_bc = comp.verbose_llvm_bc,
5345 .verbose_cimport = comp.verbose_cimport,5349 .verbose_cimport = comp.verbose_cimport,
5346 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,5350 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
5347 .clang_passthrough_mode = comp.clang_passthrough_mode,5351 .clang_passthrough_mode = comp.clang_passthrough_mode,
...@@ -5419,6 +5423,7 @@ pub fn build_crt_file(...@@ -5419,6 +5423,7 @@ pub fn build_crt_file(
5419 .verbose_link = comp.bin_file.options.verbose_link,5423 .verbose_link = comp.bin_file.options.verbose_link,
5420 .verbose_air = comp.verbose_air,5424 .verbose_air = comp.verbose_air,
5421 .verbose_llvm_ir = comp.verbose_llvm_ir,5425 .verbose_llvm_ir = comp.verbose_llvm_ir,
5426 .verbose_llvm_bc = comp.verbose_llvm_bc,
5422 .verbose_cimport = comp.verbose_cimport,5427 .verbose_cimport = comp.verbose_cimport,
5423 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,5428 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
5424 .clang_passthrough_mode = comp.clang_passthrough_mode,5429 .clang_passthrough_mode = comp.clang_passthrough_mode,
src/Module.zig+2-2
...@@ -4263,7 +4263,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {...@@ -4263,7 +4263,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {
4263 comp.emit_llvm_bc == null);4263 comp.emit_llvm_bc == null);
42644264
4265 const dump_air = builtin.mode == .Debug and comp.verbose_air;4265 const dump_air = builtin.mode == .Debug and comp.verbose_air;
4266 const dump_llvm_ir = builtin.mode == .Debug and comp.verbose_llvm_ir;4266 const dump_llvm_ir = builtin.mode == .Debug and (comp.verbose_llvm_ir != null or comp.verbose_llvm_bc != null);
42674267
4268 if (no_bin_file and !dump_air and !dump_llvm_ir) return;4268 if (no_bin_file and !dump_air and !dump_llvm_ir) return;
42694269
...@@ -6395,7 +6395,7 @@ pub fn linkerUpdateDecl(mod: *Module, decl_index: Decl.Index) !void {...@@ -6395,7 +6395,7 @@ pub fn linkerUpdateDecl(mod: *Module, decl_index: Decl.Index) !void {
6395 comp.emit_llvm_ir == null and6395 comp.emit_llvm_ir == null and
6396 comp.emit_llvm_bc == null);6396 comp.emit_llvm_bc == null);
63976397
6398 const dump_llvm_ir = builtin.mode == .Debug and comp.verbose_llvm_ir;6398 const dump_llvm_ir = builtin.mode == .Debug and (comp.verbose_llvm_ir != null or comp.verbose_llvm_bc != null);
63996399
6400 if (no_bin_file and !dump_llvm_ir) return;6400 if (no_bin_file and !dump_llvm_ir) return;
64016401
src/codegen/llvm.zig+29-2
...@@ -751,8 +751,35 @@ pub const Object = struct {...@@ -751,8 +751,35 @@ pub const Object = struct {
751 dib.finalize();751 dib.finalize();
752 }752 }
753753
754 if (comp.verbose_llvm_ir) {754 if (comp.verbose_llvm_ir) |path| {
755 self.llvm_module.dump();755 if (std.mem.eql(u8, path, "-")) {
756 self.llvm_module.dump();
757 } else {
758 const path_z = try comp.gpa.dupeZ(u8, path);
759 defer comp.gpa.free(path_z);
760
761 var error_message: [*:0]const u8 = undefined;
762
763 if (self.llvm_module.printModuleToFile(path_z, &error_message).toBool()) {
764 defer llvm.disposeMessage(error_message);
765
766 log.err("dump LLVM module failed ir={s}: {s}", .{
767 path, error_message,
768 });
769 }
770 }
771 }
772
773 if (comp.verbose_llvm_bc) |path| {
774 const path_z = try comp.gpa.dupeZ(u8, path);
775 defer comp.gpa.free(path_z);
776
777 const error_code = self.llvm_module.writeBitcodeToFile(path_z);
778 if (error_code != 0) {
779 log.err("dump LLVM module failed bc={s}: {d}", .{
780 path, error_code,
781 });
782 }
756 }783 }
757784
758 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);785 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
src/codegen/llvm/bindings.zig+3
...@@ -422,6 +422,9 @@ pub const Module = opaque {...@@ -422,6 +422,9 @@ pub const Module = opaque {
422422
423 pub const printModuleToFile = LLVMPrintModuleToFile;423 pub const printModuleToFile = LLVMPrintModuleToFile;
424 extern fn LLVMPrintModuleToFile(M: *Module, Filename: [*:0]const u8, ErrorMessage: *[*:0]const u8) Bool;424 extern fn LLVMPrintModuleToFile(M: *Module, Filename: [*:0]const u8, ErrorMessage: *[*:0]const u8) Bool;
425
426 pub const writeBitcodeToFile = LLVMWriteBitcodeToFile;
427 extern fn LLVMWriteBitcodeToFile(M: *Module, Path: [*:0]const u8) c_int;
425};428};
426429
427pub const lookupIntrinsicID = LLVMLookupIntrinsicID;430pub const lookupIntrinsicID = LLVMLookupIntrinsicID;
src/glibc.zig+1
...@@ -1097,6 +1097,7 @@ fn buildSharedLib(...@@ -1097,6 +1097,7 @@ fn buildSharedLib(
1097 .verbose_link = comp.bin_file.options.verbose_link,1097 .verbose_link = comp.bin_file.options.verbose_link,
1098 .verbose_air = comp.verbose_air,1098 .verbose_air = comp.verbose_air,
1099 .verbose_llvm_ir = comp.verbose_llvm_ir,1099 .verbose_llvm_ir = comp.verbose_llvm_ir,
1100 .verbose_llvm_bc = comp.verbose_llvm_bc,
1100 .verbose_cimport = comp.verbose_cimport,1101 .verbose_cimport = comp.verbose_cimport,
1101 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,1102 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
1102 .clang_passthrough_mode = comp.clang_passthrough_mode,1103 .clang_passthrough_mode = comp.clang_passthrough_mode,
src/libcxx.zig+2
...@@ -250,6 +250,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -250,6 +250,7 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
250 .verbose_link = comp.bin_file.options.verbose_link,250 .verbose_link = comp.bin_file.options.verbose_link,
251 .verbose_air = comp.verbose_air,251 .verbose_air = comp.verbose_air,
252 .verbose_llvm_ir = comp.verbose_llvm_ir,252 .verbose_llvm_ir = comp.verbose_llvm_ir,
253 .verbose_llvm_bc = comp.verbose_llvm_bc,
253 .verbose_cimport = comp.verbose_cimport,254 .verbose_cimport = comp.verbose_cimport,
254 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,255 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
255 .clang_passthrough_mode = comp.clang_passthrough_mode,256 .clang_passthrough_mode = comp.clang_passthrough_mode,
...@@ -410,6 +411,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -410,6 +411,7 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
410 .verbose_link = comp.bin_file.options.verbose_link,411 .verbose_link = comp.bin_file.options.verbose_link,
411 .verbose_air = comp.verbose_air,412 .verbose_air = comp.verbose_air,
412 .verbose_llvm_ir = comp.verbose_llvm_ir,413 .verbose_llvm_ir = comp.verbose_llvm_ir,
414 .verbose_llvm_bc = comp.verbose_llvm_bc,
413 .verbose_cimport = comp.verbose_cimport,415 .verbose_cimport = comp.verbose_cimport,
414 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,416 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
415 .clang_passthrough_mode = comp.clang_passthrough_mode,417 .clang_passthrough_mode = comp.clang_passthrough_mode,
src/libtsan.zig+1
...@@ -226,6 +226,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -226,6 +226,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
226 .verbose_link = comp.bin_file.options.verbose_link,226 .verbose_link = comp.bin_file.options.verbose_link,
227 .verbose_air = comp.verbose_air,227 .verbose_air = comp.verbose_air,
228 .verbose_llvm_ir = comp.verbose_llvm_ir,228 .verbose_llvm_ir = comp.verbose_llvm_ir,
229 .verbose_llvm_bc = comp.verbose_llvm_bc,
229 .verbose_cimport = comp.verbose_cimport,230 .verbose_cimport = comp.verbose_cimport,
230 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,231 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
231 .clang_passthrough_mode = comp.clang_passthrough_mode,232 .clang_passthrough_mode = comp.clang_passthrough_mode,
src/libunwind.zig+1
...@@ -122,6 +122,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -122,6 +122,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: *std.Progress.Node) !void {
122 .verbose_link = comp.bin_file.options.verbose_link,122 .verbose_link = comp.bin_file.options.verbose_link,
123 .verbose_air = comp.verbose_air,123 .verbose_air = comp.verbose_air,
124 .verbose_llvm_ir = comp.verbose_llvm_ir,124 .verbose_llvm_ir = comp.verbose_llvm_ir,
125 .verbose_llvm_bc = comp.verbose_llvm_bc,
125 .verbose_cimport = comp.verbose_cimport,126 .verbose_cimport = comp.verbose_cimport,
126 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,127 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
127 .clang_passthrough_mode = comp.clang_passthrough_mode,128 .clang_passthrough_mode = comp.clang_passthrough_mode,
src/main.zig+15-8
...@@ -370,10 +370,10 @@ const usage_build_generic =...@@ -370,10 +370,10 @@ const usage_build_generic =
370 \\ -fno-emit-bin Do not output machine code370 \\ -fno-emit-bin Do not output machine code
371 \\ -femit-asm[=path] Output .s (assembly code)371 \\ -femit-asm[=path] Output .s (assembly code)
372 \\ -fno-emit-asm (default) Do not output .s (assembly code)372 \\ -fno-emit-asm (default) Do not output .s (assembly code)
373 \\ -femit-llvm-ir[=path] Produce a .ll file with LLVM IR (requires LLVM extensions)373 \\ -femit-llvm-ir[=path] Produce a .ll file with optimized LLVM IR (requires LLVM extensions)
374 \\ -fno-emit-llvm-ir (default) Do not produce a .ll file with LLVM IR374 \\ -fno-emit-llvm-ir (default) Do not produce a .ll file with optimized LLVM IR
375 \\ -femit-llvm-bc[=path] Produce a LLVM module as a .bc file (requires LLVM extensions)375 \\ -femit-llvm-bc[=path] Produce an optimized LLVM module as a .bc file (requires LLVM extensions)
376 \\ -fno-emit-llvm-bc (default) Do not produce a LLVM module as a .bc file376 \\ -fno-emit-llvm-bc (default) Do not produce an optimized LLVM module as a .bc file
377 \\ -femit-h[=path] Generate a C header file (.h)377 \\ -femit-h[=path] Generate a C header file (.h)
378 \\ -fno-emit-h (default) Do not generate a C header file (.h)378 \\ -fno-emit-h (default) Do not generate a C header file (.h)
379 \\ -femit-docs[=path] Create a docs/ dir with html documentation379 \\ -femit-docs[=path] Create a docs/ dir with html documentation
...@@ -555,13 +555,14 @@ const usage_build_generic =...@@ -555,13 +555,14 @@ const usage_build_generic =
555 \\ --test-runner [path] Specify a custom test runner555 \\ --test-runner [path] Specify a custom test runner
556 \\556 \\
557 \\Debug Options (Zig Compiler Development):557 \\Debug Options (Zig Compiler Development):
558 \\ -fopt-bisect-limit [limit] Only run [limit] first LLVM optimization passes558 \\ -fopt-bisect-limit=[limit] Only run [limit] first LLVM optimization passes
559 \\ -ftime-report Print timing diagnostics559 \\ -ftime-report Print timing diagnostics
560 \\ -fstack-report Print stack size diagnostics560 \\ -fstack-report Print stack size diagnostics
561 \\ --verbose-link Display linker invocations561 \\ --verbose-link Display linker invocations
562 \\ --verbose-cc Display C compiler invocations562 \\ --verbose-cc Display C compiler invocations
563 \\ --verbose-air Enable compiler debug output for Zig AIR563 \\ --verbose-air Enable compiler debug output for Zig AIR
564 \\ --verbose-llvm-ir Enable compiler debug output for LLVM IR564 \\ --verbose-llvm-ir[=path] Enable compiler debug output for unoptimized LLVM IR
565 \\ --verbose-llvm-bc=[path] Enable compiler debug output for unoptimized LLVM BC
565 \\ --verbose-cimport Enable compiler debug output for C imports566 \\ --verbose-cimport Enable compiler debug output for C imports
566 \\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features567 \\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features
567 \\ --debug-log [scope] Enable printing debug/info log messages for scope568 \\ --debug-log [scope] Enable printing debug/info log messages for scope
...@@ -704,7 +705,8 @@ fn buildOutputType(...@@ -704,7 +705,8 @@ fn buildOutputType(
704 var verbose_link = (builtin.os.tag != .wasi or builtin.link_libc) and std.process.hasEnvVarConstant("ZIG_VERBOSE_LINK");705 var verbose_link = (builtin.os.tag != .wasi or builtin.link_libc) and std.process.hasEnvVarConstant("ZIG_VERBOSE_LINK");
705 var verbose_cc = (builtin.os.tag != .wasi or builtin.link_libc) and std.process.hasEnvVarConstant("ZIG_VERBOSE_CC");706 var verbose_cc = (builtin.os.tag != .wasi or builtin.link_libc) and std.process.hasEnvVarConstant("ZIG_VERBOSE_CC");
706 var verbose_air = false;707 var verbose_air = false;
707 var verbose_llvm_ir = false;708 var verbose_llvm_ir: ?[]const u8 = null;
709 var verbose_llvm_bc: ?[]const u8 = null;
708 var verbose_cimport = false;710 var verbose_cimport = false;
709 var verbose_llvm_cpu_features = false;711 var verbose_llvm_cpu_features = false;
710 var time_report = false;712 var time_report = false;
...@@ -1441,7 +1443,11 @@ fn buildOutputType(...@@ -1441,7 +1443,11 @@ fn buildOutputType(
1441 } else if (mem.eql(u8, arg, "--verbose-air")) {1443 } else if (mem.eql(u8, arg, "--verbose-air")) {
1442 verbose_air = true;1444 verbose_air = true;
1443 } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {1445 } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
1444 verbose_llvm_ir = true;1446 verbose_llvm_ir = "-";
1447 } else if (mem.startsWith(u8, arg, "--verbose-llvm-ir=")) {
1448 verbose_llvm_ir = arg["--verbose-llvm-ir=".len..];
1449 } else if (mem.startsWith(u8, arg, "--verbose-llvm-bc=")) {
1450 verbose_llvm_bc = arg["--verbose-llvm-bc=".len..];
1445 } else if (mem.eql(u8, arg, "--verbose-cimport")) {1451 } else if (mem.eql(u8, arg, "--verbose-cimport")) {
1446 verbose_cimport = true;1452 verbose_cimport = true;
1447 } else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {1453 } else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
...@@ -3226,6 +3232,7 @@ fn buildOutputType(...@@ -3226,6 +3232,7 @@ fn buildOutputType(
3226 .verbose_link = verbose_link,3232 .verbose_link = verbose_link,
3227 .verbose_air = verbose_air,3233 .verbose_air = verbose_air,
3228 .verbose_llvm_ir = verbose_llvm_ir,3234 .verbose_llvm_ir = verbose_llvm_ir,
3235 .verbose_llvm_bc = verbose_llvm_bc,
3229 .verbose_cimport = verbose_cimport,3236 .verbose_cimport = verbose_cimport,
3230 .verbose_llvm_cpu_features = verbose_llvm_cpu_features,3237 .verbose_llvm_cpu_features = verbose_llvm_cpu_features,
3231 .machine_code_model = machine_code_model,3238 .machine_code_model = machine_code_model,