[LLVMdev] clean CMake build failing (Mac OS X 10.8)

56 views
Skip to first unread message

Marshall Clow

unread,
Jul 30, 2012, 1:03:41 PM7/30/12
to llv...@cs.uiuc.edu
Over the weekend I upgraded my system to Mac OS X 10.8, and now a clean cmake build fails.

The error message:
> Building C object runtime/libprofile/CMakeFiles/profile_rt-static.dir/CommonProfiling.c.o
> cc1: error: unrecognized command line option "-Wcovered-switch-default"


The configuration:
> Mac OS X 10.8
> CMake 2.8.8
> LLVM tot
> Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)


Running cmake to generate the make files gives the following output:
> -- The C compiler identification is GNU 4.2.1
> -- The CXX compiler identification is Clang 4.0.0
>

Diagnosis:
cmake is passing "-Wcovered-switch-default" to the c compiler.
It also thinks that the c compiler should be gcc, rather than clang.
gcc does not support that switch, and fails.

Possible solutions:
* use clang to compile the C code (note that /usr/bin/cc is clang on this system; why it's picking gcc, I don't know)
* Don't pass "-Wcovered-switch-default" to the C compiler.

-- Marshall

Marshall Clow Idio Software <mailto:mclow...@gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
-- Yu Suzuki


_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Marshall Clow

unread,
Jul 30, 2012, 4:08:17 PM7/30/12
to llv...@cs.uiuc.edu

On Jul 30, 2012, at 10:03 AM, Marshall Clow <mclow...@gmail.com> wrote:

> Over the weekend I upgraded my system to Mac OS X 10.8, and now a clean cmake build fails.
>
> The error message:
>> Building C object runtime/libprofile/CMakeFiles/profile_rt-static.dir/CommonProfiling.c.o
>> cc1: error: unrecognized command line option "-Wcovered-switch-default"
>
>
> The configuration:
>> Mac OS X 10.8
>> CMake 2.8.8
>> LLVM tot
>> Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
>
>
> Running cmake to generate the make files gives the following output:
>> -- The C compiler identification is GNU 4.2.1
>> -- The CXX compiler identification is Clang 4.0.0
>>
>
> Diagnosis:
> cmake is passing "-Wcovered-switch-default" to the c compiler.
> It also thinks that the c compiler should be gcc, rather than clang.
> gcc does not support that switch, and fails.
>
> Possible solutions:
> * use clang to compile the C code (note that /usr/bin/cc is clang on this system; why it's picking gcc, I don't know)
> * Don't pass "-Wcovered-switch-default" to the C compiler.

A workaround - force use of clang for C compilations:
CC=/usr/bin/cc cmake $LLVM/llvm

Dimitry Andric

unread,
Jul 30, 2012, 5:13:57 PM7/30/12
to Marshall Clow, llv...@cs.uiuc.edu
On 2012-07-30 19:03, Marshall Clow wrote:
> Over the weekend I upgraded my system to Mac OS X 10.8, and now a clean cmake build fails.
>
> The error message:
>> Building C object runtime/libprofile/CMakeFiles/profile_rt-static.dir/CommonProfiling.c.o
>> cc1: error: unrecognized command line option "-Wcovered-switch-default"
>
>
> The configuration:
>> Mac OS X 10.8
>> CMake 2.8.8
>> LLVM tot
>> Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
>
>
> Running cmake to generate the make files gives the following output:
>> -- The C compiler identification is GNU 4.2.1
>> -- The CXX compiler identification is Clang 4.0.0
>>
>
> Diagnosis:
> cmake is passing "-Wcovered-switch-default" to the c compiler.
> It also thinks that the c compiler should be gcc, rather than clang.
> gcc does not support that switch, and fails.
>
> Possible solutions:
> * use clang to compile the C code (note that /usr/bin/cc is clang on this system; why it's picking gcc, I don't know)

This is a problem in CMake; for a C compiler, it always picks a 'gcc'
executable in the PATH over a 'cc' executable. See the file
/opt/local/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, where
it has:

[...]
SET(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl bcc xlc)

Maybe this was done, because some systems used to have a bad default cc?
Like Solaris? :) I don't think that reasoning is really valid anymore,
these days, though.

In any case, I usually just add these to the cmake invocation, just to
be sure:

-DCMAKE_C_COMPILER=/usr/bin/cc -DCMAKE_CXX_COMPILER=/usr/bin/c++

Óscar Fuentes

unread,
Jul 31, 2012, 4:57:01 PM7/31/12
to llv...@cs.uiuc.edu
Dimitry Andric <dim...@andric.com> writes:

> This is a problem in CMake; for a C compiler, it always picks a 'gcc'
> executable in the PATH over a 'cc' executable. See the file
> /opt/local/share/cmake-2.8/Modules/CMakeDetermineCCompiler.cmake, where
> it has:
>
> [...]
> SET(CMAKE_C_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl bcc xlc)
>
> Maybe this was done, because some systems used to have a bad default cc?
> Like Solaris? :) I don't think that reasoning is really valid anymore,
> these days, though.

I passed your remark to the CMake developers and they swiftly fixed the
issue:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27b74445

CMake version 2.8.9 already is in final RC stage, so the change will
appear on version 2.8.10.

Thanks.

[snip]
Reply all
Reply to author
Forward
0 new messages