authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2025-02-13 20:58:11+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-26 14:41:33-05:00
logba7cd8121d5a52beb1e9844a784ec7a439ee6cfd
treea00b423510a61b56572b3451100d3a0cf762b9e4
parentfff8eff2bd0cc36b192d0ab43b522161227c3c2d

`@deprecated`: add build system support


3 files changed, 17 insertions(+), 0 deletions(-)

lib/compiler/build_runner.zig+6
......@@ -260,6 +260,10 @@ pub fn main() !void {
260260 graph.incremental = true;
261261 } else if (mem.eql(u8, arg, "-fno-incremental")) {
262262 graph.incremental = false;
263 } else if (mem.eql(u8, arg, "-fallow-deprecated")) {
264 graph.allow_deprecated = true;
265 } else if (mem.eql(u8, arg, "-fno-allow-deprecated")) {
266 graph.allow_deprecated = false;
263267 } else if (mem.eql(u8, arg, "-fwine")) {
264268 builder.enable_wine = true;
265269 } else if (mem.eql(u8, arg, "-fno-wine")) {
......@@ -1283,6 +1287,8 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
12831287 \\ new Omit cached steps
12841288 \\ failures (Default) Only print failed steps
12851289 \\ none Do not print the build summary
1290 \\ -fallow-deprecated Allow usage of deprecated code for the entire build graph
1291 \\ -fno-allow-deprecated Disallow usage of deprecated code for the entire build graph
12861292 \\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
12871293 \\ --maxrss <bytes> Limit memory usage (default is to use available memory)
12881294 \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
lib/std/Build.zig+5
......@@ -94,6 +94,9 @@ available_deps: AvailableDeps,
9494
9595release_mode: ReleaseMode,
9696
97// True only for the top-level builder.
98is_root: bool = false,
99
97100pub const ReleaseMode = enum {
98101 off,
99102 any,
......@@ -118,6 +121,7 @@ pub const Graph = struct {
118121 /// Information about the native target. Computed before build() is invoked.
119122 host: ResolvedTarget,
120123 incremental: ?bool = null,
124 allow_deprecated: ?bool = null,
121125 random_seed: u32 = 0,
122126 dependency_cache: InitializedDepMap = .empty,
123127 allow_so_scripts: ?bool = null,
......@@ -304,6 +308,7 @@ pub fn create(
304308 .pkg_hash = "",
305309 .available_deps = available_deps,
306310 .release_mode = .off,
311 .is_root = true,
307312 };
308313 try b.top_level_steps.put(arena, b.install_tls.step.name, &b.install_tls);
309314 try b.top_level_steps.put(arena, b.uninstall_tls.step.name, &b.uninstall_tls);
lib/std/Build/Module.zig+6
......@@ -25,6 +25,7 @@ stack_check: ?bool,
2525sanitize_c: ?bool,
2626sanitize_thread: ?bool,
2727fuzz: ?bool,
28allow_deprecated: ?bool,
2829code_model: std.builtin.CodeModel,
2930valgrind: ?bool,
3031pic: ?bool,
......@@ -284,6 +285,7 @@ pub fn init(
284285 .owner = owner,
285286 .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
286287 .import_table = .{},
288 .allow_deprecated = owner.graph.allow_deprecated orelse !owner.is_root,
287289 .resolved_target = options.target,
288290 .optimize = options.optimize,
289291 .link_libc = options.link_libc,
......@@ -557,6 +559,10 @@ pub fn appendZigProcessFlags(
557559 try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
558560 try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
559561
562 if (m.root_source_file != null) {
563 try addFlag(zig_args, m.allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated");
564 }
565
560566 if (m.dwarf_format) |dwarf_format| {
561567 try zig_args.append(switch (dwarf_format) {
562568 .@"32" => "-gdwarf32",