[Freeswitch-dev] Error compiling freeswitch 1.6.6 with --disable-debug and possible fix
freeswitch-dev.opencode at spamgourmet.com
freeswitch-dev.opencode at spamgourmet.com
Wed Feb 24 07:28:46 MSK 2016
I'm getting a compilation error compiling the latest production release (1.6.6) when using --disable-debug with certain (as yet undermined) environment settings. The approximate steps I'm following are:
curl -O https://files.freeswitch.org/releases/freeswitch/freeswitch-1.6.6.tar.xz
tar -xvf freeswitch-1.6.6.tar.xz
cd freeswitch-1.6.6
./configure --disable-debug
make
Except I'm using makepkg, the build tool for Arch Linux. (It's ultimately for Arch Linux ARM on a Raspberry Pi Zero, but the same thing happens with normal x86_64 Arch Linux). When I use the exact steps above in a shell, make succeeds, but when I run the equivalent within ArchLinux's makepkg tool, I'm getting the following error (lightly sanitized):
CC freeswitch-switch.o
src/switch.c: In function ‘main’:
src/switch.c:1194:5: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result]
(void)read(fds[1], &v, sizeof(v));
^
src/switch.c: In function ‘check_fd’:
src/switch.c:236:5: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
(void)write(fd, &r, sizeof(r));
^
cc1: all warnings being treated as errors
Makefile:1988: recipe for target 'freeswitch-switch.o' failed
make[2]: *** [freeswitch-switch.o] Error 1
make[2]: Leaving directory '~/builds/freeswitch/src/freeswitch-1.6.6'
Makefile:2420: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '~/builds/freeswitch/src/freeswitch-1.6.6'
Makefile:970: recipe for target 'all' failed
make: *** [all] Error 2
In parallel, I'm checking with the Arch Linux folks for help understanding the makepkg environment (perhaps some compilation *FLAGS environment variables?) that are likely needed to reproduce the error on other distributions. I'll reply further if I get better data from them.
However, from a look at configure.ac, it does appear that unused result warnings/errors are being suppressed via SWITCH_AM_CFLAGS perhaps only in when debug is enabled:
if test "${enable_debug}" = "yes"; then
AC_DEFINE([DEBUG],[],[Enable extra debugging.])
saved_CFLAGS="$CFLAGS"
CFLAGS=
AX_CFLAGS_WARN_ALL_ANSI
SWITCH_ANSI_CFLAGS=$CFLAGS
CFLAGS="$saved_CFLAGS"
if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
if test "$ac_cv_gcc_supports_w_no_unused_result" = yes; then
APR_ADDTO(SWITCH_AM_CFLAGS, -Wno-unused-result)
fi
APR_ADDTO(SWITCH_AM_CFLAGS, -g -ggdb)
export DEBUG_CFLAGS="-g -ggdb"
fi
fi
Though I'm a newbie so I may be missing something obvious. (For one, I don't yet understand the difference between SWITCH_AM_CFLAGS and other related variable(s).)
I'm currently working around the error using the following patch:
--- configure.ac.old 2016-02-23 16:50:04.190884018 -0800
+++ configure.ac 2016-02-23 16:50:29.103970709 -0800
@@ -410,6 +410,7 @@
APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC)
if test "$ac_cv_gcc_supports_w_no_unused_result" = yes; then
APR_ADDTO(SWITCH_AM_CFLAGS, -Werror)
+ APR_ADDTO(SWITCH_AM_CFLAGS, -Wno-unused-result)
fi
if test "${enable_64}" = "yes"; then
case "$host" in
@@ -533,9 +534,6 @@
CFLAGS="$saved_CFLAGS"
if test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
- if test "$ac_cv_gcc_supports_w_no_unused_result" = yes; then
- APR_ADDTO(SWITCH_AM_CFLAGS, -Wno-unused-result)
- fi
APR_ADDTO(SWITCH_AM_CFLAGS, -g -ggdb)
export DEBUG_CFLAGS="-g -ggdb"
fi
Can you tell whether I'm on the right track here (is this a bug in freeswitch's configure script)? If this is the right fix (or close to it), would you be interested in taking it?
(And apologies if this isn't the best way to format code snippets for this mailing list; please let me know if there's a better way.)
Thanks,
David
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-dev
mailing list