The usual pattern for optional-XS modules is to have one dist that is the pure-perl implementation and another dist that overrides the first with some XS speedups.

This works, but often people list the pure-perl module as a dependency and then sometimes the XS one doesn't get installed for the average end-user, letting them suffer with low performance not realizing they could speed it up with an additional module.

Has anyone explored the possibility of packaging the XS and PP together in the same dist so that the XS is compiled and installed iff a C compiler is available? Or even better, skips installing the XS if it fails to compile and install for any reason?

I was toying with the idea, and thought a quick way to get there without a bunch of Makefile.pm shenanigans would be if I create a normal XS dist and then include that as a subdirectory of the PP dist. Then I just start a subshell to run the nomal make process in that subdirectory, and if it fails, I ignore it and continue installing and testing the PP module.

Does anyone see any problems with that? Had this been solved better ways by other modules I could look at as an example?


In reply to How to author a module with optional XS by NERDVANA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.