Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd warning in simple XSub (-Dusequadmath builds only) #17128

Closed
p5pRT opened this issue Aug 15, 2019 · 16 comments
Closed

Odd warning in simple XSub (-Dusequadmath builds only) #17128

p5pRT opened this issue Aug 15, 2019 · 16 comments
Assignees
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 Closable? We might be able to close this ticket, but we need to check with the reporter

Comments

@p5pRT
Copy link

p5pRT commented Aug 15, 2019

Migrated from rt.perl.org#134363 (status was 'open')

Searchable as RT134363$

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

From @sisyphus

Hi,

The Inline​::C demo script​:

#####################
use warnings;
use Devel​::Peek;
use Inline C => Config =>
BUILD_NOISY => 1,
USING => 'ParseRegExp',
;
use Inline C => <<'EOC';
void foo(NV val) {
  printf("%.15" NVgf, val);
}
EOC
foo(sqrt(3));
#####################

On my -Dusequadmath build of perl-5.30.0 I get the following warning during
the compilation stage​:

try_pl_0ea3.xs​: In function ‘foo’​:
try_pl_0ea3.xs​:7​:10​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
  printf("%.15" NVgf, val);
  ^~~~~~
try_pl_0ea3.xs​:7​:10​: warning​: too many arguments for format
[-Wformat-extra-arg ]

Upon compilation the script then runs successfully.

I noticed the same warning building Scalar-List-Utils-1.51 on the same
build of perl.
In that instance it was triggered by identical formatting in ListUtil.xs

The same code compiles without warning on non-quadmath builds of perl-5.30.0

Cheers,
Rob

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

From @jkeenan

On Thu, 15 Aug 2019 05​:21​:56 GMT, sisyphus359@​gmail.com wrote​:

Hi,

The Inline​::C demo script​:

#####################
use warnings;
use Devel​::Peek;
use Inline C => Config =>
BUILD_NOISY => 1,
USING => 'ParseRegExp',
;
use Inline C => <<'EOC';
void foo(NV val) {
printf("%.15" NVgf, val);
}
EOC
foo(sqrt(3));
#####################

On my -Dusequadmath build of perl-5.30.0 I get the following warning during
the compilation stage​:

try_pl_0ea3.xs​: In function ‘foo’​:
try_pl_0ea3.xs​:7​:10​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
printf("%.15" NVgf, val);
^~~~~~
try_pl_0ea3.xs​:7​:10​: warning​: too many arguments for format
[-Wformat-extra-arg ]

Upon compilation the script then runs successfully.

I noticed the same warning building Scalar-List-Utils-1.51 on the same
build of perl.
In that instance it was triggered by identical formatting in ListUtil.xs

The same code compiles without warning on non-quadmath builds of perl-5.30.0

Cheers,
Rob

Confirmed. Attached output is from 'make' within a git checkout of the Scalar-List-Utils distribution. The perl used to call 'perl Makefile.PL' was configured as '-des -Dusedevel -Dusequadmath'.

Thank you very much.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

From @jkeenan

$ make
cp lib/Sub/Util.pm blib/lib/Sub/Util.pm
cp lib/List/Util.pm blib/lib/List/Util.pm
cp lib/List/Util/XS.pm blib/lib/List/Util/XS.pm
cp lib/Scalar/Util.pm blib/lib/Scalar/Util.pm
Running Mkbootstrap for Util ()
chmod 644 "Util.bs"
"/home/jkeenan/testing/blead/bin/perl" -MExtUtils​::Command​::MM -e 'cp_nonempty' -- Util.bs blib/arch/auto/List/Util/Util.bs 644
"/home/jkeenan/testing/blead/bin/perl" "/home/jkeenan/testing/blead/lib/perl5/5.31.3/ExtUtils/xsubpp" -typemap '/home/jkeenan/testing/blead/lib/perl5/5.31.3/ExtUtils/typemap' ListUtil.xs > ListUtil.xsc
mv ListUtil.xsc ListUtil.c
cc -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"1.51\" -DXS_VERSION=\"1.51\" -fPIC "-I/home/jkeenan/testing/blead/lib/perl5/5.31.3/x86_64-linux-quadmath/CORE" -DPERL_EXT -DUSE_PPPORT_H ListUtil.c
ListUtil.xs​: In function ‘XS_List__Util_uniq’​:
ListUtil.xs​:1193​:34​: warning​: unknown conversion type character ‘Q’ in format [-Wformat=]
  sv_setpvf(keysv, "%.15" NVgf, SvNV(arg));
  ^~~~~~
ListUtil.xs​:1193​:34​: warning​: too many arguments for format [-Wformat-extra-args]
rm -f blib/arch/auto/List/Util/Util.so
cc -shared -O2 -L/usr/local/lib -fstack-protector-strong ListUtil.o -o blib/arch/auto/List/Util/Util.so \
  \
 
chmod 755 blib/arch/auto/List/Util/Util.so

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 15, 2019

From @jkeenan

On 8/15/19 9​:37 AM, James E Keenan via RT wrote​:

On Thu, 15 Aug 2019 05​:21​:56 GMT, sisyphus359@​gmail.com wrote​:

Hi,

The Inline​::C demo script​:

#####################
use warnings;
use Devel​::Peek;
use Inline C => Config =>
BUILD_NOISY => 1,
USING => 'ParseRegExp',
;
use Inline C => <<'EOC';
void foo(NV val) {
printf("%.15" NVgf, val);
}
EOC
foo(sqrt(3));
#####################

On my -Dusequadmath build of perl-5.30.0 I get the following warning during
the compilation stage​:

try_pl_0ea3.xs​: In function ‘foo’​:
try_pl_0ea3.xs​:7​:10​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
printf("%.15" NVgf, val);
^~~~~~
try_pl_0ea3.xs​:7​:10​: warning​: too many arguments for format
[-Wformat-extra-arg ]

Upon compilation the script then runs successfully.

I noticed the same warning building Scalar-List-Utils-1.51 on the same
build of perl.
In that instance it was triggered by identical formatting in ListUtil.xs

The same code compiles without warning on non-quadmath builds of perl-5.30.0

Cheers,
Rob

Confirmed. Attached output is from 'make' within a git checkout of the Scalar-List-Utils distribution. The perl used to call 'perl Makefile.PL' was configured as '-des -Dusedevel -Dusequadmath'.

Curiously, I do *not* get that warning when I build a perl on linux with
-Dusequadmath and examine the output of 'make' while Scalar-List-Utils
is compiled -- even though that's the same $VERSION as the checkout.

@p5pRT
Copy link
Author

p5pRT commented Aug 16, 2019

From @sisyphus

On Fri, Aug 16, 2019 at 2​:19 AM James E Keenan <jkeenan@​pobox.com> wrote​:

Curiously, I do *not* get that warning when I build a perl on linux with
-Dusequadmath and examine the output of 'make' while Scalar-List-Utils is
compiled -- even though that's the same $VERSION as the checkout.

That's quite strange, indeed. Here's what I see​:

ListUtil.xs​: In function ‘XS_List__Util_uniq’​:
ListUtil.xs​:1188​:34​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
  sv_setpvf(keysv, "%.15" NVgf, SvNV(arg));
  ^~~~~~
ListUtil.xs​:1188​:34​: warning​: too many arguments for format
[-Wformat-extra-arg ]

Can you check that you were attempting to build the same version (1.51) of
Scalar-List-Utils as I was, and also that line 1188 of ListUtil.xs is as
quoted in that warning.

I can only think that you must have been building Scalar-List-Utils from a
different source.
If that's not the case, could you post the full output of your build.

As regards my build of perl-5.30.0​:
$ perl -V​:config_args
config_args='-des -Duse64bitall -Dprefix=/home/sisyphus/perl-5.30.0-q
-Dusequadmath';

(I'm also seeing the same on perl-5.31.2, built with '-des -Duse64bitall
-Uversiononly -Dusedevel -Dprefix=/home/sisyphus/blead-5.31.2-q
-Dusequadmath'.)

Cheers,
Rob

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2019

From @tonycoz

On Wed, 14 Aug 2019 22​:21​:56 -0700, sisyphus359@​gmail.com wrote​:

Hi,

The Inline​::C demo script​:

#####################
use warnings;
use Devel​::Peek;
use Inline C => Config =>
BUILD_NOISY => 1,
USING => 'ParseRegExp',
;
use Inline C => <<'EOC';
void foo(NV val) {
printf("%.15" NVgf, val);
}
EOC
foo(sqrt(3));
#####################

On my -Dusequadmath build of perl-5.30.0 I get the following warning during
the compilation stage​:

try_pl_0ea3.xs​: In function ‘foo’​:
try_pl_0ea3.xs​:7​:10​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
printf("%.15" NVgf, val);
^~~~~~
try_pl_0ea3.xs​:7​:10​: warning​: too many arguments for format
[-Wformat-extra-arg ]

Upon compilation the script then runs successfully.

I noticed the same warning building Scalar-List-Utils-1.51 on the same
build of perl.
In that instance it was triggered by identical formatting in ListUtil.xs

The same code compiles without warning on non-quadmath builds of perl-5.30.0

Which operating system? Which compiler?

Please include perl -V output when you report issues.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2019

From @sisyphus

OS is Ubuntu-18.04, current compiler is gcc-7.4.0.
I can't find a -Dusequadmath build on the system that doesn't issue the
warning.
I've tested​:
(v5.31.2) built for x86_64-linux-quadmath
(v5.30.0) built for x86_64-linux-quadmath
(v5.28.0) built for x86_64-linux-quadmath
(v5.26.0) built for x86_64-linux-thread-multi-quadmath
(v5.24.0) built for x86_64-linux-thread-multi-quadmath
(v5.22.0) built for x86_64-linux-thread-multi-quadmath

Here's perl -V for 5.31.2

$ perl -V
Summary of my perl5 (revision 5 version 31 subversion 2) configuration​:
  Platform​:
  osname=linux
  osvers=4.15.0-54-generic
  archname=x86_64-linux-quadmath
  uname='linux sisyphus5-desktop 4.15.0-54-generic #58-ubuntu smp mon jun
24 10​:55​:24 utc 2019 x86_64 x86_64 x86_64 gnulinux '
  config_args='-des -Duse64bitall -Uversiononly -Dusedevel
-Dprefix=/home/sisyphus/blead-5.31.2-q -Dusequadmath'
  hint=recommended
  useposix=true
  d_sigaction=define
  useithreads=undef
  usemultiplicity=undef
  use64bitint=define
  use64bitall=define
  uselongdouble=undef
  usemymalloc=n
  default_inc_excludes_dot=define
  bincompat5005=undef
  Compiler​:
  cc='cc'
  ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
  optimize='-O2'
  cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong
-I/usr/local/include'
  ccversion=''
  gccversion='7.4.0'
  gccosandvers=''
  intsize=4
  longsize=8
  ptrsize=8
  doublesize=8
  byteorder=12345678
  doublekind=3
  d_longlong=define
  longlongsize=8
  d_longdbl=define
  longdblsize=16
  longdblkind=3
  ivtype='long'
  ivsize=8
  nvtype='__float128'
  nvsize=16
  Off_t='off_t'
  lseeksize=8
  alignbytes=16
  prototype=define
  Linker and Libraries​:
  ld='cc'
  ldflags =' -fstack-protector-strong -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib
/usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
  libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc -lquadmath
  perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc -lquadmath
  libc=libc-2.27.so
  so=so
  useshrplib=false
  libperl=libperl.a
  gnulibc_version='2.27'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs
  dlext=so
  d_dlsymun=undef
  ccdlflags='-Wl,-E'
  cccdlflags='-fPIC'
  lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl)​:
  Compile-time options​:
  HAS_TIMES
  PERLIO_LAYERS
  PERL_COPY_ON_WRITE
  PERL_DONT_CREATE_GVSV
  PERL_MALLOC_WRAP
  PERL_OP_PARENT
  PERL_PRESERVE_IVUV
  PERL_USE_DEVEL
  USE_64_BIT_ALL
  USE_64_BIT_INT
  USE_LARGE_FILES
  USE_LOCALE
  USE_LOCALE_COLLATE
  USE_LOCALE_CTYPE
  USE_LOCALE_NUMERIC
  USE_LOCALE_TIME
  USE_PERLIO
  USE_PERL_ATOF
  USE_QUADMATH
  Built under linux
  Compiled at Jul 21 2019 10​:46​:59
  @​INC​:

/home/sisyphus/blead-5.31.2-q/lib/perl5/site_perl/5.31.2/x86_64-linux-quadmath
  /home/sisyphus/blead-5.31.2-q/lib/perl5/site_perl/5.31.2
  /home/sisyphus/blead-5.31.2-q/lib/perl5/5.31.2/x86_64-linux-quadmath
  /home/sisyphus/blead-5.31.2-q/lib/perl5/5.31.2

Cheers,
Rob

On Tue, Aug 20, 2019 at 4​:05 PM Tony Cook via RT <perlbug-followup@​perl.org>
wrote​:

On Wed, 14 Aug 2019 22​:21​:56 -0700, sisyphus359@​gmail.com wrote​:

Hi,

The Inline​::C demo script​:

#####################
use warnings;
use Devel​::Peek;
use Inline C => Config =>
BUILD_NOISY => 1,
USING => 'ParseRegExp',
;
use Inline C => <<'EOC';
void foo(NV val) {
printf("%.15" NVgf, val);
}
EOC
foo(sqrt(3));
#####################

On my -Dusequadmath build of perl-5.30.0 I get the following warning
during
the compilation stage​:

try_pl_0ea3.xs​: In function ‘foo’​:
try_pl_0ea3.xs​:7​:10​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
printf("%.15" NVgf, val);
^~~~~~
try_pl_0ea3.xs​:7​:10​: warning​: too many arguments for format
[-Wformat-extra-arg ]

Upon compilation the script then runs successfully.

I noticed the same warning building Scalar-List-Utils-1.51 on the same
build of perl.
In that instance it was triggered by identical formatting in ListUtil.xs

The same code compiles without warning on non-quadmath builds of
perl-5.30.0

Which operating system? Which compiler?

Please include perl -V output when you report issues.

Tony

---
via perlbug​: queue​: perl5 status​: open
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=134363

@p5pRT
Copy link
Author

p5pRT commented Aug 26, 2019

From @tonycoz

On Mon, 19 Aug 2019 23​:44​:18 -0700, sisyphus359@​gmail.com wrote​:

OS is Ubuntu-18.04, current compiler is gcc-7.4.0.
I can't find a -Dusequadmath build on the system that doesn't issue
the
warning.
I've tested​:
(v5.31.2) built for x86_64-linux-quadmath
(v5.30.0) built for x86_64-linux-quadmath
(v5.28.0) built for x86_64-linux-quadmath
(v5.26.0) built for x86_64-linux-thread-multi-quadmath
(v5.24.0) built for x86_64-linux-thread-multi-quadmath
(v5.22.0) built for x86_64-linux-thread-multi-quadmath

What I think is happening, is somehow, -Wformat is enabled by default on your gcc, similarly for James.

I don't see anything in the gcc release notes indicating that it was turned on by default, but it may have been omitted.

While building perl with a quadmath build, the build of perl itself and the bundled modules includes a -Wno-format, since gcc's -Wformat checks don't understand the Q size modifier.

This addition of -Wno-format isn't used while building CPAN modules after perl is installed though, so you see the warnings.

If you want to check if format warnings are on by default, try building this code​:

#include <stdio.h>

extern __float128 x;

void f(void) {
  printf("%Qf", x);
}

with​:

cc -c test.c

which doesn't warn here with gcc 6.3.0.

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 26, 2019

From @jkeenan

On Mon, 26 Aug 2019 02​:14​:57 GMT, tonyc wrote​:

On Mon, 19 Aug 2019 23​:44​:18 -0700, sisyphus359@​gmail.com wrote​:

OS is Ubuntu-18.04, current compiler is gcc-7.4.0.
I can't find a -Dusequadmath build on the system that doesn't issue
the
warning.
I've tested​:
(v5.31.2) built for x86_64-linux-quadmath
(v5.30.0) built for x86_64-linux-quadmath
(v5.28.0) built for x86_64-linux-quadmath
(v5.26.0) built for x86_64-linux-thread-multi-quadmath
(v5.24.0) built for x86_64-linux-thread-multi-quadmath
(v5.22.0) built for x86_64-linux-thread-multi-quadmath

What I think is happening, is somehow, -Wformat is enabled by default
on your gcc, similarly for James.

I don't see anything in the gcc release notes indicating that it was
turned on by default, but it may have been omitted.

While building perl with a quadmath build, the build of perl itself
and the bundled modules includes a -Wno-format, since gcc's -Wformat
checks don't understand the Q size modifier.

This addition of -Wno-format isn't used while building CPAN modules
after perl is installed though, so you see the warnings.

If you want to check if format warnings are on by default, try
building this code​:

#include <stdio.h>

extern __float128 x;

void f(void) {
printf("%Qf", x);
}

with​:

cc -c test.c

which doesn't warn here with gcc 6.3.0.

$ uname -mrs
Linux 4.15.0-58-generic x86_64

$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

$ gcc -c 134363-test.c
134363-test.c​: In function ‘f’​:
134363-test.c​:6​:14​: warning​: unknown conversion type character ‘Q’ in format [-Wformat=]
  printf("%Qf", x);
  ^
134363-test.c​:6​:12​: warning​: too many arguments for format [-Wformat-extra-args]
  printf("%Qf", x);
  ^~~~~

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Aug 26, 2019

From @tonycoz

On Sun, 25 Aug 2019 19​:21​:09 -0700, jkeenan wrote​:

On Mon, 26 Aug 2019 02​:14​:57 GMT, tonyc wrote​:

On Mon, 19 Aug 2019 23​:44​:18 -0700, sisyphus359@​gmail.com wrote​:

OS is Ubuntu-18.04, current compiler is gcc-7.4.0.
I can't find a -Dusequadmath build on the system that doesn't issue
the
warning.
I've tested​:
(v5.31.2) built for x86_64-linux-quadmath
(v5.30.0) built for x86_64-linux-quadmath
(v5.28.0) built for x86_64-linux-quadmath
(v5.26.0) built for x86_64-linux-thread-multi-quadmath
(v5.24.0) built for x86_64-linux-thread-multi-quadmath
(v5.22.0) built for x86_64-linux-thread-multi-quadmath

What I think is happening, is somehow, -Wformat is enabled by default
on your gcc, similarly for James.

I don't see anything in the gcc release notes indicating that it was
turned on by default, but it may have been omitted.

While building perl with a quadmath build, the build of perl itself
and the bundled modules includes a -Wno-format, since gcc's -Wformat
checks don't understand the Q size modifier.

This addition of -Wno-format isn't used while building CPAN modules
after perl is installed though, so you see the warnings.

If you want to check if format warnings are on by default, try
building this code​:

#include <stdio.h>

extern __float128 x;

void f(void) {
printf("%Qf", x);
}

with​:

cc -c test.c

which doesn't warn here with gcc 6.3.0.

$ uname -mrs
Linux 4.15.0-58-generic x86_64

$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

$ gcc -c 134363-test.c
134363-test.c​: In function ‘f’​:
134363-test.c​:6​:14​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
printf("%Qf", x);
^
134363-test.c​:6​:12​: warning​: too many arguments for format [-Wformat-
extra-args]
printf("%Qf", x);
^~~~~

Ubuntu seem to turn on -Wformat=2 and -Wformat-security by default, from the dist diff file​:

+++ gcc-7-7.4.0/debian/patches/gcc-default-format-security.diff
@​@​ -0,0 +1,39 @​@​
+# DP​: Turn on -Wformat -Wformat-security by default for C, C++, ObjC, ObjC++.
+
+Index​: b/src/gcc/doc/invoke.texi
+===================================================================
+--- a/src/gcc/doc/invoke.texi
++++ b/src/gcc/doc/invoke.texi
+@​@​ -4142,6 +4142,11 @​@​ value is used and that might result in t
+ sufficient length or magnitude.
+ @​end table
+
++NOTE​: In Ubuntu 8.10 and later versions this option is enabled by default
++for C, C++, ObjC, ObjC++. To disable, use @​option{-Wno-format-security},
++or disable all format warnings with @​option{-Wformat=0}. To make format
++security warnings fatal, specify @​option{-Werror=format-security}.
++
+ @​item -Wformat-y2k
+ @​opindex Wformat-y2k
+ @​opindex Wno-format-y2k
+Index​: b/src/gcc/gcc.c
+===================================================================
+--- a/src/gcc/gcc.c
++++ b/src/gcc/gcc.c
+@​@​ -876,11 +876,14 @​@​ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G"
+ #endif
+
++/* no separate spec, just shove it into the ssp default spec */
++#define FORMAT_SECURITY_SPEC "%{!Wformat​:%{!Wformat=2​:%{!Wformat=0​:%{!Wall​:-Wformat} %{!Wno-format-security​:-Wformat-security}}}}"
++
+ #ifndef SSP_DEFAULT_SPEC
+ #if defined(TARGET_LIBC_PROVIDES_SSP) && !defined(ACCEL_COMPILER)
+-#define SSP_DEFAULT_SPEC "%{!fno-stack-protector​:%{!fstack-protector-all​:%{!ffreestanding​:%{!nostdlib​:-fstack-protector}}}}"
++#define SSP_DEFAULT_SPEC "%{!fno-stack-protector​:%{!fstack-protector-all​:%{!ffreestanding​:%{!nostdlib​:-fstack-protector}}}} " FORMAT_SECURITY_SPEC
+ #else
+-#define SSP_DEFAULT_SPEC ""
++#define SSP_DEFAULT_SPEC FORMAT_SECURITY_SPEC
+ #endif
+ #endif
+

Tony

@p5pRT
Copy link
Author

p5pRT commented Aug 26, 2019

From @sisyphus

On Mon, 26 Aug 2019 02​:14​:57 GMT, tonyc wrote​:

This addition of -Wno-format isn't used while building CPAN modules
after perl is installed though, so you see the warnings.

Yes - that explains it. If I introduce the -Wno-format switch into the
Inline​::C build then the warning does not appear.
What should be done about this ?
Would it be unwise to add the -Wno-format flag to (say) ccflags, so
that modules (and Inline​::C scripts) are built with it ?
Or is there a way to hide the offending "Q" from gcc ?

The warning makes me a little nervous. I've seen similar types of warnings
on Windows, where they often signify that the formatting won't be done as
intended.

Cheers,
Rob

@p5pRT
Copy link
Author

p5pRT commented Aug 26, 2019

From @jkeenan

On Mon, 26 Aug 2019 04​:38​:38 GMT, tonyc wrote​:

On Sun, 25 Aug 2019 19​:21​:09 -0700, jkeenan wrote​:

On Mon, 26 Aug 2019 02​:14​:57 GMT, tonyc wrote​:

On Mon, 19 Aug 2019 23​:44​:18 -0700, sisyphus359@​gmail.com wrote​:

OS is Ubuntu-18.04, current compiler is gcc-7.4.0.
I can't find a -Dusequadmath build on the system that doesn't
issue
the
warning.
I've tested​:
(v5.31.2) built for x86_64-linux-quadmath
(v5.30.0) built for x86_64-linux-quadmath
(v5.28.0) built for x86_64-linux-quadmath
(v5.26.0) built for x86_64-linux-thread-multi-quadmath
(v5.24.0) built for x86_64-linux-thread-multi-quadmath
(v5.22.0) built for x86_64-linux-thread-multi-quadmath

What I think is happening, is somehow, -Wformat is enabled by
default
on your gcc, similarly for James.

I don't see anything in the gcc release notes indicating that it
was
turned on by default, but it may have been omitted.

While building perl with a quadmath build, the build of perl itself
and the bundled modules includes a -Wno-format, since gcc's
-Wformat
checks don't understand the Q size modifier.

This addition of -Wno-format isn't used while building CPAN modules
after perl is installed though, so you see the warnings.

If you want to check if format warnings are on by default, try
building this code​:

#include <stdio.h>

extern __float128 x;

void f(void) {
printf("%Qf", x);
}

with​:

cc -c test.c

which doesn't warn here with gcc 6.3.0.

$ uname -mrs
Linux 4.15.0-58-generic x86_64

$ gcc --version
gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0

$ gcc -c 134363-test.c
134363-test.c​: In function ‘f’​:
134363-test.c​:6​:14​: warning​: unknown conversion type character ‘Q’ in
format [-Wformat=]
printf("%Qf", x);
^
134363-test.c​:6​:12​: warning​: too many arguments for format [-Wformat-
extra-args]
printf("%Qf", x);
^~~~~

Ubuntu seem to turn on -Wformat=2 and -Wformat-security by default,
from the dist diff file​:

+++ gcc-7-7.4.0/debian/patches/gcc-default-format-security.diff
@​@​ -0,0 +1,39 @​@​
+# DP​: Turn on -Wformat -Wformat-security by default for C, C++,
ObjC, ObjC++.
+
+Index​: b/src/gcc/doc/invoke.texi
+===================================================================
+--- a/src/gcc/doc/invoke.texi
++++ b/src/gcc/doc/invoke.texi
+@​@​ -4142,6 +4142,11 @​@​ value is used and that might result in t
+ sufficient length or magnitude.
+ @​end table
+
++NOTE​: In Ubuntu 8.10 and later versions this option is enabled by
default
++for C, C++, ObjC, ObjC++. To disable, use @​option{-Wno-format-
security},
++or disable all format warnings with @​option{-Wformat=0}. To make
format
++security warnings fatal, specify @​option{-Werror=format-security}.
++
+ @​item -Wformat-y2k
+ @​opindex Wformat-y2k
+ @​opindex Wno-format-y2k
+Index​: b/src/gcc/gcc.c
+===================================================================
+--- a/src/gcc/gcc.c
++++ b/src/gcc/gcc.c
+@​@​ -876,11 +876,14 @​@​ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G"
+ #endif
+
++/* no separate spec, just shove it into the ssp default spec */
++#define FORMAT_SECURITY_SPEC
"%{!Wformat​:%{!Wformat=2​:%{!Wformat=0​:%{!Wall​:-Wformat} %{!Wno-format-
security​:-Wformat-security}}}}"
++
+ #ifndef SSP_DEFAULT_SPEC
+ #if defined(TARGET_LIBC_PROVIDES_SSP) && !defined(ACCEL_COMPILER)
+-#define SSP_DEFAULT_SPEC "%{!fno-stack-protector​:%{!fstack-
protector-all​:%{!ffreestanding​:%{!nostdlib​:-fstack-protector}}}}"
++#define SSP_DEFAULT_SPEC "%{!fno-stack-protector​:%{!fstack-
protector-all​:%{!ffreestanding​:%{!nostdlib​:-fstack-protector}}}} "
FORMAT_SECURITY_SPEC
+ #else
+-#define SSP_DEFAULT_SPEC ""
++#define SSP_DEFAULT_SPEC FORMAT_SECURITY_SPEC
+ #endif
+ #endif
+

Tony

Some data which I think supports your hypothesis​:

#####
$ uname -a
Linux zareason 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11​:12​:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

#####

$ sh ./Configure -des -Dusedevel -Dusequadmath -Dcc=gcc

[ build and install perl; change to git checkout of Scalar-List-Utils ]

$/home/jkeenan/testing/14d26b44/bin/perl -I/home/jkeenan/testing/14d26b44/lib Makefile.PL
$ make
cp lib/Sub/Util.pm blib/lib/Sub/Util.pm
cp lib/List/Util.pm blib/lib/List/Util.pm
cp lib/Scalar/Util.pm blib/lib/Scalar/Util.pm
cp lib/List/Util/XS.pm blib/lib/List/Util/XS.pm
Running Mkbootstrap for Util ()
chmod 644 "Util.bs"
"/home/jkeenan/testing/14d26b44/bin/perl" -MExtUtils​::Command​::MM -e 'cp_nonempty' -- Util.bs blib/arch/auto/List/Util/Util.bs 644
"/home/jkeenan/testing/14d26b44/bin/perl" "/home/jkeenan/testing/14d26b44/lib/perl5/5.31.4/ExtUtils/xsubpp" -typemap '/home/jkeenan/testing/14d26b44/lib/perl5/5.31.4/ExtUtils/typemap' ListUtil.xs > ListUtil.xsc
mv ListUtil.xsc ListUtil.c
gcc -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"1.51\" -DXS_VERSION=\"1.51\" -fPIC "-I/home/jkeenan/testing/14d26b44/lib/perl5/5.31.4/x86_64-linux-quadmath/CORE" -DPERL_EXT -DUSE_PPPORT_H ListUtil.c
ListUtil.xs​: In function ‘XS_List__Util_uniq’​:
ListUtil.xs​:1193​:34​: warning​: unknown conversion type character ‘Q’ in format [-Wformat=]
  sv_setpvf(keysv, "%.15" NVgf, SvNV(arg));
  ^~~~~~
ListUtil.xs​:1193​:34​: warning​: too many arguments for format [-Wformat-extra-args]
rm -f blib/arch/auto/List/Util/Util.so
gcc -shared -O2 -L/usr/local/lib -fstack-protector-strong ListUtil.o -o blib/arch/auto/List/Util/Util.so \
  \
 
chmod 755 blib/arch/auto/List/Util/Util.so

#####

$ sh ./Configure -des -Dusedevel -Dusequadmath -Dcc="gcc -Wformat=0"

[ build and install perl; change to git checkout of Scalar-List-Utils ]

$ /home/jkeenan/testing/9cb69123/bin/perl -I/home/jkeenan/testing/9cb69123/lib Makefile.PL
$ make
cp lib/Sub/Util.pm blib/lib/Sub/Util.pm
cp lib/List/Util.pm blib/lib/List/Util.pm
cp lib/Scalar/Util.pm blib/lib/Scalar/Util.pm
cp lib/List/Util/XS.pm blib/lib/List/Util/XS.pm
Running Mkbootstrap for Util ()
chmod 644 "Util.bs"
"/home/jkeenan/testing/9cb69123/bin/perl" -MExtUtils​::Command​::MM -e 'cp_nonempty' -- Util.bs blib/arch/auto/List/Util/Util.bs 644
"/home/jkeenan/testing/9cb69123/bin/perl" "/home/jkeenan/testing/9cb69123/lib/perl5/5.31.4/ExtUtils/xsubpp" -typemap '/home/jkeenan/testing/9cb69123/lib/perl5/5.31.4/ExtUtils/typemap' ListUtil.xs > ListUtil.xsc
mv ListUtil.xsc ListUtil.c
gcc -Wformat=0 -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"1.51\" -DXS_VERSION=\"1.51\" -fPIC "-I/home/jkeenan/testing/9cb69123/lib/perl5/5.31.4/x86_64-linux-quadmath/CORE" -DPERL_EXT -DUSE_PPPORT_H ListUtil.c
rm -f blib/arch/auto/List/Util/Util.so
gcc -Wformat=0 -shared -O2 -L/usr/local/lib -fstack-protector-strong ListUtil.o -o blib/arch/auto/List/Util/Util.so \
  \
 
chmod 755 blib/arch/auto/List/Util/Util.so
#####

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Aug 27, 2019

From @tonycoz

On Mon, 26 Aug 2019 06​:02​:47 -0700, sisyphus359@​gmail.com wrote​:

On Mon, 26 Aug 2019 02​:14​:57 GMT, tonyc wrote​:

This addition of -Wno-format isn't used while building CPAN modules
after perl is installed though, so you see the warnings.

Yes - that explains it. If I introduce the -Wno-format switch into the
Inline​::C build then the warning does not appear.
What should be done about this ?
Would it be unwise to add the -Wno-format flag to (say) ccflags, so
that modules (and Inline​::C scripts) are built with it ?
Or is there a way to hide the offending "Q" from gcc ?

The warning makes me a little nervous. I've seen similar types of warnings
on Windows, where they often signify that the formatting won't be done as
intended.

Well, from a custom perl installation point of view you could add -Wno-format to ccflags.

Realise while this suppresses the unknown "Q" warnings, it will also suppress any other format issues (but except for __float128, you'll see those in non-quadmath builds.)

Ideally gcc would have pragmas to register new size/format specifiers to -Wformat, and quadmath would use those. quadmath already uses the glibc mechanism to add format specifiers[1], so it seems like a reasonable extension.

It doesn't seem to have come up - the first hit for google C<gcc "wformat" "quadmath"> is this ticket.

Tony

[1] https://www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html#Customizing-Printf

@jkeenan jkeenan added the build-time-warnings Replaces [META] Build-time warnings RT #133556 label Nov 4, 2019
@jkeenan
Copy link
Contributor

jkeenan commented Nov 13, 2020

From @tonycoz

On Mon, 26 Aug 2019 06​:02​:47 -0700, sisyphus359@​gmail.com wrote​:

On Mon, 26 Aug 2019 02​:14​:57 GMT, tonyc wrote​:

This addition of -Wno-format isn't used while building CPAN modules
after perl is installed though, so you see the warnings.

Yes - that explains it. If I introduce the -Wno-format switch into the
Inline​::C build then the warning does not appear.
What should be done about this ?
Would it be unwise to add the -Wno-format flag to (say) ccflags, so
that modules (and Inline​::C scripts) are built with it ?
Or is there a way to hide the offending "Q" from gcc ?
The warning makes me a little nervous. I've seen similar types of warnings
on Windows, where they often signify that the formatting won't be done as
intended.

Well, from a custom perl installation point of view you could add -Wno-format to ccflags.

Realise while this suppresses the unknown "Q" warnings, it will also suppress any other format issues (but except for __float128, you'll see those in non-quadmath builds.)

Ideally gcc would have pragmas to register new size/format specifiers to -Wformat, and quadmath would use those. quadmath already uses the glibc mechanism to add format specifiers[1], so it seems like a reasonable extension.

It doesn't seem to have come up - the first hit for google C<gcc "wformat" "quadmath"> is this ticket.

Tony

[1] https://www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html#Customizing-Printf

@tonycoz, @sisyphus, is there any further action we need to take on this ticket (e.g., some documentation about this peculiarity)?

Thank you very much.
Jim Keenan

@jkeenan
Copy link
Contributor

jkeenan commented Sep 1, 2021

From @tonycoz

On Mon, 26 Aug 2019 06​:02​:47 -0700, sisyphus359@​gmail.com wrote​:

On Mon, 26 Aug 2019 02​:14​:57 GMT, tonyc wrote​:

This addition of -Wno-format isn't used while building CPAN modules
after perl is installed though, so you see the warnings.

Yes - that explains it. If I introduce the -Wno-format switch into the
Inline​::C build then the warning does not appear.
What should be done about this ?
Would it be unwise to add the -Wno-format flag to (say) ccflags, so
that modules (and Inline​::C scripts) are built with it ?
Or is there a way to hide the offending "Q" from gcc ?
The warning makes me a little nervous. I've seen similar types of warnings
on Windows, where they often signify that the formatting won't be done as
intended.

Well, from a custom perl installation point of view you could add -Wno-format to ccflags.
Realise while this suppresses the unknown "Q" warnings, it will also suppress any other format issues (but except for __float128, you'll see those in non-quadmath builds.)
Ideally gcc would have pragmas to register new size/format specifiers to -Wformat, and quadmath would use those. quadmath already uses the glibc mechanism to add format specifiers[1], so it seems like a reasonable extension.
It doesn't seem to have come up - the first hit for google C<gcc "wformat" "quadmath"> is this ticket.
Tony
[1] https://www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html#Customizing-Printf

@tonycoz, @sisyphus, is there any further action we need to take on this ticket (e.g., some documentation about this peculiarity)?

No response in nearly 10 months. I will close this ticket within 7 days unless someone provides a good reason to keep it open.

Thank you very much.
Jim Keenan

@jkeenan jkeenan self-assigned this Sep 1, 2021
@jkeenan jkeenan added the Closable? We might be able to close this ticket, but we need to check with the reporter label Sep 1, 2021
@tonycoz tonycoz closed this as completed Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-time-warnings Replaces [META] Build-time warnings RT #133556 Closable? We might be able to close this ticket, but we need to check with the reporter
Projects
None yet
Development

No branches or pull requests

3 participants