nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

xs bootstrap List::MoreUtils #364

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
pcc -v5 -S -e'use List::MoreUtils; all { defined } 1..100;'

 @dl_modules: mro IO Fcntl arybase List::MoreUtils Tie::Hash::NamedCapture
 bootstrapping mro added to XSLoader dl_init
 no dl_init for IO, not bootstrapped
 no dl_init for Fcntl, not bootstrapped
 no dl_init for arybase, not bootstrapped
 no dl_init for List::MoreUtils, not bootstrapped
 no dl_init for Tie::Hash::NamedCapture, not bootstrapped

Original issue reported on code.google.com by reini.urban on 22 Jul 2014 at 4:12

GoogleCodeExporter commented 9 years ago
The problem is more generic:
calling a bootstrap method, like this

bootstrap List::MoreUtils $VERSION

does not mark the module as XS.
Moose has the same problem, just with XSLoader::load 'Moose'. See #350.

Original comment by reini.urban on 22 Jul 2014 at 4:47

GoogleCodeExporter commented 9 years ago
For the beginning we could use the same hack as with Moose.

But then we get a 2nd issue here:
bootstrap List::MoreUtils $VERSION;

List::MoreUtils object version 0.33_005 does not match 
$List::MoreUtils::VERSION 0.33005 at (eval 11) line 68

Need to fix the generated bootstrap args also. 
In this case add the given version as 2nd arg to 

mXPUSHp("List::MoreUtils", 15);
mXPUSHp("/usr/local/lib/perl5/site_perl/5.16.2/x86_64-linux-debug/List/MoreUtils
.pm", 74);
# missing VERSION here
call_pv("XSLoader::load_file", G_VOID|G_DISCARD);

Original comment by reini.urban on 22 Jul 2014 at 4:58

GoogleCodeExporter commented 9 years ago
The detection logic must go like this:
p -MO=Concise,BEGIN -e'use List::MoreUtils; all { defined } 1..100;'

6r                <;> nextstate(List::MoreUtils 131 MoreUtils.pm:36) 
v:*,&,{,x*,x&,x$,$ ->6s
6w                <1> entersub[t8] vKS/TARG,2 ->6x
6s                   <0> pushmark s ->6t
6t                   <$> const(PV "List::MoreUtils") sM/BARE ->6u
-                    <1> ex-rv2sv sKM/3 ->6v
6u                      <$> gvsv(*List::MoreUtils::VERSION) s ->6v
6v                   <$> method_named(PV "bootstrap") ->6w
6x                <;> nextstate(List::MoreUtils 131 MoreUtils.pm:37) 
v:*,&,{,x*,x&,x$,$ ->6y

The const(PV "List::MoreUtils") (which package to bootstrap) could also be a 
gvsv.
All other args here must be added to the bootstrap call later in xs_init.

Original comment by reini.urban on 22 Jul 2014 at 5:06

GoogleCodeExporter commented 9 years ago
I did not go the path to record all args after pushmark until a method_named(PV 
"bootstrap"). I rather used the sane assumption, that all @dl_modules which are 
non-b-c deps need to be bootstrapped, and are xs modules, not pure dynaload 
modules.
BTW: It doesn't harm to xs_init pure dynaloaded modules neither.

New warning message on -v: Assuming xs loaded $stashname 

tested ok correct for Moose and List::MoreUtils.

commit f829c4ae58f29d926d8a517f221ab44a2400a865
Author: Reini Urban <rurban@cpanel.net>
Date:   Tue Jul 22 12:41:03 2014 -0500

    C 1.49_06: generalize xs-loading via bootstrap Module

    remove the special cases for Moose and List::MoreUtils xs loading,
    which is needed if you call  bootstrap Module manually.
    actually boot all non-b-c dependent @dl_modules. we assume XSLoader.

Original comment by reini.urban on 22 Jul 2014 at 5:50