aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/std/Build/Step/Compile.zig16
-rw-r--r--test/standalone/build.zig.zon3
-rw-r--r--test/standalone/dep_duplicate_module/build.zig32
-rw-r--r--test/standalone/dep_duplicate_module/lib.zig6
-rw-r--r--test/standalone/dep_duplicate_module/main.zig8
-rw-r--r--test/standalone/dep_duplicate_module/mod.zig7
6 files changed, 69 insertions, 3 deletions
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index d18d8de413..504025e3d4 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -989,10 +989,10 @@ fn getGeneratedFilePath(compile: *Compile, comptime tag_name: []const u8, asking
return path;
}
-fn make(step: *Step, prog_node: std.Progress.Node) !void {
+fn getZigArgs(compile: *Compile) ![][]const u8 {
+ const step = &compile.step;
const b = step.owner;
const arena = b.allocator;
- const compile: *Compile = @fieldParentPtr("step", step);
var zig_args = ArrayList([]const u8).init(arena);
defer zig_args.deinit();
@@ -1298,6 +1298,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
// We need to emit the --mod argument here so that the above link objects
// have the correct parent module, but only if the module is part of
// this compilation.
+ if (!my_responsibility) continue;
if (cli_named_modules.modules.getIndex(dep.module)) |module_cli_index| {
const module_cli_name = cli_named_modules.names.keys()[module_cli_index];
try dep.module.appendZigProcessFlags(&zig_args, step);
@@ -1724,7 +1725,16 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
try zig_args.append(resolved_args_file);
}
- const maybe_output_bin_path = step.evalZigProcess(zig_args.items, prog_node) catch |err| switch (err) {
+ return try zig_args.toOwnedSlice();
+}
+
+fn make(step: *Step, prog_node: std.Progress.Node) !void {
+ const b = step.owner;
+ const compile: *Compile = @fieldParentPtr("step", step);
+
+ const zig_args = try getZigArgs(compile);
+
+ const maybe_output_bin_path = step.evalZigProcess(zig_args, prog_node) catch |err| switch (err) {
error.NeedCompileErrorCheck => {
assert(compile.expect_errors != null);
try checkCompileErrors(compile);
diff --git a/test/standalone/build.zig.zon b/test/standalone/build.zig.zon
index 1e79a547e9..80e9ba046c 100644
--- a/test/standalone/build.zig.zon
+++ b/test/standalone/build.zig.zon
@@ -86,6 +86,9 @@
.dirname = .{
.path = "dirname",
},
+ .dep_duplicate_module = .{
+ .path = "dep_duplicate_module",
+ },
.empty_env = .{
.path = "empty_env",
},
diff --git a/test/standalone/dep_duplicate_module/build.zig b/test/standalone/dep_duplicate_module/build.zig
new file mode 100644
index 0000000000..733d49b91c
--- /dev/null
+++ b/test/standalone/dep_duplicate_module/build.zig
@@ -0,0 +1,32 @@
+const std = @import("std");
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+
+ const mod = b.addModule("mod", .{
+ .root_source_file = b.path("mod.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+
+ const lib = b.addStaticLibrary(.{
+ .name = "lib",
+ .root_source_file = b.path("lib.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+ lib.root_module.addImport("mod", mod);
+
+ const exe = b.addExecutable(.{
+ .name = "app",
+ .root_source_file = b.path("main.zig"),
+ .target = target,
+ .optimize = optimize,
+ });
+
+ exe.root_module.addImport("mod", mod);
+ exe.root_module.linkLibrary(lib);
+
+ b.installArtifact(exe);
+}
diff --git a/test/standalone/dep_duplicate_module/lib.zig b/test/standalone/dep_duplicate_module/lib.zig
new file mode 100644
index 0000000000..0a44f1a8ce
--- /dev/null
+++ b/test/standalone/dep_duplicate_module/lib.zig
@@ -0,0 +1,6 @@
+const std = @import("std");
+const mod = @import("mod");
+
+export fn work(x: u32) u32 {
+ return mod.double(x);
+}
diff --git a/test/standalone/dep_duplicate_module/main.zig b/test/standalone/dep_duplicate_module/main.zig
new file mode 100644
index 0000000000..0ff26699c3
--- /dev/null
+++ b/test/standalone/dep_duplicate_module/main.zig
@@ -0,0 +1,8 @@
+const std = @import("std");
+const mod = @import("mod");
+
+extern fn work(x: u32) u32;
+
+pub fn main() !void {
+ _ = work(mod.half(25));
+}
diff --git a/test/standalone/dep_duplicate_module/mod.zig b/test/standalone/dep_duplicate_module/mod.zig
new file mode 100644
index 0000000000..019ae3be97
--- /dev/null
+++ b/test/standalone/dep_duplicate_module/mod.zig
@@ -0,0 +1,7 @@
+pub fn double(v: u32) u32 {
+ return v * 2;
+}
+
+pub fn half(v: u32) u32 {
+ return v / 2;
+}