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

Dimitry Andric dimitry at andric.com
Mon Jul 30 14:13:57 PDT 2012


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/profilert-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 <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><msub><mrow></mrow><mi>C</mi></msub><mi>M</mi><mi>A</mi><mi>K</mi><msub><mi>E</mi><mi>T</mi></msub><mi>O</mi><mi>O</mi><mi>L</mi><mi>C</mi><mi>H</mi><mi>A</mi><mi>I</mi><msub><mi>N</mi><mi>P</mi></msub><mi>R</mi><mi>E</mi><mi>F</mi><mi>I</mi><mi>X</mi></mrow><mi>g</mi><mi>c</mi><mi>c</mi></mrow><annotation encoding="application/x-tex">{_CMAKE_TOOLCHAIN_PREFIX}gcc </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8778em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord"><span></span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.07153em;">C</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.07153em;">K</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.05764em;">E</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.0576em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.02778em;">OO</span><span class="mord mathnormal">L</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mord mathnormal" style="margin-right:0.08125em;">H</span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3283em;"><span style="top:-2.55em;margin-left:-0.109em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.13889em;">P</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal" style="margin-right:0.13889em;">REF</span><span class="mord mathnormal" style="margin-right:0.07847em;">I</span><span class="mord mathnormal" style="margin-right:0.07847em;">X</span></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">cc</span></span></span></span>{_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++


More information about the llvm-dev mailing list