[llvm-dev] [llvm v3.6.2+] BROKEN: g++-4.9: error: unrecognized command line option '-Wcovered-switch-default'

Sedat Dilek via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 4 00:59:00 PDT 2015


Hi,

I try to compile LLVM/Clang v3.6.2 with gcc/g++ v4.9, this fails after
configure like this...

[ build-log]
...
llvm[0]: Constructing LLVMBuild project information.
make[1]: Entering directory
`/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support'
llvm[1]: Compiling APFloat.cpp for Release+Asserts build
g++-4.9: error: unrecognized command line option '-Wcovered-switch-default'
/bin/rm: cannot remove
`/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support/Release+Asserts/APFloat.d.tmp':
No such file or directory
make[1]: *** [/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support/Release+Asserts/APFloat.o]
Error 1
make[1]: Leaving directory
`/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support'
...

'-Wcovered-switch-default' is really an unrecognized command line
option for g++, but it is set after configure has done its work (see
[1]).

[ configure-log ]
...
checking optional compiler flags... -Wno-variadic-macros
-Wno-missing-field-initializers -Wcovered-switch-default
-Wno-uninitialized  -Wno-comment
...

Why is '-Wcovered-switch-default' set? It is unrecognized!

Not sure if this workaround below is good or not.

[ llvm/autoconf/configure.ac ]
...
dnl Check optional compiler flags.
AC_MSG_CHECKING([optional compiler flags])
CXX_FLAG_CHECK(NO_VARIADIC_MACROS, [-Wno-variadic-macros])
CXX_FLAG_CHECK(NO_MISSING_FIELD_INITIALIZERS, [-Wno-missing-field-initializers])
# XXX: Workaround: g++-4.9: error: unrecognized command line option
'-Wcovered-switch-default'
if test "$GXX" = "yes"
  COVERED_SWITCH_DEFAULT=
else
CXX_FLAG_CHECK(COVERED_SWITCH_DEFAULT, [-Wcovered-switch-default])
fi
...

I checked Wild Wild Internet, but what is the adequate command line
option for g++?

I followed the BR in [3] and [4] gave no clear information on this.

GCC online-docs [1] lists these warning-options:
...
[ -Wswitch ]
Warn whenever a switch statement has an index of enumerated type and
lacks a case for one or more of the named codes of that enumeration.
(The presence of a default label prevents this warning.) case labels
outside the enumeration range also provoke warnings when this option
is used (even if there is a default label). This warning is enabled by
-Wall.

[ -Wswitch-default ]
Warn whenever a switch statement does not have a default case.

[ -Wswitch-enum ]
Warn whenever a switch statement has an index of enumerated type and
lacks a case for one or more of the named codes of that enumeration.
case labels outside the enumeration range also provoke warnings when
this option is used. The only difference between -Wswitch and this
option is that this option gives a warning about an omitted
enumeration code even if there is a default label.

[ -Wswitch-bool ]
Warn whenever a switch statement has an index of boolean type and the
case values are outside the range of a boolean type. It is possible to
suppress this warning by casting the controlling expression to a type
other than bool. For example:

          switch ((int) (a == 4))
            {
            ...
            }

This warning is enabled by default for C and C++ programs.
...

In my workaround-snippet I unset COVERED_SWITCH_DEFAULT.

Comments?

Thanks in advance.

Regards,
- Sedat -

P.S.: I have attached my build-script and the outputs of my configure
and build logs.

[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
[2] http://stackoverflow.com/questions/5402745/gcc-switch-on-enum-retain-missing-warning-but-use-default
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61864
[4] http://programmers.stackexchange.com/questions/179269/why-does-clang-llvm-warn-me-about-using-default-in-a-switch-statement-where-all/242896#242896
-------------- next part --------------
llvm[0]: Constructing LLVMBuild project information.
make[1]: Entering directory `/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support'
llvm[1]: Compiling APFloat.cpp for Release+Asserts build
g++-4.9: error: unrecognized command line option '-Wcovered-switch-default'
/bin/rm: cannot remove `/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support/Release+Asserts/APFloat.d.tmp': No such file or directory
make[1]: *** [/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support/Release+Asserts/APFloat.o] Error 1
make[1]: Leaving directory `/home/wearefam/src/llvm-toolchain/llvm-build/lib/Support'
make: *** [all] Error 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build_llvm-toolchain.sh
Type: application/x-sh
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150904/dc3fd467/attachment.sh>
-------------- next part --------------
checking for clang... clang
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking for clang++... clang++
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking how to run the C preprocessor... clang -E
checking whether clang works... yes
checking whether GCC or Clang is our host compiler... clang
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking type of operating system we're going to host on... Linux
checking type of operating system we're going to target... Linux
checking target architecture... x86_64
checking whether Clang is new enough... yes
checking whether Clang will select a modern C++ standard library... yes
checking optimization flags... -O3
checking for GNU make... make
checking whether ln -s works... yes
checking for nm... /usr/bin/nm
checking for cmp... /usr/bin/cmp
checking for cp... /bin/cp
checking for date... /bin/date
checking for find... /usr/bin/find
checking for grep... /bin/grep
checking for mkdir... /bin/mkdir
checking for mv... /bin/mv
checking for ranlib... ranlib
checking for ar... ar
checking for rm... /bin/rm
checking for sed... /bin/sed
checking for tar... /bin/tar
checking for pwd... /bin/pwd
checking for dot... /usr/bin/dot
checking for a BSD-compatible install... /usr/bin/install -c
checking for bzip2... /bin/bzip2
checking for cat... /bin/cat
checking for doxygen... /usr/bin/doxygen
checking for groff... /usr/bin/groff
checking for gzip... /bin/gzip
checking for pdfroff... no
checking for zip... /usr/bin/zip
checking for go... no
checking for ocamlfind... no
checking for gas... no
checking for as... /usr/bin/as
checking for linker version... 2.22
checking for compiler -Wl,-R<path> option... yes
checking for compiler -rdynamic option... yes
checking for compiler -Wl,--version-script option... yes
checking for grep that handles long lines and -e... (cached) /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking tool compatibility... ok
checking optional compiler flags... -Wno-variadic-macros -Wno-missing-field-initializers -Wcovered-switch-default -Wno-uninitialized  -Wno-comment
checking for python... /usr/bin/python
checking for python >= 2.7... /usr/bin/python (2.7.3)
checking for sin in -lm... yes
checking for library containing dlopen... -ldl
checking for library containing clock_gettime... -lrt
checking for library containing setupterm... -ltinfo
checking for library containing el_init... -ledit
checking for library containing mallinfo... none required
checking for pthread_mutex_init in -lpthread... yes
checking for library containing pthread_mutex_lock... none required
checking for library containing pthread_rwlock_init... none required
checking for library containing pthread_getspecific... none required
checking for compress2 in -lz... yes
checking for xml2-config... no
checking for libxml2 includes... xml2-config not found
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking for MAP_ANONYMOUS vs. MAP_ANON... yes
checking whether stat file-mode macros are broken... no
checking for sys/wait.h that is POSIX.1 compatible... yes
checking whether time.h and sys/time.h may both be included... yes
checking for cxxabi.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking execinfo.h usability... yes
checking execinfo.h presence... yes
checking for execinfo.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for inttypes.h... (cached) yes
checking link.h usability... yes
checking link.h presence... yes
checking for link.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking setjmp.h usability... yes
checking setjmp.h presence... yes
checking for setjmp.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for stdint.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking utime.h usability... yes
checking utime.h presence... yes
checking for utime.h... yes
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/uio.h usability... yes
checking sys/uio.h presence... yes
checking for sys/uio.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking malloc/malloc.h usability... no
checking malloc/malloc.h presence... no
checking for malloc/malloc.h... no
checking mach/mach.h usability... no
checking mach/mach.h presence... no
checking for mach/mach.h... no
checking valgrind/valgrind.h usability... yes
checking valgrind/valgrind.h presence... yes
checking for valgrind/valgrind.h... yes
checking fenv.h usability... yes
checking fenv.h presence... yes
checking for fenv.h... yes
checking whether FE_ALL_EXCEPT is declared... yes
checking whether FE_INEXACT is declared... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking CrashReporterClient.h usability... no
checking CrashReporterClient.h presence... no
checking for CrashReporterClient.h... no
checking __crashreporter_info__... no
checking for HUGE_VAL sanity... yes
checking for pid_t... yes
checking for size_t... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for int64_t... yes
checking for uint64_t... yes
checking for backtrace... yes
checking for ceilf... yes
checking for floorf... yes
checking for roundf... yes
checking for rintf... yes
checking for nearbyintf... yes
checking for getcwd... yes
checking for powf... yes
checking for fmodf... yes
checking for strtof... yes
checking for round... yes
checking for log... yes
checking for log2... yes
checking for log10... yes
checking for exp... yes
checking for exp2... yes
checking for getpagesize... yes
checking for getrusage... yes
checking for getrlimit... yes
checking for setrlimit... yes
checking for gettimeofday... yes
checking for isatty... yes
checking for mkdtemp... yes
checking for mkstemp... yes
checking for mktemp... yes
checking for posix_spawn... yes
checking for pread... yes
checking for realpath... yes
checking for sbrk... yes
checking for setrlimit... (cached) yes
checking for strerror... yes
checking for strerror_r... yes
checking for setenv... yes
checking for strtoll... yes
checking for strtoq... yes
checking for sysconf... yes
checking for malloc_zone_statistics... no
checking for setjmp... yes
checking for longjmp... yes
checking for sigsetjmp... no
checking for siglongjmp... yes
checking for writev... yes
checking for futimes... yes
checking for futimens... yes
checking if printf has the %a format character... yes
checking for srand48/lrand48/drand48 in <stdlib.h>... yes
checking whether arc4random is declared... no
checking whether strerror_s is declared... no
checking for isnan in <math.h>... yes
checking for isnan in <cmath>... yes
checking for std::isnan in <cmath>... yes
checking for isinf in <math.h>... yes
checking for isinf in <cmath>... yes
checking for std::isinf in <cmath>... yes
checking for finite in <ieeefp.h>... no
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... (cached) yes
checking for working mmap... yes
checking for mmap of files... yes
checking if /dev/zero is needed for mmap... no
checking for GCC atomic builtins... yes
checking for 32-bit userspace on 64-bit system... no
checking for __dso_handle... yes
checking for compiler -fvisibility-inlines-hidden option... yes
configure: creating ./config.status
config.status: creating include/llvm/Config/Targets.def
config.status: creating include/llvm/Config/AsmPrinters.def
config.status: creating include/llvm/Config/AsmParsers.def
config.status: creating include/llvm/Config/Disassemblers.def
config.status: creating Makefile.config
config.status: creating llvm.spec
config.status: creating docs/doxygen.cfg
config.status: creating tools/clang/docs/doxygen.cfg
config.status: creating bindings/ocaml/llvm/META.llvm
config.status: creating include/llvm/Config/config.h
config.status: creating include/llvm/Config/llvm-config.h
config.status: creating include/llvm/Support/DataTypes.h
config.status: creating tools/clang/include/clang/Config/config.h
config.status: executing setup commands
config.status: executing Makefile commands
config.status: executing Makefile.common commands
config.status: executing examples/Makefile commands
config.status: executing lib/Makefile commands
config.status: executing test/Makefile commands
config.status: executing test/Makefile.tests commands
config.status: executing unittests/Makefile commands
config.status: executing tools/Makefile commands
config.status: executing utils/Makefile commands
config.status: executing projects/Makefile commands
config.status: executing bindings/Makefile commands
config.status: executing bindings/ocaml/Makefile.ocaml commands


More information about the llvm-dev mailing list