In configure script generated by autoconf 2.13 for mozilla software
# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
I found a few tests that failed if -Werror=unsed-variable is defined for
CFLAGS (an environment variable).
Since the unused variable in test code snipet causes the short
compilation test to fail,
configure sets the tested feature as non-working by mistake.
In my case, it was |working const| that was found to be lacking and
caused a lot of grief during build.
cf. My environment variable setting before running configure.
--- begin quote
SPLITDWARF="-Wl,--gdb-index"
# ASAN="-fsanitaize=address"
ASAN=
# added -Wsign-compare on 14 Sept, 2016
# -Werror=unused-variable" took out due to the reported bug.
# -fno-builtin-strlen : to reduce false-positive from valgrind. Jan 27,
2014
export CFLAGS="$CFLAGS $MEMORYMODEL $ASAN -fno-builtin-strlen
$SPLITDWARF -Dfdatasync=fdatasync -DDEBUG_4GB_CHECK -DUSEHELGRIND=1
-Werror=sign-compare "
export CXXFLAGS="$CXXFLAGS $MEMORYMODEL $ASAN -fno-builtin-strlen
$SPLITDWARF -Dfdatasync=fdatasync -DDEBUG_4GB_CHECK -DUSEHELGRIND=1
-Werror=sign-compare "
#
export CC="/usr/bin/gcc-6"
export CXX="/usr/bin/g++-6"
export CC CXX
--- end quote
these are set along with some other environment variables for mozilla
software build before
configure is called eventually.
---
Here are a few configure tests that failed due to
-Werror=unused-variable.
I have no clear solution but for a stop-gap measure,
may I suggest that the variable(s) are used as an argument to dummy
function call?
Test failures from config.log due to -Werror=unused-variable
configure:6471: checking for working const
configure:6525: /usr/bin/ccache /usr/bin/gcc-6 -std=gnu99 -c
-fno-builtin-strlen -Wl,--gdb-index -Dfdatasync=fdatasync
-DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -Werror=sign-compare
-Werror=unused-variable -fno-strict-aliasing -fno-math-errno conftest.c
1>&5
configure: In function 'main':
configure:6499:15: error: unused variable 's' [-Werror=unused-variable]
configure:6519:13: error: unused variable 'foo'
[-Werror=unused-variable]
configure:6487:27: error: unused variable 'zero'
[-Werror=unused-variable]
configure:6481:39: error: unused variable 'x' [-Werror=unused-variable]
cc1: some warnings being treated as errors
configure: failed program was:
#line 6476 "configure"
#include "confdefs.h"
int main() {
/* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x;
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
/* NEC SVR4.0.2 mips cc rejects this. */
struct point {int x, y;};
static struct point const zero = {0,0};
/* AIX XL C 1.02.0.0 rejects this.
It does not let you subtract one const X* pointer from another in an
arm
of an if-expression whose if-part is not a constant expression */
const char *g = "string";
ccp = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++ccp;
p = (char**) ccp;
ccp = (char const *const *) p;
{ /* SCO 3.2v4 cc rejects this. */
char *t;
char const *s = 0 ? (char *) 0 : (char const *) 0;
*t++ = 0;
}
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this.
*/
int x[] = {25, 17};
const int *foo = &x[0];
++foo;
}
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
typedef const int *iptr;
iptr p = 0;
++p;
}
{ /* AIX XL C 1.02.0.0 rejects this saying
"k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue.
*/
struct s { int j; const int *ap[3]; };
struct s *b; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
}
; return 0; }
configure:6820: checking for dirent.h that defines DIR
configure:6833: /usr/bin/ccache /usr/bin/gcc-6 -std=gnu99 -c
-fno-builtin-strlen -Wl,--gdb-index -Dfdatasync=fdatasync
-DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -Werror=sign-compare
-Werror=unused-variable -fno-strict-aliasing -fno-math-errno conftest.c
1>&5
configure: In function 'main':
configure:6829:6: error: unused variable 'dirp'
[-Werror=unused-variable]
cc1: some warnings being treated as errors
configure: failed program was:
#line 6825 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <dirent.h>
int main() {
DIR *dirp = 0;
; return 0; }
configure:6820: checking for sys/dir.h that defines DIR
configure:6833: /usr/bin/ccache /usr/bin/gcc-6 -std=gnu99 -c
-fno-builtin-strlen -Wl,--gdb-index -Dfdatasync=fdatasync
-DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -Werror=sign-compare
-Werror=unused-variable -fno-strict-aliasing -fno-math-errno conftest.c
1>&5
configure: In function 'main':
configure:6829:6: error: unused variable 'dirp'
[-Werror=unused-variable]
cc1: some warnings being treated as errors
configure: failed program was:
#line 6825 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/dir.h>
int main() {
DIR *dirp = 0;
; return 0; }
configure:8613: checking for res_ninit()
configure:8636: /usr/bin/ccache /usr/bin/gcc-6 -std=gnu99 -o conftest
-fno-builtin-strlen -Wl,--gdb-index -Dfdatasync=fdatasync
-DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -Werror=sign-compare
-Werror=unused-variable -fno-strict-aliasing -fno-math-errno -pthread
-lpthread -Wl,-z,noexecstack -Wl,-z,text -Wl,--build-id conftest.c -ldl
1>&5
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:25:0,
from configure:8626:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and
_SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use
_DEFAULT_SOURCE"
^~~~~~~
configure: In function 'main':
configure:8632:5: error: unused variable 'foo' [-Werror=unused-variable]
cc1: some warnings being treated as errors
configure: failed program was:
#line 8621 "configure"
#include "confdefs.h"
#ifdef linux
#define _BSD_SOURCE 1
#endif
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
int main() {
int foo = res_ninit(&_res);
; return 0; }
configure:8907: checking for nl_langinfo and CODESET
configure:8919: /usr/bin/ccache /usr/bin/g++-6 -std=gnu++11 -o conftest
-fno-builtin-strlen -Wl,--gdb-index -Dfdatasync=fdatasync
-DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -Werror=sign-compare
-Werror=unused-variable -fno-exceptions -fno-strict-aliasing -fno-rtti
-fno-exceptions -fno-math-errno -pthread -lpthread -Wl,-z,noexecstack
-Wl,-z,text -Wl,--build-id conftest.C -ldl 1>&5
configure: In function 'int main()':
configure:8915:7: error: unused variable 'cs' [-Werror=unused-variable]
cc1plus: some warnings being treated as errors
configure: failed program was:
#line 8912 "configure"
#include "confdefs.h"
#include <langinfo.h>
int main() {
char* cs = nl_langinfo(CODESET);
; return 0; }
configure:9272: checking for LC_MESSAGES
configure:9284: /usr/bin/ccache /usr/bin/gcc-6 -std=gnu99 -c
-fno-builtin-strlen -Wl,--gdb-index -Dfdatasync=fdatasync
-DDEBUG_4GB_CHECK -DUSEHELGRIND=1 -Werror=sign-compare
-Werror=unused-variable -fno-strict-aliasing -fno-math-errno -pthread
conftest.c 1>&5
configure: In function 'main':
configure:9280:5: error: unused variable 'category'
[-Werror=unused-variable]
cc1: some warnings being treated as errors
configure: failed program was:
#line 9277 "configure"
#include "confdefs.h"
#include <locale.h>
int main() {
int category = LC_MESSAGES;
; return 0; }
We can immediately see that the variable(s) can be passed to a function
that
takes the argument of the same type, and the function can be declared in
the short test code snippet.
Fixing test for |working const| would be the most laborious one.
TIA