[LLVMdev] [llvm-commits] Improved Covered Default Switch detection

David Blaikie dblaikie at gmail.com
Sun Nov 25 17:22:33 PST 2012


On Sun, Nov 25, 2012 at 3:19 PM, Joe Abbey <jabbey at arxan.com> wrote:
> If cmake happens to detect GCC for the C compiler and Clang for the C++
> compiler, then a manual override of either the C compiler or
> SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG is required.  This has been happening
> on my Darwin build environments:
>
> -- The C compiler identification is GNU 4.2.1
> -- The CXX compiler identification is Clang 4.1.0

How/why has this been happening, exactly? Seems kind of surprising for
any platform (or user, for that matter) to mismatch between the C and
C++ compiler.

That being said, I'm not sure we should prohibit this configuration,
I'm just not sure how much I'd really want to tweak the build system
to accommodate it given that there is a workaround.

>
> Without the manual overrides, all C sources fail to compile with:
>
> [  4%] Building C object lib/Support/CMakeFiles/LLVMSupport.dir/regcomp.c.o
> cd /Users/jabbey/src/llvmCommit/build/lib/Support && /usr/bin/gcc  -D_DEBUG
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC
> -I/Users/jabbey/src/llvmCommit/build/lib/Support
> -I/Users/jabbey/src/llvmCommit/lib/Support
> -I/Users/jabbey/src/llvmCommit/build/include
> -I/Users/jabbey/src/llvmCommit/include    -Wall -W -Wno-unused-parameter
> -Wwrite-strings -pedantic -Wno-long-long -Wcovered-switch-default
> -fno-exceptions -o CMakeFiles/LLVMSupport.dir/regcomp.c.o   -c
> /Users/jabbey/src/llvmCommit/lib/Support/regcomp.c
> cc1: error: unrecognized command line option "-Wcovered-switch-default"
>
> The problem stems from HandleLLVMOptions.cmake where a single check of the
> warning option is performed using check_cxx_compiler_flag, and then upon
> success add_llvm_definitions appends to the flag to a list consumed by both
> C and CXX compilers.
>
> Attached is a patch which updates HandleLLVMOptions.cmake to:
>   - Test C and CXX compiler separately for -Wcovered-switch-default
>   - Split SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG into a C and CXX variant
>   - Replace set( ${variable} "${variable} arg") with list( append $variable
> "arg" )
>   - Check cmake_minimum_required of at least CMake 2.4 (where list append
> was introduced).
>
> Ok to commit?
>
> Joe
> ______________________________
> Joe Abbey
> Director of Software Development
> Arxan Technologies
> jabbey at arxan.com www.arxan.com
> Protecting the App Economy™
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-dev mailing list