From: Nicholas Clark Date: Tue, 23 Sep 2008 13:48:10 +0000 (+0000) Subject: defined %{$package.'::'} isn't good enough to tell whether a module is X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f667a15aba5fcf07ed08e48e2bfdf0b62d76a3aa;p=p5sagit%2Fp5-mst-13.2.git defined %{$package.'::'} isn't good enough to tell whether a module is loaded when it's XS and staticly linked to perl. p4raw-id: //depot/perl@34409 --- diff --git a/ext/B/B/Concise.pm b/ext/B/B/Concise.pm index 7ddf1d7..284f797 100644 --- a/ext/B/B/Concise.pm +++ b/ext/B/B/Concise.pm @@ -14,7 +14,7 @@ use warnings; # uses #3 and #4, since warnings uses Carp use Exporter (); # use #5 -our $VERSION = "0.75"; +our $VERSION = "0.76"; our @ISA = qw(Exporter); our @EXPORT_OK = qw( set_style set_style_standard add_callback concise_subref concise_cv concise_main @@ -299,7 +299,18 @@ sub compileOpts { elsif ($o =~ /^-stash=(.*)/) { my $pkg = $1; no strict 'refs'; - eval "require $pkg" unless defined %{$pkg.'::'}; + if (!defined %{$pkg.'::'}) { + eval "require $pkg"; + } else { + require Config; + if (!$Config::Config{usedl} + && keys %{$pkg.'::'} == 1 + && $pkg->can('bootstrap')) { + # It is something that we're staticly linked to, but hasn't + # yet been used. + eval "require $pkg"; + } + } push @render_packs, $pkg; } # line-style options diff --git a/ext/B/t/concise.t b/ext/B/t/concise.t index 7b4df88..5cd5543 100644 --- a/ext/B/t/concise.t +++ b/ext/B/t/concise.t @@ -416,11 +416,8 @@ like($out, qr/FUNC: \*ExtUtils::Mksymlists::_write_vms/, $out = runperl ( switches => ["-MO=Concise,-stash=Data::Dumper,-src,-exec"], prog => '-e 1', stderr => 1 ); -{ - local $TODO = q(require $package unless ${$package.'::'}; doesn't do what you want under static linking) unless $Config{usedl}; - like($out, qr/FUNC: \*Data::Dumper::format_refaddr/, - "stash rendering loads package as needed"); -} +like($out, qr/FUNC: \*Data::Dumper::format_refaddr/, + "stash rendering loads package as needed"); my $prog = q{package FOO; sub bar { print "bar" } package main; FOO::bar(); };