I think the first difficulty (not necessarily a show-stopper) I see with that approach is that it relies on WriteMakefile() being run. However, some Makefile.PL's may abort prior to that happening - eg because $] is too low, or because $^O is inappropriate, or because some pre-requisite could not be found.
Handle that, and you're probably on a winner. It may even be that if $] is too low or $^O is inappropriate, then you don't even need to know whether the module needs to be compiled ... and if the Makefile.PL aborts because a pre-requisite C library can't be found, then it should be safe to assume it's a module that needs compiling. But if the Makefile.PL aborts because a pre-requisite perl module could not be found, then all bets are off. (I've a notion that there are some modules that do that, though I can't provide an example.)
then do backticks on your make tool running in "list commands and do not execute" mode
And then there's Inline/Inline::C ... run make in "list commands and do not execute" mode when building Inline/Inline::C and you'll see no mention of any compiler. (But perhaps that's the right result anyway ... not sure about that one.)
And, of course, not every distro has a Makefile.PL - and there's presumably a need to handle them, too. (That's the beauty of having a choice of 2 build systems - instead of solving a problem once, you get the added joy of having to solve it twice :-)
Cheers, Rob
Comment on Re^2: How to know if a CPAN module uses XS
Hooking WriteMakefile wouldn't work on Module::Build, and it wouldn't work for a makefile.pl that gets $Config{cc} and runs the compiler itself. As said elsewhere in this thread, searching the source code for Dynaloader is another choice, even for this post Pure Perl module(246 lines, Linux/Win32) that calls external libraries - no XS file.. Then again "Dynaloader" as a string can be obfuscated.