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 51 forks source link

Build-time warnings #145

Closed jkeenan closed 3 years ago

jkeenan commented 3 years ago

While looking into Devel-NYTProf's test failures on bleadperl today, I observed these build-time warnings generated during make using Clang 10.0.1 as the C-compiler on FreeBSD-12.

$ bleadperl Makefile.PL && make && make -j4 test
Looking for header files and functions...
Found clock_gettime in time.h
Found deflateInit2 in zlib.h
Assertion testing enabled
Your perl was compiled with gcc (version FreeBSD Clang 10.0.1 (git@github.com:llvm/llvm-project.git llvmorg-10.0.1-0-gef32c611aa2)), okay.

[snip]

Running Mkbootstrap for NYTProf ()
chmod 644 "NYTProf.bs"
"/usr/home/jkeenan/testing/blead/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- NYTProf.bs blib/arch/auto/Devel/NYTProf/NYTProf.bs 644
"/usr/home/jkeenan/testing/blead/bin/perl" "/home/jkeenan/testing/blead/lib/perl5/5.33.9/ExtUtils/xsubpp"  -typemap '/home/jkeenan/testing/blead/lib/perl5/5.33.9/ExtUtils/typemap' -typemap '/usr/home/jkeenan/gitwork/zzzothers/devel-nytprof/typemap'  FileHandle.xs > FileHandle.xsc
mv FileHandle.xsc FileHandle.c
cc -c    -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -O2 -pipe -fstack-protector -fno-strict-aliasing    -DVERSION=\"6.06\"  -DXS_VERSION=\"6.06\" -DPIC -fPIC "-I/home/jkeenan/testing/blead/lib/perl5/5.33.9/amd64-freebsd-thread-multi/CORE"  -DHAS_CLOCK_GETTIME -DHAS_ZLIB -DUSE_HARD_ASSERT -W -Wall -Wpointer-arith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual FileHandle.c
In file included from FileHandle.xs:24:
./ppport.h:4594:11: warning: 'WIDEST_UTYPE' macro redefined [-Wmacro-redefined]
#  define WIDEST_UTYPE U64TYPE
          ^
/home/jkeenan/testing/blead/lib/perl5/5.33.9/amd64-freebsd-thread-multi/CORE/handy.h:1382:12: note: 
      previous definition is here
#   define WIDEST_UTYPE U64
           ^
1 warning generated.
"/usr/home/jkeenan/testing/blead/bin/perl" "/home/jkeenan/testing/blead/lib/perl5/5.33.9/ExtUtils/xsubpp"  -typemap '/home/jkeenan/testing/blead/lib/perl5/5.33.9/ExtUtils/typemap' -typemap '/usr/home/jkeenan/gitwork/zzzothers/devel-nytprof/typemap'  NYTProf.xs > NYTProf.xsc
mv NYTProf.xsc NYTProf.c
cc -c    -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -O2 -pipe -fstack-protector -fno-strict-aliasing    -DVERSION=\"6.06\"  -DXS_VERSION=\"6.06\" -DPIC -fPIC "-I/home/jkeenan/testing/blead/lib/perl5/5.33.9/amd64-freebsd-thread-multi/CORE"  -DHAS_CLOCK_GETTIME -DHAS_ZLIB -DUSE_HARD_ASSERT -W -Wall -Wpointer-arith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual NYTProf.c
In file included from NYTProf.xs:36:
./ppport.h:4594:11: warning: 'WIDEST_UTYPE' macro redefined [-Wmacro-redefined]
#  define WIDEST_UTYPE U64TYPE
          ^
/home/jkeenan/testing/blead/lib/perl5/5.33.9/amd64-freebsd-thread-multi/CORE/handy.h:1382:12: note: 
      previous definition is here
#   define WIDEST_UTYPE U64
           ^
NYTProf.xs:3999:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:3985:69: note: parameter of type 'const nytp_tax_index' is declared here
load_time_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                    ^
NYTProf.xs:4076:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4060:72: note: parameter of type 'const nytp_tax_index' is declared here
load_new_fid_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                       ^
NYTProf.xs:4166:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4156:73: note: parameter of type 'const nytp_tax_index' is declared here
load_src_line_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                        ^
NYTProf.xs:4206:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4191:73: note: parameter of type 'const nytp_tax_index' is declared here
load_sub_info_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                        ^
NYTProf.xs:4275:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4256:76: note: parameter of type 'const nytp_tax_index' is declared here
load_sub_callers_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                           ^
NYTProf.xs:4402:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4391:74: note: parameter of type 'const nytp_tax_index' is declared here
load_pid_start_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                         ^
NYTProf.xs:4433:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4423:72: note: parameter of type 'const nytp_tax_index' is declared here
load_pid_end_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                       ^
NYTProf.xs:4471:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4459:74: note: parameter of type 'const nytp_tax_index' is declared here
load_attribute_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                         ^
NYTProf.xs:4503:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4490:71: note: parameter of type 'const nytp_tax_index' is declared here
load_option_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                      ^
NYTProf.xs:4579:20: warning: passing an object that undergoes default argument promotion to
      'va_start' has undefined behavior [-Wvarargs]
    va_start(args, tag);
                   ^
NYTProf.xs:4551:69: note: parameter of type 'const nytp_tax_index' is declared here
load_perl_callback(Loader_state_base *cb_data, const nytp_tax_index tag, ...)
                                                                    ^
NYTProf.xs:1220:1: warning: unused function 'get_str_id' [-Wunused-function]
get_str_id(pTHX_ char* str, STRLEN len)
^
12 warnings generated.

[snip]

I doubt these warnings are directly related to the test failures. However, if they could be cleaned up in the course of other updating of Devel-NYTProf, that would be nice.

Thank you very much.

jkeenan commented 3 years ago

NYTProf.xs:1220:1: warning: unused function 'get_str_id' [-Wunused-function] get_strid(pTHX char* str, STRLEN len) ^ [snip]

I note that in NYTProf.xs, the definition of get_str_id is prefaced with this comment:

/**
 * Return a unique persistent id number for a string.
 *
 * XXX Currently not used, so may trigger compiler warnings, but is intended to be
 * used to assign ids to strings like subroutine names like we do for file ids.
 */
jkeenan commented 3 years ago

This problem is partially alleviated by https://github.com/timbunce/devel-nytprof/pull/157 committed to master last night. What remains: (1) function unused warning being emitted by each of the 3 C-compilers I've tried (clang-10, gcc-9, g++-9); and (2) other g++ warnings which I'll detail in a subsequent post.

As to (1): This may be addressed by simply removing this unused function from NYTProf.xs. I'm thinking of creating a directory in the distribution simply to hold code that we've deleted. Such a directory would at least enable downstream users who might have used undocumented or untested code to locate the code if they really want to use it or want us to officially support it.

As to (2): Some patches from https://github.com/timbunce/devel-nytprof/pull/134 will address some of the g++ warnings, but my preliminary investigation suggests there might still be a few to work on.

Thank you very much. Jim Keenan

jkeenan commented 3 years ago

CPAN release 6.08 eliminates the build-time warnings we've observed on Linux, FreeBSD, OpenBSD and Windows. So this ticket is now closable.