Skip to content

Commit 85c3ff5

Browse files
committed
stop MacOS dropping LIBS=>"-framework X" with no "-l" libs
1 parent ab4fb6a commit 85c3ff5

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/ExtUtils/Liblist/Kid.pm

+4-8
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ sub _unix_os2_ext {
8686

8787
if ($^O eq 'darwin') {
8888
# 'escape' Mach-O ld -framework and -F flags, so they aren't dropped later on
89-
$potential_libs =~ s/(^|\s)(-(?:weak_|reexport_|lazy_)?framework)\s+(\S+)/$1-Wl,$2 -Wl,$3/g;
90-
$potential_libs =~ s/(^|\s)(-F)\s*(\S+)/$1-Wl,$2 -Wl,$3/g;
89+
$found++ if $potential_libs =~ s/(^|\s)(-(?:weak_|reexport_|lazy_)?framework)\s+(\S+)/$1-Wl,$2 -Wl,$3/g;
90+
$found++ if $potential_libs =~ s/(^|\s)(-F)\s*(\S+)/$1-Wl,$2 -Wl,$3/g;
9191
}
9292

9393
foreach my $thislib ( Text::ParseWords::shellwords($potential_libs) ) {
@@ -271,12 +271,8 @@ sub _unix_os2_ext {
271271
unless $found_lib > 0;
272272
}
273273

274-
unless ( $found ) {
275-
return ( '', '', '', '', ( $give_libs ? \@libs : () ) );
276-
}
277-
else {
278-
return ( "@extralibs", "@bsloadlibs", "@ldloadlibs", join( ":", @ld_run_path ), ( $give_libs ? \@libs : () ) );
279-
}
274+
return ( '', '', '', '', ( $give_libs ? \@libs : () ) ) unless $found;
275+
( "@extralibs", "@bsloadlibs", "@ldloadlibs", join( ":", @ld_run_path ), ( $give_libs ? \@libs : () ) );
280276
}
281277

282278
sub _win32_ext {

t/Liblist_Kid.t

+8
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ sub test_kid_unix_os2 {
133133
like( $out[2], $qlibre, 'existing file results in quoted ldloadlibs' );
134134
ok $out[3], 'existing file results in true LD_RUN_PATH';
135135
is_deeply [ _ext( '-L. -lnotthere' ) ], [ ('') x 4 ], 'non-present lib = empty';
136+
if ($^O eq 'darwin') {
137+
my @got = _ext( '-framework Something -L. -lfoo' );
138+
like $got[0], qr/Something/, '-framework with other lib works' or diag explain \@got;
139+
like $got[2], qr/Something/, '-framework with other lib works' or diag explain \@got;
140+
@got = _ext( '-framework Something' );
141+
like $got[0], qr/Something/, 'no drop -framework without other lib' or diag explain \@got;
142+
like $got[2], qr/Something/, 'no drop -framework without other lib' or diag explain \@got;
143+
}
136144
my $curr_dirspace = File::Spec->rel2abs( 'di r' );
137145
my $cmd_frag = '-L'.quote($curr_dirspace) . ' -ldir_test';
138146
is_deeply [ _ext( '-L"di r" -ldir_test' ) ], [ $cmd_frag, '', $cmd_frag, $curr_dirspace ], '-L directories with spaces work';

0 commit comments

Comments
 (0)