aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-02-22 18:18:24 -0500
committerGitHub <noreply@github.com>2025-02-22 18:18:24 -0500
commit61b69a418db2f525c4be4e19029487f61fb3234e (patch)
tree8612f2d44ceac2de68f0493476e2bbbfb0c112cb /test
parent6ef2384c07ef6817f134ffc61e34bcea6e87df92 (diff)
parent0499c731eabd2c88928ef740b488706c51a8a6a7 (diff)
downloadzig-61b69a418db2f525c4be4e19029487f61fb3234e.tar.gz
zig-61b69a418db2f525c4be4e19029487f61fb3234e.zip
Merge pull request #22659 from ifreund/linker-script-fix
link: fix ambiguous names in linker scripts
Diffstat (limited to 'test')
-rw-r--r--test/link/elf.zig27
1 files changed, 19 insertions, 8 deletions
diff --git a/test/link/elf.zig b/test/link/elf.zig
index a64da3ad20..dfa5954032 100644
--- a/test/link/elf.zig
+++ b/test/link/elf.zig
@@ -2123,24 +2123,35 @@ fn testLinkOrder(b: *Build, opts: Options) *Step {
fn testLdScript(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "ld-script", opts);
- const dso = addSharedLibrary(b, opts, .{ .name = "bar" });
- addCSourceBytes(dso, "int foo() { return 42; }", &.{});
+ const bar = addSharedLibrary(b, opts, .{ .name = "bar" });
+ addCSourceBytes(bar, "int bar() { return 42; }", &.{});
+
+ const baz = addSharedLibrary(b, opts, .{ .name = "baz" });
+ addCSourceBytes(baz, "int baz() { return 42; }", &.{});
const scripts = WriteFile.create(b);
- _ = scripts.add("liba.so", "INPUT(libfoo.so)");
+ _ = scripts.add("liba.so", "INPUT(libfoo.so libfoo2.so.1)");
_ = scripts.add("libfoo.so", "GROUP(AS_NEEDED(-lbar))");
+ // Check finding a versioned .so file that is elsewhere in the library search paths.
+ const scripts2 = WriteFile.create(b);
+ _ = scripts2.add("libfoo2.so.1", "GROUP(AS_NEEDED(-lbaz))");
+
const exe = addExecutable(b, opts, .{ .name = "main" });
addCSourceBytes(exe,
- \\int foo();
+ \\int bar();
+ \\int baz();
\\int main() {
- \\ return foo() - 42;
+ \\ return bar() - baz();
\\}
, &.{});
exe.linkSystemLibrary2("a", .{});
exe.addLibraryPath(scripts.getDirectory());
- exe.addLibraryPath(dso.getEmittedBinDirectory());
- exe.addRPath(dso.getEmittedBinDirectory());
+ exe.addLibraryPath(scripts2.getDirectory());
+ exe.addLibraryPath(bar.getEmittedBinDirectory());
+ exe.addLibraryPath(baz.getEmittedBinDirectory());
+ exe.addRPath(bar.getEmittedBinDirectory());
+ exe.addRPath(baz.getEmittedBinDirectory());
exe.linkLibC();
exe.allow_so_scripts = true;
@@ -2167,7 +2178,7 @@ fn testLdScriptPathError(b: *Build, opts: Options) *Step {
// TODO: A future enhancement could make this error message also mention
// the file that references the missing library.
expectLinkErrors(exe, test_step, .{
- .stderr_contains = "error: unable to find dynamic system library 'foo' using strategy 'no_fallback'. searched paths:",
+ .stderr_contains = "error: libfoo.so: file listed in linker script not found",
});
return test_step;