CMake misidentifies xlc++ as Clang
I reported this issue on the mailing list and was asked to add it here:
I am using cmake-3.9.4 on a power9 system with CXX=xlc++ (IBM XL C++) and CMake is misidentifying the compiler as "clang".
% uname -a
Linux cn2021 4.11.0-44.4.1.el7a.ppc64le #1 SMP Sat Dec 9 02:17:51 EST 2017 ppc64le ppc64le ppc64le GNU/Linux
% echo $CXX
xlc++
% $CXX --version
IBM XL C/C++ for Linux, V13.1.6 (Community Edition)
Version: 13.01.0006.0001
% cmake ..
-- The CXX compiler identification is Clang 4.0.1
-- Check for working CXX compiler:
/projects/opt/ppc64le/ibm/xlc-13.1.6/xlC/13.1.6/bin/xlc++
-- Check for working CXX compiler:
/projects/opt/ppc64le/ibm/xlc-13.1.6/xlC/13.1.6/bin/xlc++ -- works
…
Because, the compiler_ID is misidentified, inappropriate compiler options are added when CXX_CXX_STANDARD is set (along with other issues).
- Question 1: How do I report this as a bug? What additional information is needed to characterize the failure mode?
- Question 2: Is there a way to force the compiler ID to be "XL" as a temporary work around until the bug is fixed?
@robertmaynard replied to my email with the following:
- You can report this issue on the CMake gitlab. You will want to attach the result of dumping all defines from the compiler (
xlc++ -dD -E - < /dev/null
orxlc++ -dM -E
). Currently it looks like we are using'__IBMCPP__'
to detect xlc++, and that might not be defined on the power pc platform.
- If my guess about about 1 is correct, You can try setting the environment variable
CXX_FLAGS
to-qxlcompatmacros
and see if that works. IBM knowledgecenter
Follow up:
- I can confirm that
__IBMCPP__
is not set, instead__ibmxl__
is set to1
. The output file fromxlc++ -dM -E foo.cc
is attached and shows all of the defines.ibmxl-defines.txt - I also tried
xlc++ -qxlcompatmacros -dM -E foo.cc
, and that does produce the desired symbol.
% cmake -DCMAKE_C_FLAGS="-qxlcompatmacros" -DCMAKE_CXX_FLAGS="-qxlcompatmacros" ..
-- The CXX compiler identification is XL 13.1.6
-- The C compiler identification is XL 13.1.6
-- Check for working CXX compiler: /projects/opt/ppc64le/ibm/xlc-13.1.6/xlC/13.1.6/bin/xlc++
-- Check for working CXX compiler: /projects/opt/ppc64le/ibm/xlc-13.1.6/xlC/13.1.6/bin/xlc++ -- works
- Maybe cmake's test for compiler flavor should always use the
-qxlcompatmacros
.
Edited by Kelly (KT) Thompson