| author | |
| committer | |
| log | c5aa680c88f7c03718460ff38e7cb1f7c5482cf2 |
| tree | 945c63b1778719f79ead29a757d227184a406d13 |
| parent | 4ddb13468b372b2f722703b5e6d60997776c251a |
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).4 files changed, 7 insertions(+), 10 deletions(-)
lib/compiler/build_runner.zig+2| ... | ... | @@ -80,6 +80,7 @@ pub fn main() !void { |
| 80 | 80 | .query = .{}, |
| 81 | 81 | .result = try std.zig.system.resolveTargetQuery(.{}), |
| 82 | 82 | }, |
| 83 | .root_builder = undefined, // populated below | |
| 83 | 84 | }; |
| 84 | 85 | |
| 85 | 86 | graph.cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); |
| ... | ... | @@ -94,6 +95,7 @@ pub fn main() !void { |
| 94 | 95 | local_cache_directory, |
| 95 | 96 | dependencies.root_deps, |
| 96 | 97 | ); |
| 98 | graph.root_builder = builder; | |
| 97 | 99 | |
| 98 | 100 | var targets = ArrayList([]const u8).init(arena); |
| 99 | 101 | var debug_log_scopes = ArrayList([]const u8).init(arena); |
lib/std/Build.zig+2-5| ... | ... | @@ -94,9 +94,6 @@ available_deps: AvailableDeps, |
| 94 | 94 | |
| 95 | 95 | release_mode: ReleaseMode, |
| 96 | 96 | |
| 97 | /// `true` only for the root `Build`; `false` for any `Build` belonging to a dependency. | |
| 98 | is_root: bool = false, | |
| 99 | ||
| 100 | 97 | pub const ReleaseMode = enum { |
| 101 | 98 | off, |
| 102 | 99 | any, |
| ... | ... | @@ -121,10 +118,11 @@ pub const Graph = struct { |
| 121 | 118 | /// Information about the native target. Computed before build() is invoked. |
| 122 | 119 | host: ResolvedTarget, |
| 123 | 120 | incremental: ?bool = null, |
| 124 | allow_deprecated: ?bool = null, | |
| 125 | 121 | random_seed: u32 = 0, |
| 126 | 122 | dependency_cache: InitializedDepMap = .empty, |
| 127 | 123 | allow_so_scripts: ?bool = null, |
| 124 | allow_deprecated: ?bool = null, | |
| 125 | root_builder: *std.Build, | |
| 128 | 126 | }; |
| 129 | 127 | |
| 130 | 128 | const AvailableDeps = []const struct { []const u8, []const u8 }; |
| ... | ... | @@ -308,7 +306,6 @@ pub fn create( |
| 308 | 306 | .pkg_hash = "", |
| 309 | 307 | .available_deps = available_deps, |
| 310 | 308 | .release_mode = .off, |
| 311 | .is_root = true, | |
| 312 | 309 | }; |
| 313 | 310 | try b.top_level_steps.put(arena, b.install_tls.step.name, &b.install_tls); |
| 314 | 311 | try b.top_level_steps.put(arena, b.uninstall_tls.step.name, &b.uninstall_tls); |
lib/std/Build/Module.zig+3-4| ... | ... | @@ -557,10 +557,9 @@ pub fn appendZigProcessFlags( |
| 557 | 557 | try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC"); |
| 558 | 558 | try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone"); |
| 559 | 559 | |
| 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"); | |
| 564 | 563 | |
| 565 | 564 | if (m.dwarf_format) |dwarf_format| { |
| 566 | 565 | try zig_args.append(switch (dwarf_format) { |
src/Package/Module.zig-1| ... | ... | @@ -238,7 +238,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 238 | 238 | |
| 239 | 239 | const allow_deprecated = b: { |
| 240 | 240 | if (options.inherited.allow_deprecated) |x| break :b x; |
| 241 | if (options.parent) |p| break :b p.allow_deprecated; | |
| 242 | 241 | break :b false; |
| 243 | 242 | }; |
| 244 | 243 |