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 }
In reply to Check compiler features before building XS module by jdv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |