timbunce / devel-nytprof

Devel::NYTProf is a powerful feature-rich source code profiler for Perl. (Mostly in maintenance mode, so PRs are much more likely to be acted upon than Issues.)
http://blog.timbunce.org/tag/nytprof/
67 stars 50 forks source link

Don't request 'bad-function-cast' warnings during 'make' #204

Closed jkeenan closed 9 months ago

jkeenan commented 1 year ago

In May 2021 I applied a patch to the Devel-NYTProf distribution originally contributed by @rurban in 2017.

$ gitshowf b1821179 |cat
commit b1821179028dc5a76d65b60a18143fba018fd49e
Author:     Reini Urban <rurban@cpan.org>
AuthorDate: Sun Jun 18 20:32:34 2017 +0200
Commit:     James E Keenan <jkeenan@cpan.org>
CommitDate: Fri May 7 01:18:19 2021 +0000

    c++ -fpermissive compat

    Signed-off-by: James E Keenan <jkeenan@cpan.org>

    This eliminates two 'cc1plus:' warnings when compiling NYTProf with g++.

diff --git a/Makefile.PL b/Makefile.PL
index 4b63f54..1da9a03 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -162,7 +162,8 @@ $mm_opts{PREREQ_PM} = {
 if (my $gccversion = $Config{gccversion}) {    # ask gcc to be more pedantic
     print "Your perl was compiled with gcc (version $Config{gccversion}), okay.\n";
     $gccversion =~ s/[^\d\.]//g;               # just a number please
-    $mm_opts{DEFINE} .= ' -W -Wall -Wpointer-arith -Wbad-function-cast';
+    $mm_opts{DEFINE} .= ' -W -Wall -Wpointer-arith';
+    $mm_opts{DEFINE} .= ' -Wbad-function-cast' unless $Config{d_cplusplus};
     $mm_opts{DEFINE} .= ' -Wno-comment -Wno-sign-compare -Wno-cast-qual';
     $mm_opts{DEFINE} .= ' -Wmissing-noreturn -Wno-unused-parameter' if $gccversion ge "3.0";
     if ($is_developer && $opt_g) {

However, when I compile our master branch with gcc (or, for that matter, with clang), I get a lot of these -Wbad-function-cast warnings -- but all of them originate in the Perl core distribution's source code (specifically, handy.h) rather than from any code in the Devel-NYTProf distribution (such as NYTP.xs).

$ parse-build-warnings 5993c69690.linux.gcc9.make.output.txt | grep 'source =>'
    source => "/home/jkeenan/perl5/perlbrew/perls/perl-5.36.0/lib/5.36.0/x86_64-linux/CORE/handy.h",
...

$ parse-build-warnings 5993c69690.linux.gcc9.make.output.txt | grep 'source =>.*handy\.h' | wc -l
22

Recently I had to do a lot of work debugging an instance where a change in the Perl core distribution triggered test failures in Devel-NYTProf. I repeatedly had to recompile Devel::NYTProf, and I found these 22 warnings to be a big distraction. Since they're not caused by Devel-NYTProf, I don't think we should be searching them out.

I recommend we remove the statement in Makefile.PL requesting -Wbad-function-call warnings during `make'. I will submit a pull request for that purpose.

@timbunce, thoughts?

jkeenan commented 9 months ago

Fixed by https://github.com/timbunce/devel-nytprof/pull/205. Closing ticket.