authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-06-18 19:53:55+05:00
committergravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2024-12-18 01:47:50+05:00
logfaafeb51afb9edf5a1f11cb3ab1f9091f07344c7
treebc6c51c3e6f5311847f7830c7175f06be9d384a3
parent3d393dba6fc06cea3508aaa3db9d49042663367e
signaturelock-open Commit is signed but in an unrecognized format.

std.Build.Step.Compile: change `root_module` field type to `*Module`

This commit changes the `root_module` field of `std.Build.Step.Compile` to be a `*Module` rather than a `Module`. This is a breaking change, but an incredibly minor one (the full potential extent of the breakage can be seen in the modified standalone test). This change will be necessary for an upcoming improvement, so it was convenient to make it here.

4 files changed, 8 insertions(+), 6 deletions(-)

lib/std/Build/Module.zig+1-1
......@@ -430,7 +430,7 @@ pub const DependencyIterator = struct {
430430 if (!it.chase_dyn_libs and compile.isDynamicLibrary()) continue;
431431
432432 it.set.put(it.allocator, .{
433 .module = &compile.root_module,
433 .module = compile.root_module,
434434 .compile = compile,
435435 }, "root") catch @panic("OOM");
436436 },
lib/std/Build/Step/Compile.zig+5-3
......@@ -22,7 +22,7 @@ const Path = std.Build.Cache.Path;
2222pub const base_id: Step.Id = .compile;
2323
2424step: Step,
25root_module: Module,
25root_module: *Module,
2626
2727name: []const u8,
2828linker_script: ?LazyPath = null,
......@@ -432,7 +432,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile {
432432 .zig_process = null,
433433 };
434434
435 compile.root_module.init(owner, options.root_module, compile);
435 const root_module = owner.allocator.create(Module) catch @panic("OOM");
436 root_module.init(owner, options.root_module, compile);
437 compile.root_module = root_module;
436438
437439 if (options.zig_lib_dir) |lp| {
438440 compile.zig_lib_dir = lp.dupe(compile.step.owner);
......@@ -1089,7 +1091,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
10891091 }
10901092 }
10911093
1092 var cli_named_modules = try CliNamedModules.init(arena, &compile.root_module);
1094 var cli_named_modules = try CliNamedModules.init(arena, compile.root_module);
10931095
10941096 // For this loop, don't chase dynamic libraries because their link
10951097 // objects are already linked.
lib/std/Build/Step/Run.zig+1-1
......@@ -1722,7 +1722,7 @@ fn addPathForDynLibs(run: *Run, artifact: *Step.Compile) void {
17221722 var it = artifact.root_module.iterateDependencies(artifact, true);
17231723 while (it.next()) |item| {
17241724 const other = item.compile.?;
1725 if (item.module == &other.root_module) {
1725 if (item.module == other.root_module) {
17261726 if (item.module.resolved_target.?.result.os.tag == .windows and
17271727 other.isDynamicLibrary())
17281728 {
test/standalone/depend_on_main_mod/build.zig+1-1
......@@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void {
1818 .root_source_file = b.path("src/foo.zig"),
1919 });
2020
21 foo_module.addImport("root2", &exe.root_module);
21 foo_module.addImport("root2", exe.root_module);
2222 exe.root_module.addImport("foo", foo_module);
2323
2424 const run_cmd = b.addRunArtifact(exe);