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 | |
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
-rw-r--r-- | configure.cmake | 26 | ||||
-rw-r--r-- | include/my_global.h | 14 |
2 files changed, 23 insertions, 17 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) diff --git a/include/my_global.h b/include/my_global.h index 9e9651b7409..dce38a124c1 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -207,20 +207,6 @@ #define likely(x) __builtin_expect(((x) != 0),1) #define unlikely(x) __builtin_expect(((x) != 0),0) -/* - now let's figure out if inline functions are supported - autoconf defines 'inline' to be empty, if not -*/ -#define inline_test_1(X) X ## 1 -#define inline_test_2(X) inline_test_1(X) -#if inline_test_2(inline) != 1 -#define HAVE_INLINE -#else -#error Compiler does not support inline! -#endif -#undef inline_test_2 -#undef inline_test_1 - /* Fix problem with S_ISLNK() on Linux */ #if defined(TARGET_OS_LINUX) || defined(__GLIBC__) #undef _GNU_SOURCE |