MantisBT - CMake
View Issue Details
0015526CMakeModulespublic2015-04-21 19:372015-11-02 09:13
Dan Kegel 
Brad King 
normalminoralways
closedfixed 
Apple MacOS X10.4.10
CMake 3.2.2 
CMake 3.3CMake 3.3 
0015526: check_c_compiler_flag does not recognize some Clang messages
Per http://stackoverflow.com/questions/26108606/no-support-to-finline-functions-in-clang-3-5 [^]
XCode 6 has dropped support for -finline-functions:

$ clang -finline-functions -c foo.c -Werror
clang: error: optimization flag '-finline-functions' is not supported

so projects that use -Werror must not use that flag.

But check_c_compiler_flag doesn't use -Werror, and the output:
$ clang -finline-functions -c foo.c
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
sails right by its regex, so the flag is listed as supported. D'oh.
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
include(CheckCCompilerFlag)
check_c_compiler_flag(-finline-functions FOOBARC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-finline-functions FOOBARCXX)
$ cmake
-- The C compiler identification is AppleClang 6.1.0.6020049
-- The CXX compiler identification is AppleClang 6.1.0.6020049
-- Performing Test FOOBARC
-- Performing Test FOOBARC - Success
-- Performing Test FOOBARCXX
-- Performing Test FOOBARCXX - Success

But I expected 'Failed', not success, as that flag is not really supported and
will cause build error if used with -Werror.
Patch sent to cmake-developers, but I guess I'm not subscribed yet, so I'll attach it here too.

Also affects older versions of cmake.
No tags attached.
patch opt.patch (1,498) 2015-04-21 19:37
https://public.kitware.com/Bug/file/5437/opt.patch
patch opt3.patch (845) 2015-04-22 10:55
https://public.kitware.com/Bug/file/5438/opt3.patch
Issue History
2015-04-21 19:37Dan KegelNew Issue
2015-04-21 19:37Dan KegelFile Added: opt.patch
2015-04-21 20:00Dan KegelNote Added: 0038576
2015-04-21 20:13Dan KegelNote Deleted: 0038576
2015-04-22 09:54Brad KingNote Added: 0038579
2015-04-22 09:54Brad KingSummarycheck_c_compiler_flag gives wrong answer on Mac => check_c_compiler_flag not implemented for Xcode 6.3
2015-04-22 09:55Brad KingAssigned To => Brad King
2015-04-22 09:55Brad KingStatusnew => assigned
2015-04-22 09:55Brad KingTarget Version => CMake 3.3
2015-04-22 10:48Dan KegelNote Added: 0038582
2015-04-22 10:55Dan KegelFile Added: opt3.patch
2015-04-22 10:56Brad KingNote Added: 0038583
2015-04-22 11:05Dan KegelNote Added: 0038584
2015-04-22 11:08Brad KingSummarycheck_c_compiler_flag not implemented for Xcode 6.3 => check_c_compiler_flag does not recognize some Clang messages
2015-04-22 12:55Brad KingNote Added: 0038585
2015-04-22 12:55Brad KingStatusassigned => resolved
2015-04-22 12:55Brad KingResolutionopen => fixed
2015-04-22 12:55Brad KingFixed in Version => CMake 3.3
2015-11-02 09:13Robert MaynardNote Added: 0039787
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038579)
Brad King   
2015-04-22 09:54   
Thanks. FYI, subscription to cmake-developers may be done here:

 http://www.cmake.org/mailman/listinfo/cmake-developers [^]

With Xcode 6.2 the AppleClang version still reports as 6.0 and the -finline-functions flag is not rejected. I've updated the description to refer to Xcode 6.3.

The pattern you propose appears to be the same for C and C+, so pleaes look at modifying CMakeCheckCompilerFlagCommonPatterns instead.
(0038582)
Dan Kegel   
2015-04-22 10:48   
Also affects older versions of clang, for instance:

$ clang -c foo.c -mno-fused-madd
clang: warning: argument unused during compilation: '-mno-fused-madd'
$ echo $?
0
$ clang -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)

Will attach patch that addresses your review, thanks.
(0038583)
Brad King   
2015-04-22 10:56   
Re 0015526:0038582: Right, it's Xcode 6.3 that dropped -finline-functions but the warning match regex needs to be updated for this Clang in general. Thanks.
(0038584)
Dan Kegel   
2015-04-22 11:05   
Here's another test case that should illustrate the general problem on
Apple LLVM version 6.0 (clang-600.0.56):

cmake_minimum_required(VERSION 2.8.12)
include(CheckCCompilerFlag)
check_c_compiler_flag("--param max-inline-insns-single=1800" FOOBARC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("--param max-inline-insns-single=1800" FOOBARCXX)
(0038585)
Brad King   
2015-04-22 12:55   
Thanks for the updated patch. I've applied it with one of the two lines:

 Check*CompilerFlag: Add another pattern for Clang
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=680ebebc [^]

The "argument unused during compilation" warning is not reliable for this purpose because it actually means that Clang does know about the flag but happens to not use it in the check's test project.
(0039787)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.