| ... | ... | @@ -277,6 +277,64 @@ pub fn addCases(ctx: *LinkContext) void { |
| 277 | 277 | }); |
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | |
| 281 | if (ctx.includeTest("explicit-extern-lib-name")) |case| { |
| 282 | // TODO: Lld.zig does not look at explicit inputs to resolve explicit extern lib names |
| 283 | if (ctx.use_llvm) return; |
| 284 | |
| 285 | const lib1 = case.addLibrary(.dynamic, .{ |
| 286 | .name = "lib1", |
| 287 | .name_target = false, |
| 288 | .zig_source_bytes = |
| 289 | \\export fn foo() u8 { |
| 290 | \\ return 43; |
| 291 | \\} |
| 292 | , |
| 293 | }); |
| 294 | |
| 295 | const lib2 = case.addLibrary(.dynamic, .{ |
| 296 | .name = "lib2", |
| 297 | .name_target = false, |
| 298 | .zig_source_bytes = |
| 299 | \\export fn foo() u8 { |
| 300 | \\ return 42; |
| 301 | \\} |
| 302 | , |
| 303 | }); |
| 304 | |
| 305 | const lib3 = case.addLibrary(.static, .{ |
| 306 | .name = "lib3", |
| 307 | .zig_source_bytes = |
| 308 | \\extern fn foo() u8; |
| 309 | \\export fn callFoo() u8 { |
| 310 | \\ return foo(); |
| 311 | \\} |
| 312 | , |
| 313 | }); |
| 314 | |
| 315 | const exe = case.addExecutable(.{ |
| 316 | .name = "test", |
| 317 | .zig_source_bytes = |
| 318 | \\extern "explicit-extern-lib-name-lib2" fn foo() u8; |
| 319 | \\extern fn callFoo() u8; |
| 320 | \\pub fn main() !u8 { |
| 321 | \\ return foo() + callFoo(); |
| 322 | \\} |
| 323 | , |
| 324 | }); |
| 325 | exe.root_module.linkLibrary(lib1); |
| 326 | exe.root_module.linkLibrary(lib2); |
| 327 | // exe.root_module.addLibraryPath(.{ |
| 328 | // .generated = .{ |
| 329 | // .index = lib2.getEmittedBin().generated.index, |
| 330 | // .up = 1, |
| 331 | // }, |
| 332 | // }); |
| 333 | exe.root_module.linkLibrary(lib3); |
| 334 | |
| 335 | const run = case.addRunArtifact(exe); |
| 336 | run.addCheck(.{ .expect_term = .{ .exited = 84 } }); |
| 337 | } |
| 280 | 338 | } |
| 281 | 339 | |
| 282 | 340 | const LinkContext = @import("tests.zig").LinkContext; |