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 {...@@ -260,6 +260,10 @@ pub fn main() !void {
260 graph.incremental = true;260 graph.incremental = true;
261 } else if (mem.eql(u8, arg, "-fno-incremental")) {261 } else if (mem.eql(u8, arg, "-fno-incremental")) {
262 graph.incremental = false;262 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;
263 } else if (mem.eql(u8, arg, "-fwine")) {267 } else if (mem.eql(u8, arg, "-fwine")) {
264 builder.enable_wine = true;268 builder.enable_wine = true;
265 } else if (mem.eql(u8, arg, "-fno-wine")) {269 } else if (mem.eql(u8, arg, "-fno-wine")) {
...@@ -1283,6 +1287,8 @@ fn usage(b: *std.Build, out_stream: anytype) !void {...@@ -1283,6 +1287,8 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
1283 \\ new Omit cached steps1287 \\ new Omit cached steps
1284 \\ failures (Default) Only print failed steps1288 \\ failures (Default) Only print failed steps
1285 \\ none Do not print the build summary1289 \\ 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
1286 \\ -j<N> Limit concurrent jobs (default is to use all CPU cores)1292 \\ -j<N> Limit concurrent jobs (default is to use all CPU cores)
1287 \\ --maxrss <bytes> Limit memory usage (default is to use available memory)1293 \\ --maxrss <bytes> Limit memory usage (default is to use available memory)
1288 \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss1294 \\ --skip-oom-steps Instead of failing, skip steps that would exceed --maxrss
lib/std/Build.zig+5
...@@ -94,6 +94,9 @@ available_deps: AvailableDeps,...@@ -94,6 +94,9 @@ available_deps: AvailableDeps,
9494
95release_mode: ReleaseMode,95release_mode: ReleaseMode,
9696
97// True only for the top-level builder.
98is_root: bool = false,
99
97pub const ReleaseMode = enum {100pub const ReleaseMode = enum {
98 off,101 off,
99 any,102 any,
...@@ -118,6 +121,7 @@ pub const Graph = struct {...@@ -118,6 +121,7 @@ pub const Graph = struct {
118 /// Information about the native target. Computed before build() is invoked.121 /// Information about the native target. Computed before build() is invoked.
119 host: ResolvedTarget,122 host: ResolvedTarget,
120 incremental: ?bool = null,123 incremental: ?bool = null,
124 allow_deprecated: ?bool = null,
121 random_seed: u32 = 0,125 random_seed: u32 = 0,
122 dependency_cache: InitializedDepMap = .empty,126 dependency_cache: InitializedDepMap = .empty,
123 allow_so_scripts: ?bool = null,127 allow_so_scripts: ?bool = null,
...@@ -304,6 +308,7 @@ pub fn create(...@@ -304,6 +308,7 @@ pub fn create(
304 .pkg_hash = "",308 .pkg_hash = "",
305 .available_deps = available_deps,309 .available_deps = available_deps,
306 .release_mode = .off,310 .release_mode = .off,
311 .is_root = true,
307 };312 };
308 try b.top_level_steps.put(arena, b.install_tls.step.name, &b.install_tls);313 try b.top_level_steps.put(arena, b.install_tls.step.name, &b.install_tls);
309 try b.top_level_steps.put(arena, b.uninstall_tls.step.name, &b.uninstall_tls);314 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,...@@ -25,6 +25,7 @@ stack_check: ?bool,
25sanitize_c: ?bool,25sanitize_c: ?bool,
26sanitize_thread: ?bool,26sanitize_thread: ?bool,
27fuzz: ?bool,27fuzz: ?bool,
28allow_deprecated: ?bool,
28code_model: std.builtin.CodeModel,29code_model: std.builtin.CodeModel,
29valgrind: ?bool,30valgrind: ?bool,
30pic: ?bool,31pic: ?bool,
...@@ -284,6 +285,7 @@ pub fn init(...@@ -284,6 +285,7 @@ pub fn init(
284 .owner = owner,285 .owner = owner,
285 .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,286 .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
286 .import_table = .{},287 .import_table = .{},
288 .allow_deprecated = owner.graph.allow_deprecated orelse !owner.is_root,
287 .resolved_target = options.target,289 .resolved_target = options.target,
288 .optimize = options.optimize,290 .optimize = options.optimize,
289 .link_libc = options.link_libc,291 .link_libc = options.link_libc,
...@@ -557,6 +559,10 @@ pub fn appendZigProcessFlags(...@@ -557,6 +559,10 @@ pub fn appendZigProcessFlags(
557 try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");559 try addFlag(zig_args, m.pic, "-fPIC", "-fno-PIC");
558 try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");560 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
560 if (m.dwarf_format) |dwarf_format| {566 if (m.dwarf_format) |dwarf_format| {
561 try zig_args.append(switch (dwarf_format) {567 try zig_args.append(switch (dwarf_format) {
562 .@"32" => "-gdwarf32",568 .@"32" => "-gdwarf32",