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..9148bf2c8f --- /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 = .{ .path = "mod.zig" }, + .target = target, + .optimize = optimize, + }); + + const lib = b.addStaticLibrary(.{ + .name = "lib", + .root_source_file = .{ .path = "lib.zig" }, + .target = target, + .optimize = optimize, + }); + lib.root_module.addImport("mod", mod); + + const exe = b.addExecutable(.{ + .name = "app", + .root_source_file = .{ .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; +}