jdv has asked for the wisdom of the Perl Monks concerning the following question:
Based on CPAN Testers reports, I see that an XS-based module I just uploaded is failing (actually, "UNKNOWN" status) on some platforms because of unsupported compiler options or missing libraries. Specifically, the C++ library being bound requires support for C++11 and POSIX threads during compilation. I think it would be better to specifically check for this in the Build.PL script and give a more informative error message before exiting cleanly (i.e. test ignored, the same result as for other types of platform incompatibility).
What I am thinking of is adding something like this to the top of Build.PL:
My question is whether there is a better or more standardized way of doing this testing. I'm aware of Devel::CheckLib which could be used to check for pthreads but not for C++11 support (that I know). Thanks for any advice.use File::Temp qw/tempfile/; my ($fh_1, $fn_1) = tempfile('cXXXX', SUFFIX=>'.cpp', UNLINK => 1); my ($fh_2, $fn_2) = tempfile('oXXXX', SUFFIX=>'.out', UNLINK => 1); print {$fh_1} "int main() {}\n"; close $fh_1; if( system("cc -o $fn_2 --std=c++11 -lpthread $fn_1") ) { warn "Unsupported compiler or missing library (must be C+11 complian +t and have POSIX thread support)\n"; exit(0); # will be ignored by CPAN Testers as having unmet dependenc +ies }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Check compiler features before building XS module
by Anonymous Monk on Jan 04, 2016 at 19:03 UTC | |
by jdv (Sexton) on Jan 04, 2016 at 19:36 UTC | |
by Anonymous Monk on Jan 04, 2016 at 20:33 UTC | |
by jdv (Sexton) on Jan 04, 2016 at 21:24 UTC | |
by Anonymous Monk on Jan 04, 2016 at 21:39 UTC |