From 5bee0d01229e9042a985292825ae7dda964fa7cc Mon Sep 17 00:00:00 2001 From: David Gonzalez Martin Date: Sun, 14 Apr 2024 14:38:32 -0600 Subject: [PATCH] Provide debug info switch --- bootstrap/Compilation.zig | 11 ++++++++++- bootstrap/backend/llvm.zig | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bootstrap/Compilation.zig b/bootstrap/Compilation.zig index f9410a9..0fc8add 100644 --- a/bootstrap/Compilation.zig +++ b/bootstrap/Compilation.zig @@ -2803,7 +2803,7 @@ pub fn buildExecutable(context: *const Context, arguments: []const []const u8, o var maybe_executable_name: ?[]const u8 = null; var c_source_files = UnpinnedArray([]const u8){}; var optimization = Optimization.none; - const generate_debug_information = true; + var generate_debug_information = true; if (arguments.len == 0) return error.InvalidInput; @@ -2929,6 +2929,15 @@ pub fn buildExecutable(context: *const Context, arguments: []const []const u8, o } else { reportUnterminatedArgumentError(current_argument); } + } else if (byte_equal(current_argument, "-debug")) { + if (i + 1 != arguments.len) { + i += 1; + + const debug_string = arguments[i]; + generate_debug_information = if (byte_equal(debug_string, "true")) true else if (byte_equal(debug_string, "false")) false else unreachable; + } else { + reportUnterminatedArgumentError(current_argument); + } } else { @panic(current_argument); // std.debug.panic("Unrecognized argument: {s}", .{current_argument}); diff --git a/bootstrap/backend/llvm.zig b/bootstrap/backend/llvm.zig index 2b68a5f..e04a9fc 100644 --- a/bootstrap/backend/llvm.zig +++ b/bootstrap/backend/llvm.zig @@ -2412,7 +2412,6 @@ pub fn codegen(unit: *Compilation.Unit, context: *const Compilation.Context) !vo .@"noalias" = llvm_context.getAttributeFromEnum(.NoAlias, 0), }, }; - unit.descriptor.generate_debug_information = false; if (unit.descriptor.generate_debug_information) { const full_path = try std.fs.cwd().realpathAlloc(context.allocator, unit.descriptor.main_package_path);