@@ -82,6 +82,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
82
82
83
83
// glibc tests
84
84
elf_step .dependOn (testAsNeeded (b , .{ .target = gnu_target }));
85
+ elf_step .dependOn (testLibraryPathsCompatibility (b , .{ .target = gnu_target , .use_lld = true }));
85
86
// https://github.com/ziglang/zig/issues/17430
86
87
// elf_step.dependOn(testCanonicalPlt(b, .{ .target = gnu_target }));
87
88
elf_step .dependOn (testCommentString (b , .{ .target = gnu_target }));
@@ -308,6 +309,54 @@ fn testAsNeeded(b: *Build, opts: Options) *Step {
308
309
return test_step ;
309
310
}
310
311
312
+ fn testLibraryPathsCompatibility (b : * Build , opts : Options ) * Step {
313
+ const test_step = addTestStep (b , "library-paths-compatibility" , opts );
314
+
315
+ const main_o = addObject (b , opts , .{
316
+ .name = "main" ,
317
+ .c_source_bytes =
318
+ \\#include <stdio.h>
319
+ \\int foo();
320
+ \\int main() {
321
+ \\ printf("%d\n", foo());
322
+ \\ return 0;
323
+ \\}
324
+ \\
325
+ ,
326
+ });
327
+ main_o .linkLibC ();
328
+
329
+ const libfoo = addSharedLibrary (b , opts , .{ .name = "foo" , .omit_soname = true });
330
+ addCSourceBytes (libfoo , "int foo() { return 42; }" , &.{});
331
+
332
+ {
333
+ const scripts = WriteFile .create (b );
334
+ const path = scripts .addCopyFile (libfoo .getEmittedBin (), "foo/libfoo.so" );
335
+
336
+ const exe = addExecutable (b , opts , .{ .name = "test" });
337
+ exe .addObject (main_o );
338
+
339
+ exe .setCwd (scripts .getDirectory ());
340
+ exe .addLibraryPathSpecial ("foo" );
341
+ exe .addRPath (path .dirname ());
342
+
343
+ exe .linkSystemLibrary2 ("foo" , .{ .needed = false });
344
+ exe .linkLibC ();
345
+
346
+ const run = addRunArtifact (exe );
347
+ run .expectStdOutEqual ("42\n " );
348
+ test_step .dependOn (& run .step );
349
+
350
+ const check = exe .checkObject ();
351
+ check .checkInDynamicSection ();
352
+ check .checkExact ("NEEDED libfoo.so" );
353
+ check .checkNotPresent ("NEEDED foo/libfoo.so" );
354
+ test_step .dependOn (& check .step );
355
+ }
356
+
357
+ return test_step ;
358
+ }
359
+
311
360
fn testCanonicalPlt (b : * Build , opts : Options ) * Step {
312
361
const test_step = addTestStep (b , "canonical-plt" , opts );
313
362
0 commit comments