configure and -Werror=unused-variable do not mix well.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

configure and -Werror=unused-variable do not mix well.

ishikawa
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



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: configure and -Werror=unused-variable do not mix well.

Eric Blake-3
On 01/27/2017 05:31 AM, [hidden email] wrote:
> 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.

Wow that's old. Can you convince the project to upgrade their
configure.in file to use autoconf 2.69 instead?

>
> I found a few tests that failed if -Werror=unsed-variable is defined for
> CFLAGS (an environment variable).

Generally, ANY use of -Werror during configure is going to cause
problems. Our general advice is "don't do that".  If you want to test if
a particular warning flag is supported, do so (and in fact, there's
patches posted that I still want to incorporate into autoconf 2.70 that
make warning flag probing easier) - but only for the duration of that
test.  Don't actually change CFLAGS for the rest of the configure suite.
 GNU Coreutils is a good example of how to probe for -Werror and even
use it via a separate Makefile.am variable, without having it on to mess
with the rest of the configure probes.

--
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


signature.asc (617 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: configure and -Werror=unused-variable do not mix well.

ishikawa
Dear Eric,

Thank you for your quick response.

On 2017/01/28 0:00, Eric Blake wrote:
> On 01/27/2017 05:31 AM, [hidden email] wrote:
>> 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.
>
> Wow that's old. Can you convince the project to upgrade their
> configure.in file to use autoconf 2.69 instead?

I realize that I do have both autconf213 and autoconf (2.69) on MY linux
PC (Debian GNU/Linux).

Not sure, though. how the Mozilla developers would update the manner to
create configure from configure.in.
It seems that they have abandoned the route and try moving into their
own configuration tool written in python.
In the meantime, the old configure is left as old-configure and is
executed and old-configure.in has, near the beginning, the following lines:
dnl Process this file with autoconf to produce a configure script.
dnl ========================================================
AC_PREREQ(2.13)  <==== !?
AC_INIT(config/config.mk)
AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
AC_CANONICAL_SYSTEM

Does AC_PRERQ(2.13) require the use of autoconf213?
Or can we use autoconf (2.69) safely? If we can use later versions
safely, I would certainly suggest upgrading to mozilla's mailing list.

>
>>
>> I found a few tests that failed if -Werror=unsed-variable is defined for
>> CFLAGS (an environment variable).
>

After sending out my report, I thought about it and I agree that
-Werror=...  would be nightmarish to deal with as you mention near the
beginning of next paragraph:

> Generally, ANY use of -Werror during configure is going to cause
> problems. Our general advice is "don't do that".  If you want to test if
> a particular warning flag is supported, do so (and in fact, there's
> patches posted that I still want to incorporate into autoconf 2.70 that
> make warning flag probing easier) - but only for the duration of that
> test.  Don't actually change CFLAGS for the rest of the configure suite.
>  GNU Coreutils is a good example of how to probe for -Werror and even
> use it via a separate Makefile.am variable, without having it on to mess
> with the rest of the configure probes.
>

What is puzzling me right now is that
I have two Debian GNU/Linux with very similar configuration and
on one machine I get the problem which I reported, but
on the other machine somehow I do NOT get the problem.
Very confusing...
(Not only that on the other machine, as of today, I noticed a GCC 6
crash (dreaded internal compiler error), but not on this machine where I
am writing  this e-mail.
I am driven nuts...

There may be a subtle configuration difference somewhere [this machine I
use fetches more ambitious testing packages while the other PC is in an
office setting and use more stable package repository], but
this kind of subtle issue may be exactly why we should avoid
using -Werror during configure.

If I have time I would love to check how GNU Coreutils handles this issue.

The reason I had to add "-Werror=unused-variable" to my CFLAGS
environment variable is that Mozilla's compilation farm available to
developers seems to apply this -Werror setting per directory basis, and
in order to detect such warning-turned-into-error locally on my
home/office PC [I found a few compilation errors ONLY AFTER I submit my
source patches to mozilla's compilation farm. The source compiled fine
on my PCs.], I had to add this -Werror, but I was not sure how to apply
the option per directory-basis in the framework mozilla uses to build
firefox browser and thunderbird mail client.
Right now, I apply the CFLAGS setting for the whole source tree.

Their command to build is very complex and handles the configure and
build in one command and it is not easy to separate the two.

Thank you again for your feedback.

Best Regards,
Chiaki Ishikawa


Loading...