pmqs / DB_File

DB_File - Perl5 access to Berkeley DB version 1.x
7 stars 3 forks source link

Building with gcc12 emits build-time warnings -- but only in Perl 5 blead, not in DB_File's own repo #10

Closed jkeenan closed 2 years ago

jkeenan commented 2 years ago

When compiling Perl 5 blead (here, a threaded build on FreeBSD-12) using gcc12 as the C-compiler, make test_prep emits build-time warnings during compilation of cpan/DB_File/DB_File.xs. But when I use that same perl to build DB_File in a checkout from its own repository, I do not get those warnings.

Here is the relevant part of the output from make test_prep run in Perl 5 blead at commit 765cd54646, using gcc12 on FreeBSD-12 and building with threads:

$ cat DB_File.blead.gcc12.make.output.txt 
./miniperl -Ilib make_ext.pl lib/auto/DB_File/DB_File.so  MAKE="make" LIBPERL_A=libperl.a LINKTYPE=dynamic
Parsing config.in...
Looks Good.
Warning (mostly harmless): No library found for -ldb
Generating a Unix-style Makefile
Writing Makefile for DB_File
Running Mkbootstrap for DB_File ()
chmod 644 "DB_File.bs"
/usr/home/jkeenan/gitwork/perl/cpan/DB_File/../../miniperl "-I../../lib" -MExtUtils::Command::MM -e 'cp_nonempty' -- DB_File.bs ../../lib/auto/DB_File/DB_File.bs 644
gcc12 -c  -I/usr/local/BerkeleyDB/include  -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -O2    -DVERSION=\"1.856\"  -DXS_VERSION=\"1.856\" -DPIC -fPIC "-I../.."  -DmDB_Prefix_t=size_t -DmDB_Hash_t=u_int32_t version.c
"../../miniperl" "-I../../lib" "../../lib/ExtUtils/xsubpp" -noprototypes -typemap '/usr/home/jkeenan/gitwork/perl/cpan/DB_File/../../lib/ExtUtils/typemap' -typemap '/usr/home/jkeenan/gitwork/perl/cpan/DB_File/typemap'  DB_File.xs > DB_File.xsc
mv DB_File.xsc DB_File.c
gcc12 -c  -I/usr/local/BerkeleyDB/include  -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -Wall -Werror=pointer-arith -Werror=vla -Wextra -Wno-long-long -Wno-declaration-after-statement -Wc++-compat -Wwrite-strings -O2    -DVERSION=\"1.856\"  -DXS_VERSION=\"1.856\" -DPIC -fPIC "-I../.."  -DmDB_Prefix_t=size_t -DmDB_Hash_t=u_int32_t DB_File.c
DB_File.xs: In function 'ParseOpenInfo':
DB_File.xs:476:44: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  476 |         if (RETVAL->dbp) err_close(RETVAL) ;                           \
      |                                            ^
DB_File.xs:1044:13: note: in expansion of macro 'croak_and_free'
 1044 |             croak_and_free("type parameter is not a reference") ;
      |             ^~~~~~~~~~~~~~
DB_File.xs:476:44: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  476 |         if (RETVAL->dbp) err_close(RETVAL) ;                           \
      |                                            ^
DB_File.xs:1050:13: note: in expansion of macro 'croak_and_free'
 1050 |             croak_and_free("internal error") ;
      |             ^~~~~~~~~~~~~~
DB_File.xs:476:44: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  476 |         if (RETVAL->dbp) err_close(RETVAL) ;                           \
      |                                            ^
DB_File.xs:1056:17: note: in expansion of macro 'croak_and_free'
 1056 |                 croak_and_free("DB_File can only tie an associative array to a DB_HASH database") ;
      |                 ^~~~~~~~~~~~~~
DB_File.xs:476:44: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  476 |         if (RETVAL->dbp) err_close(RETVAL) ;                           \
      |                                            ^
DB_File.xs:1091:17: note: in expansion of macro 'croak_and_free'
 1091 |                 croak_and_free("DB_File can only tie an associative array to a DB_BTREE database");
      |                 ^~~~~~~~~~~~~~
DB_File.xs:476:44: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  476 |         if (RETVAL->dbp) err_close(RETVAL) ;                           \
      |                                            ^
DB_File.xs:1140:17: note: in expansion of macro 'croak_and_free'
 1140 |                 croak_and_free("DB_File can only tie an array to a DB_RECNO database");
      |                 ^~~~~~~~~~~~~~
DB_File.xs:476:44: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
  476 |         if (RETVAL->dbp) err_close(RETVAL) ;                           \
      |                                            ^
DB_File.xs:1229:13: note: in expansion of macro 'croak_and_free'
 1229 |             croak_and_free("type is not of type DB_File::HASHINFO, DB_File::BTREEINFO or DB_File::RECNOINFO");
      |             ^~~~~~~~~~~~~~
rm -f ../../lib/auto/DB_File/DB_File.so
gcc12  -shared  -L/usr/local/lib -fstack-protector-strong  version.o DB_File.o  -o ../../lib/auto/DB_File/DB_File.so        
chmod 755 ../../lib/auto/DB_File/DB_File.so

Now here is the output of DB_File's make run with that gcc12-compiled, threaded perl on the same machine.

$ cat 0a1c14ff3e.DB_File.make.output.txt
cp DB_File.pm blib/lib/DB_File.pm
Running Mkbootstrap for DB_File ()
chmod 644 "DB_File.bs"
"/usr/home/jkeenan/testing/alt/blead/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- DB_File.bs blib/arch/auto/DB_File/DB_File.bs 644
gcc12 -c  -I/usr/local/BerkeleyDB/include  -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -O2    -DVERSION=\"1.856\"  -DXS_VERSION=\"1.856\" -DPIC -fPIC "-I/home/jkeenan/testing/alt/blead/lib/perl5/5.35.10/amd64-freebsd-thread-multi/CORE"  -D_NOT_CORE  -DmDB_Prefix_t=size_t -DmDB_Hash_t=u_int32_t version.c
"/usr/home/jkeenan/testing/alt/blead/bin/perl" "/home/jkeenan/testing/alt/blead/lib/perl5/5.35.10/ExtUtils/xsubpp" -noprototypes -typemap '/home/jkeenan/testing/alt/blead/lib/perl5/5.35.10/ExtUtils/typemap' -typemap '/usr/home/jkeenan/gitwork/zzzothers/DB_File/typemap'  DB_File.xs > DB_File.xsc
mv DB_File.xsc DB_File.c
gcc12 -c  -I/usr/local/BerkeleyDB/include  -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_FORTIFY_SOURCE=2 -O2    -DVERSION=\"1.856\"  -DXS_VERSION=\"1.856\" -DPIC -fPIC "-I/home/jkeenan/testing/alt/blead/lib/perl5/5.35.10/amd64-freebsd-thread-multi/CORE"  -D_NOT_CORE  -DmDB_Prefix_t=size_t -DmDB_Hash_t=u_int32_t DB_File.c
rm -f blib/arch/auto/DB_File/DB_File.so
gcc12  -shared  -L/usr/local/lib -fstack-protector-strong  version.o DB_File.o  -o blib/arch/auto/DB_File/DB_File.so        
chmod 755 blib/arch/auto/DB_File/DB_File.so

I always like to eliminate build-time warnings from Perl 5's make as much as possible. If I apply the following patch to Perl 5 blead, those warnings are eliminated:

diff --git a/cpan/DB_File/DB_File.xs b/cpan/DB_File/DB_File.xs
index d0ed44379f..1dde57d52f 100644
--- a/cpan/DB_File/DB_File.xs
+++ b/cpan/DB_File/DB_File.xs
@@ -473,7 +473,7 @@ typedef DBT DBTKEY ;
 #define croak_and_free(x)                                             \
     do                                                                \
     {                                                                 \
-        if (RETVAL->dbp) err_close(RETVAL) ;                           \
+        if (RETVAL->dbp) { err_close(RETVAL) ; }                      \
         Safefree(RETVAL);                                             \
         croak(x);                                                     \
     } while (0)

... and perl builds and tests successfully, as in this smoke-me branch.

But I concede that I find the absence of build-time warnings when I build in DB_File's own repository surprising.

pmqs commented 2 years ago

Thanks for the patch James. Very strange that this is only present in blead and not when built with my modules stand-alone. Don't have gcc12 available yet to test it myself, so can't verify.

regardless, patch is applied.

jkeenan commented 2 years ago

On 2/25/22 17:28, Paul Marquess wrote:

Thanks for the patch James. Very strange that this is only present in blead and not when built with my modules stand-alone. Don't have gcc12 available yet to test it myself, so can't verify.

regardless, patch is applied.

Thanks. Can you just ping me when you get around to a new CPAN release, so that I can synch it into blead?

Thank you very much. Jim Keenan

pmqs commented 2 years ago

just uploaded DB_File 1.587 to CPAN

jkeenan commented 2 years ago

On 2/25/22 17:48, Paul Marquess wrote:

just uploaded DB_File 1.587 to CPAN

Thanks. I'll let CPANtesters have at it for several days, then synch it.