in reply to How to know if a CPAN module uses XS

I just scan the MANIFEST (in the source distro) for a '.xs' file. Presence of one means that compiling is reqired; absence means no compilation is required.

However, whilst this is a fairly reliable method, it's not foolproof. For example, PDL::NetCDF has no xs file yet requires compilation. (The 'perl Makefile.PL' step generates the xs file.) And I think there are some modules that, while providing an xs file, also cater for a pure-perl build.

Perhaps some of the other monks know of a smarter approach.

Cheers,
Rob
  • Comment on Re: How to know if a CPAN module uses XS

Replies are listed 'Best First'.
Re^2: How to know if a CPAN module uses XS
by tobyink (Canon) on Jun 20, 2012 at 06:54 UTC

    Another heuristic is to look for use DynaLoader or use XSLoader in any of the modules.

    XS code also often comes with a file called typemap which is used by the XS build system to map between Perl data structures and C data structures.

    And ppport.h is often bundled. This is a C header file which, as I understand it, smooths over the differences between versions of the Perl API.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re^2: How to know if a CPAN module uses XS
by etj (Priest) on May 23, 2022 at 20:18 UTC
    (The 'perl Makefile.PL' step generates the xs file.)
    It does not. The Makefile thereby generated has a rule that turns the supplied .pd file into .pm and .xs files, and for distributions that have "opted in" and with a PDL 2.058+, a .c file per operation (allowing parallel builds).

    Probably the best heuristic to spot a PDL distro that generates XS rather than being a pure-Perl user of other PDL modules is the use of PDL::Core::Dev, and/or calls to pdlpp_stdargs.