diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-02-14 22:15:16 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-02-15 12:51:35 +0100 |
commit | a5d9597e9703052895c8c2401132e77aa68a6123 (patch) | |
tree | 339369f681d0081c582b30afe1aefbd4eb74ea31 /configure.cmake | |
parent | 5f078cc8ff1f8af979d8852bf62fa259f41b1f93 (diff) | |
download | mariadb-git-a5d9597e9703052895c8c2401132e77aa68a6123.tar.gz |
better inline check
1. check that unused inline functions are removed
2. only allow compilation if they are or if the check if overridden
3. with CMAKE_GENERATOR=Makefiles, use all flags when testing
(e.g. both CMAKE_C_FLAGS and CMAKE_C_FLAGS_DEBUG if
CMAKE_BUILD_TYPE=Debug). This is because
- on Solaris with the SunPro compiler, default CMAKE_C_FLAGS_xxx
values contain -xO2 (for Release and RelWithDebInfo)
and -g (for RelWithDebInfo and Debug)
- proper inlining only works at -xO4 without -g
- so if CMAKE_C_FLAGS has -xO4, inlining would work in
configure.cmake (before this fix) and fail during actual compilation
also remove the outdated check for inline from myu_global.h
Diffstat (limited to 'configure.cmake')
-rw-r--r-- | configure.cmake | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/configure.cmake b/configure.cmake index d01bf9eb0e7..f0517bfa41e 100644 --- a/configure.cmake +++ b/configure.cmake @@ -798,16 +798,36 @@ ENDIF() # # Test for how the C compiler does inline, if at all # +# SunPro is weird, apparently it only supports inline at -xO3 or -xO4. +# And if CMAKE_C_FLAGS has -xO4 but CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} has -xO2 +# then CHECK_C_SOURCE_COMPILES will succeed but the built will fail. +# We must test all flags here. +# XXX actually, we can do this for all compilers, not only SunPro +IF (CMAKE_CXX_COMPILER_ID MATCHES "SunPro" AND + CMAKE_GENERATOR MATCHES "Makefiles") + STRING(TOUPPER "CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}" flags) + SET(CMAKE_REQUIRED_FLAGS "${${flags}}") +ENDIF() CHECK_C_SOURCE_COMPILES(" -static inline int foo(){return 0;} +extern int bar(int x); +static inline int foo(){return bar(1);} int main(int argc, char *argv[]){return 0;}" C_HAS_inline) IF(NOT C_HAS_inline) CHECK_C_SOURCE_COMPILES(" - static __inline int foo(){return 0;} + extern int bar(int x); + static __inline int foo(){return bar(1);} int main(int argc, char *argv[]){return 0;}" C_HAS___inline) - SET(C_INLINE __inline) + IF(C_HAS___inline) + SET(C_INLINE __inline) + ElSE() + SET(C_INLINE) + MESSAGE(WARNING "C compiler does not support funcion inlining") + IF(NOT NOINLINE) + MESSAGE(FATAL_ERROR "Use -DNOINLINE=TRUE to allow compilation without inlining") + ENDIF() + ENDIF() ENDIF() IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC) |