| author | |
| committer | |
| log | faafeb51afb9edf5a1f11cb3ab1f9091f07344c7 |
| tree | bc6c51c3e6f5311847f7830c7175f06be9d384a3 |
| parent | 3d393dba6fc06cea3508aaa3db9d49042663367e |
| signature |
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 { |
| 430 | 430 | if (!it.chase_dyn_libs and compile.isDynamicLibrary()) continue; |
| 431 | 431 | |
| 432 | 432 | it.set.put(it.allocator, .{ |
| 433 | .module = &compile.root_module, | |
| 433 | .module = compile.root_module, | |
| 434 | 434 | .compile = compile, |
| 435 | 435 | }, "root") catch @panic("OOM"); |
| 436 | 436 | }, |
lib/std/Build/Step/Compile.zig+5-3| ... | ... | @@ -22,7 +22,7 @@ const Path = std.Build.Cache.Path; |
| 22 | 22 | pub const base_id: Step.Id = .compile; |
| 23 | 23 | |
| 24 | 24 | step: Step, |
| 25 | root_module: Module, | |
| 25 | root_module: *Module, | |
| 26 | 26 | |
| 27 | 27 | name: []const u8, |
| 28 | 28 | linker_script: ?LazyPath = null, |
| ... | ... | @@ -432,7 +432,9 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 432 | 432 | .zig_process = null, |
| 433 | 433 | }; |
| 434 | 434 | |
| 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; | |
| 436 | 438 | |
| 437 | 439 | if (options.zig_lib_dir) |lp| { |
| 438 | 440 | compile.zig_lib_dir = lp.dupe(compile.step.owner); |
| ... | ... | @@ -1089,7 +1091,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { |
| 1089 | 1091 | } |
| 1090 | 1092 | } |
| 1091 | 1093 | |
| 1092 | var cli_named_modules = try CliNamedModules.init(arena, &compile.root_module); | |
| 1094 | var cli_named_modules = try CliNamedModules.init(arena, compile.root_module); | |
| 1093 | 1095 | |
| 1094 | 1096 | // For this loop, don't chase dynamic libraries because their link |
| 1095 | 1097 | // objects are already linked. |
lib/std/Build/Step/Run.zig+1-1| ... | ... | @@ -1722,7 +1722,7 @@ fn addPathForDynLibs(run: *Run, artifact: *Step.Compile) void { |
| 1722 | 1722 | var it = artifact.root_module.iterateDependencies(artifact, true); |
| 1723 | 1723 | while (it.next()) |item| { |
| 1724 | 1724 | const other = item.compile.?; |
| 1725 | if (item.module == &other.root_module) { | |
| 1725 | if (item.module == other.root_module) { | |
| 1726 | 1726 | if (item.module.resolved_target.?.result.os.tag == .windows and |
| 1727 | 1727 | other.isDynamicLibrary()) |
| 1728 | 1728 | { |
test/standalone/depend_on_main_mod/build.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ pub fn build(b: *std.Build) void { |
| 18 | 18 | .root_source_file = b.path("src/foo.zig"), |
| 19 | 19 | }); |
| 20 | 20 | |
| 21 | foo_module.addImport("root2", &exe.root_module); | |
| 21 | foo_module.addImport("root2", exe.root_module); | |
| 22 | 22 | exe.root_module.addImport("foo", foo_module); |
| 23 | 23 | |
| 24 | 24 | const run_cmd = b.addRunArtifact(exe); |