diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index 114a9e3acf..f159863ab6 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -80,6 +80,7 @@ pub fn main() !void { .query = .{}, .result = try std.zig.system.resolveTargetQuery(.{}), }, + .root_builder = undefined, // populated below }; graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); @@ -94,6 +95,7 @@ pub fn main() !void { local_cache_directory, dependencies.root_deps, ); + graph.root_builder = builder; var targets = ArrayList([]const u8).init(arena); var debug_log_scopes = ArrayList([]const u8).init(arena); diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 1add40d5df..4f3364bb19 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -94,9 +94,6 @@ available_deps: AvailableDeps, release_mode: ReleaseMode, -/// `true` only for the root `Build`; `false` for any `Build` belonging to a dependency. -is_root: bool = false, - pub const ReleaseMode = enum { off, any, @@ -121,10 +118,11 @@ pub const Graph = struct { /// Information about the native target. Computed before build() is invoked. host: ResolvedTarget, incremental: ?bool = null, - allow_deprecated: ?bool = null, random_seed: u32 = 0, dependency_cache: InitializedDepMap = .empty, allow_so_scripts: ?bool = null, + allow_deprecated: ?bool = null, + root_builder: *std.Build, }; const AvailableDeps = []const struct { []const u8, []const u8 }; @@ -308,7 +306,6 @@ pub fn create( .pkg_hash = "", .available_deps = available_deps, .release_mode = .off, - .is_root = true, }; try b.top_level_steps.put(arena, b.install_tls.step.name, &b.install_tls); try b.top_level_steps.put(arena, b.uninstall_tls.step.name, &b.uninstall_tls); diff --git a/lib/std/Build/Module.zig b/lib/std/Build/Module.zig index 8a8b9573e4..40b9a5e619 100644 --- a/lib/std/Build/Module.zig +++ b/lib/std/Build/Module.zig @@ -557,10 +557,9 @@ pub fn appendZigProcessFlags( try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC"); try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone"); - if (m.root_source_file != null) { - const allow_deprecated = m.owner.graph.allow_deprecated orelse !m.owner.is_root; - try addFlag(zig_args, allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated"); - } + // -fno-allow-deprecated is the CLI default, and not inherited, so only pass the flag if true. + const allow_deprecated = m.owner.graph.allow_deprecated orelse (m.owner.graph.root_builder != m.owner); + if (allow_deprecated == true) try zig_args.append("-fallow-deprecated"); if (m.dwarf_format) |dwarf_format| { try zig_args.append(switch (dwarf_format) { diff --git a/src/Package/Module.zig b/src/Package/Module.zig index 6bd33dffa1..c5aa21a105 100644 --- a/src/Package/Module.zig +++ b/src/Package/Module.zig @@ -238,7 +238,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { const allow_deprecated = b: { if (options.inherited.allow_deprecated) |x| break :b x; - if (options.parent) |p| break :b p.allow_deprecated; break :b false; };