Skip to content

Commit c5aa680

Browse files
committed
don't inherit allowed deprecation from parent modules
Inheriting allow-deprecation from parent modules doesn't make too much sense, so instead make them default to disallow unless otherwise specified. This allows build system to avoid redundant `-fno-allow-deprecated` args. This makes the generated CLIs smaller, and makes zig1.wasm update not needed. Also represented `is_root` differently (moved to field of graph).
1 parent 4ddb134 commit c5aa680

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

lib/compiler/build_runner.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub fn main() !void {
8080
.query = .{},
8181
.result = try std.zig.system.resolveTargetQuery(.{}),
8282
},
83+
.root_builder = undefined, // populated below
8384
};
8485

8586
graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() });
@@ -94,6 +95,7 @@ pub fn main() !void {
9495
local_cache_directory,
9596
dependencies.root_deps,
9697
);
98+
graph.root_builder = builder;
9799

98100
var targets = ArrayList([]const u8).init(arena);
99101
var debug_log_scopes = ArrayList([]const u8).init(arena);

lib/std/Build.zig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ available_deps: AvailableDeps,
9494

9595
release_mode: ReleaseMode,
9696

97-
/// `true` only for the root `Build`; `false` for any `Build` belonging to a dependency.
98-
is_root: bool = false,
99-
10097
pub const ReleaseMode = enum {
10198
off,
10299
any,
@@ -121,10 +118,11 @@ pub const Graph = struct {
121118
/// Information about the native target. Computed before build() is invoked.
122119
host: ResolvedTarget,
123120
incremental: ?bool = null,
124-
allow_deprecated: ?bool = null,
125121
random_seed: u32 = 0,
126122
dependency_cache: InitializedDepMap = .empty,
127123
allow_so_scripts: ?bool = null,
124+
allow_deprecated: ?bool = null,
125+
root_builder: *std.Build,
128126
};
129127

130128
const AvailableDeps = []const struct { []const u8, []const u8 };
@@ -308,7 +306,6 @@ pub fn create(
308306
.pkg_hash = "",
309307
.available_deps = available_deps,
310308
.release_mode = .off,
311-
.is_root = true,
312309
};
313310
try b.top_level_steps.put(arena, b.install_tls.step.name, &b.install_tls);
314311
try b.top_level_steps.put(arena, b.uninstall_tls.step.name, &b.uninstall_tls);

lib/std/Build/Module.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,9 @@ pub fn appendZigProcessFlags(
557557
try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
558558
try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
559559

560-
if (m.root_source_file != null) {
561-
const allow_deprecated = m.owner.graph.allow_deprecated orelse !m.owner.is_root;
562-
try addFlag(zig_args, allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated");
563-
}
560+
// -fno-allow-deprecated is the CLI default, and not inherited, so only pass the flag if true.
561+
const allow_deprecated = m.owner.graph.allow_deprecated orelse (m.owner.graph.root_builder != m.owner);
562+
if (allow_deprecated == true) try zig_args.append("-fallow-deprecated");
564563

565564
if (m.dwarf_format) |dwarf_format| {
566565
try zig_args.append(switch (dwarf_format) {

src/Package/Module.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
238238

239239
const allow_deprecated = b: {
240240
if (options.inherited.allow_deprecated) |x| break :b x;
241-
if (options.parent) |p| break :b p.allow_deprecated;
242241
break :b false;
243242
};
244243

0 commit comments

Comments
 (0)