Skip to content

Commit a8ac5a8

Browse files
committed
Use LIBS not LDFROM to link against a library
There is a newish test in 02-xsdynamic.t that tries to use LDFROM to link against another extension. The docs for LDFROM make it pretty clear that it is for object files, not libraries. So switch that test to LIBS, which also greatly simplifies the test setup because LIBS already knows about what file extensions to use for dynamic libraries on different platforms, etc.
1 parent d94765b commit a8ac5a8

File tree

1 file changed

+5
-31
lines changed
  • t/lib/MakeMaker/Test/Setup

1 file changed

+5
-31
lines changed

t/lib/MakeMaker/Test/Setup/XS.pm

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -203,43 +203,17 @@ $label2files{eud_consume} = +{
203203
%{ $label2files{basic} }, # make copy
204204
'Makefile.PL' => <<'EOF' .
205205
use File::Spec::Functions;
206-
my $root; BEGIN {$root = catdir(updir, qw(XS-Testeud_produce blib arch));}
206+
my @parts = split /::/, 'XS::Other';
207+
my $libdir = catdir(updir, qw(XS-Testeud_produce blib arch auto), @parts);
208+
my $stem = defined &DynaLoader::mod2fname ? DynaLoader::mod2fname(\@parts) : $parts[-1];
207209
EOF
208210
sprintf(
209211
$MAKEFILEPL, 'Test', 'Test.pm', qq{},
210212
q{
211213
DEFINE => '-DINVAR=input',
212-
LDFROM => join(' ', '$(OBJECT)', map _quote_if_space($_), find_extra_libs({'XS::Other'=>undef}, [$root])),
214+
LIBS => ["-L$libdir -l$stem"],
213215
},
214-
) . <<'EOF',
215-
use Config;
216-
use File::Spec::Functions;
217-
sub _quote_if_space { $_[0] =~ / / ? qq{"$_[0]"} : $_[0] }
218-
my %exts; BEGIN { %exts = (
219-
MSWin32 => [ ".lib", ".$Config{dlext}", $Config{_a} ],
220-
cygwin => [ '.dll' ],
221-
android => [ ".$Config{dlext}" ],
222-
); }
223-
sub find_extra_libs {
224-
my ($deps, $search) = @_;
225-
return () if !keys %$deps;
226-
return () unless my $exts = $exts{$^O};
227-
my @found_libs = ();
228-
DEP: foreach my $name (keys %$deps) {
229-
my @parts = split /::/, $name;
230-
my $stem = defined &DynaLoader::mod2fname
231-
? DynaLoader::mod2fname(\@parts) : $parts[-1];
232-
my @bases = map $stem.$_, @$exts;
233-
for my $dir (grep -d, @$search) { # only extant dirs
234-
my ($found) = grep -f, map catfile($dir, 'auto', @parts, $_), @bases;
235-
next if !defined $found;
236-
push @found_libs, $found;
237-
next DEP;
238-
}
239-
}
240-
@found_libs;
241-
}
242-
EOF
216+
),
243217
'Test.pm' => do {
244218
my $t = $PM_TEST; $t =~ s:is_even:is_odd:g;
245219
$t =~ s/bootstrap/

0 commit comments

Comments
 (0)