Commit a5d9597e authored by Sergei Golubchik's avatar Sergei Golubchik

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
parent 5f078cc8
...@@ -798,16 +798,36 @@ ENDIF() ...@@ -798,16 +798,36 @@ ENDIF()
# #
# Test for how the C compiler does inline, if at all # 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(" 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;}" int main(int argc, char *argv[]){return 0;}"
C_HAS_inline) C_HAS_inline)
IF(NOT C_HAS_inline) IF(NOT C_HAS_inline)
CHECK_C_SOURCE_COMPILES(" 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;}" int main(int argc, char *argv[]){return 0;}"
C_HAS___inline) C_HAS___inline)
IF(C_HAS___inline)
SET(C_INLINE __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() ENDIF()
IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC) IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC)
......
...@@ -207,20 +207,6 @@ ...@@ -207,20 +207,6 @@
#define likely(x) __builtin_expect(((x) != 0),1) #define likely(x) __builtin_expect(((x) != 0),1)
#define unlikely(x) __builtin_expect(((x) != 0),0) #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 */ /* Fix problem with S_ISLNK() on Linux */
#if defined(TARGET_OS_LINUX) || defined(__GLIBC__) #if defined(TARGET_OS_LINUX) || defined(__GLIBC__)
#undef _GNU_SOURCE #undef _GNU_SOURCE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment