This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
nano printf patch breaks arm build (GCC 7.3)
- From: Alexey Neyman <stilor at att dot net>
- To: alfedotov at gmail dot com, newlib at sourceware dot org
- Date: Sun, 28 Jan 2018 23:52:21 -0800
- Subject: nano printf patch breaks arm build (GCC 7.3)
- Authentication-results: sourceware.org; auth=none
Hi,
Commit fcd33916ac03086b9090c68e88036afa4b25d913 breaks the build for
`arm-*-elf`; using GCC 7.3.
/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/src/newlib/newlib/libc/stdio/nano-vfprintf.c:
In function '_vfprintf_r':
/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/src/newlib/newlib/libc/stdio/nano-vfprintf.c:644:2:
error: cannot convert to a pointer type
n = _printf_i (data, &prt_data, fp, pfunc, va_ptr(ap));
^
The indicated location is misleading; the actual problem is the va_ptr
macro. This is the definition of va_ptr:
#define va_ptr(ap) _Generic(&(ap), va_list *: &(ap), default: (va_list
*)(ap))
I am not sure if _Generic picks up the default alternative (it looks
like it shouldn't) or if the compiler tries to first construct and
validate the expressions for all alternatives, including the ones not
going to be selected. In the description of _Generic, I don't see any
mention that a non-selected expression is allowed to be invalid - so
what happens here is probably an error before _Generic is even evaluated.
Note that in the GCC PR referenced in this commit, someone already made
a similar comment that these macros are broken in their current form.
They probably work on PowerPC, as there both `&ap` and `(va_list *)ap`
are both valid expressions, so you just need to choose the correct one.
I don't have a fix at this time - but it looks like this commit made the
use of va_list in newlib even less portable than before.
Just in case, GCC info:
Using built-in specs.
COLLECT_GCC=arm-nano-eabi-cc
COLLECT_LTO_WRAPPER=/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/buildtools/libexec/gcc/arm-nano-eabi/7.3.0/lto-wrapper
Target: arm-nano-eabi
Configured with:
/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/src/gcc/configure
--build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu
--target=arm-nano-eabi
--prefix=/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/buildtools
--with-local-prefix=/home/avn/x-tools/arm-nano-eabi/arm-nano-eabi
--without-headers --with-newlib --enable-threads=no --disable-shared
--with-pkgversion='crosstool-NG crosstool-ng-1.23.0-296-gba165ed4-dirty'
--enable-__cxa_atexit --disable-libgomp --disable-libmudflap
--disable-libmpx --disable-libssp --disable-libquadmath
--disable-libquadmath-support
--with-gmp=/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/buildtools
--with-mpfr=/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/buildtools
--with-mpc=/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/buildtools
--with-isl=/home/avn/work/ctng/issues-ctng/.build/arm-nano-eabi/buildtools
--enable-lto --with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-target-optspace
--disable-nls --enable-multiarch --enable-languages=c
Thread model: single
gcc version 7.3.0 (crosstool-NG crosstool-ng-1.23.0-296-gba165ed4-dirty)
Regards,
Alexey.