@@ -68,6 +68,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
6868 macho_step .dependOn (testTlsLargeTbss (b , .{ .target = default_target }));
6969 macho_step .dependOn (testTlsZig (b , .{ .target = default_target }));
7070 macho_step .dependOn (testUndefinedFlag (b , .{ .target = default_target }));
71+ macho_step .dependOn (testUndefinedDynamicLookup (b , .{ .target = default_target }));
7172 macho_step .dependOn (testDiscardLocalSymbols (b , .{ .target = default_target }));
7273 macho_step .dependOn (testUnresolvedError (b , .{ .target = default_target }));
7374 macho_step .dependOn (testUnresolvedError2 (b , .{ .target = default_target }));
@@ -2632,6 +2633,29 @@ fn testUndefinedFlag(b: *Build, opts: Options) *Step {
26322633 return test_step ;
26332634}
26342635
2636+ fn testUndefinedDynamicLookup (b : * Build , opts : Options ) * Step {
2637+ const test_step = addTestStep (b , "undefined-dynamic-lookup" , opts );
2638+
2639+ // Create a dylib with an undefined external symbol reference
2640+ const dylib = addSharedLibrary (b , opts , .{ .name = "a" });
2641+ addCSourceBytes (dylib ,
2642+ \\extern int undefined_symbol(void);
2643+ \\int call_undefined(void) {
2644+ \\ return undefined_symbol();
2645+ \\}
2646+ , &.{});
2647+ dylib .linker_allow_shlib_undefined = true ;
2648+
2649+ // Verify the Mach-O header does NOT contain NOUNDEFS flag
2650+ const check = dylib .checkObject ();
2651+ check .checkInHeaders ();
2652+ check .checkExact ("header" );
2653+ check .checkNotPresent ("NOUNDEFS" );
2654+ test_step .dependOn (& check .step );
2655+
2656+ return test_step ;
2657+ }
2658+
26352659fn testUnresolvedError (b : * Build , opts : Options ) * Step {
26362660 const test_step = addTestStep (b , "unresolved-error" , opts );
26372661
0 commit comments