Skip to content

Commit ef35c3d

Browse files
authored
Merge pull request #23986 from mlugg/incremental-stuff
incremental: bugfix (and a debugging feature that helped me do that bugfix)
2 parents dc6ffc2 + 3d8e760 commit ef35c3d

File tree

11 files changed

+651
-60
lines changed

11 files changed

+651
-60
lines changed

lib/compiler/build_runner.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ pub fn main() !void {
236236
graph.debug_compiler_runtime_libs = true;
237237
} else if (mem.eql(u8, arg, "--debug-compile-errors")) {
238238
builder.debug_compile_errors = true;
239+
} else if (mem.eql(u8, arg, "--debug-incremental")) {
240+
builder.debug_incremental = true;
239241
} else if (mem.eql(u8, arg, "--system")) {
240242
// The usage text shows another argument after this parameter
241243
// but it is handled by the parent process. The build runner

lib/std/Build.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pkg_config_pkg_list: ?(PkgConfigError![]const PkgConfigPkg) = null,
5959
args: ?[]const []const u8 = null,
6060
debug_log_scopes: []const []const u8 = &.{},
6161
debug_compile_errors: bool = false,
62+
debug_incremental: bool = false,
6263
debug_pkg_config: bool = false,
6364
/// Number of stack frames captured when a `StackTrace` is recorded for debug purposes,
6465
/// in particular at `Step` creation.
@@ -385,6 +386,7 @@ fn createChildOnly(
385386
.cache_root = parent.cache_root,
386387
.debug_log_scopes = parent.debug_log_scopes,
387388
.debug_compile_errors = parent.debug_compile_errors,
389+
.debug_incremental = parent.debug_incremental,
388390
.debug_pkg_config = parent.debug_pkg_config,
389391
.enable_darling = parent.enable_darling,
390392
.enable_qemu = parent.enable_qemu,

lib/std/Build/Step/Compile.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,10 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
14471447
try zig_args.append("--debug-compile-errors");
14481448
}
14491449

1450+
if (b.debug_incremental) {
1451+
try zig_args.append("--debug-incremental");
1452+
}
1453+
14501454
if (b.verbose_cimport) try zig_args.append("--verbose-cimport");
14511455
if (b.verbose_air) try zig_args.append("--verbose-air");
14521456
if (b.verbose_llvm_ir) |path| try zig_args.append(b.fmt("--verbose-llvm-ir={s}", .{path}));

src/Compilation.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ time_report: bool,
190190
stack_report: bool,
191191
debug_compiler_runtime_libs: bool,
192192
debug_compile_errors: bool,
193+
/// Do not check this field directly. Instead, use the `debugIncremental` wrapper function.
194+
debug_incremental: bool,
193195
incremental: bool,
194196
alloc_failure_occurred: bool = false,
195197
last_update_was_cache_hit: bool = false,
@@ -768,6 +770,14 @@ pub const Directories = struct {
768770
}
769771
};
770772

773+
/// This small wrapper function just checks whether debug extensions are enabled before checking
774+
/// `comp.debug_incremental`. It is inline so that comptime-known `false` propagates to the caller,
775+
/// preventing debugging features from making it into release builds of the compiler.
776+
pub inline fn debugIncremental(comp: *const Compilation) bool {
777+
if (!build_options.enable_debug_extensions) return false;
778+
return comp.debug_incremental;
779+
}
780+
771781
pub const default_stack_protector_buffer_size = target_util.default_stack_protector_buffer_size;
772782
pub const SemaError = Zcu.SemaError;
773783

@@ -1598,6 +1608,7 @@ pub const CreateOptions = struct {
15981608
verbose_llvm_cpu_features: bool = false,
15991609
debug_compiler_runtime_libs: bool = false,
16001610
debug_compile_errors: bool = false,
1611+
debug_incremental: bool = false,
16011612
incremental: bool = false,
16021613
/// Normally when you create a `Compilation`, Zig will automatically build
16031614
/// and link in required dependencies, such as compiler-rt and libc. When
@@ -1968,6 +1979,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
19681979
.test_name_prefix = options.test_name_prefix,
19691980
.debug_compiler_runtime_libs = options.debug_compiler_runtime_libs,
19701981
.debug_compile_errors = options.debug_compile_errors,
1982+
.debug_incremental = options.debug_incremental,
19711983
.incremental = options.incremental,
19721984
.root_name = root_name,
19731985
.sysroot = sysroot,

0 commit comments

Comments
 (0)