summaryrefslogtreecommitdiff
path: root/storage/xtradb
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-10-23 22:21:50 +0200
committerSergei Golubchik <serg@mariadb.org>2015-10-24 19:58:34 +0200
commit84da1547e6ccc25daa0e7a9b11ae51c51629a923 (patch)
tree38758766ea833a0831dd9460fd020f79133be6ee /storage/xtradb
parentfb8713385f514da0b77d1212f2035a6d5678561e (diff)
downloadmariadb-git-84da1547e6ccc25daa0e7a9b11ae51c51629a923.tar.gz
MDEV-8883 more cross-compiling fixes
use CHECK_C_SOURCE_COMPILES for atomic tests if cross-compiling (continue to use CHECK_C_SOURCE_RUNS otherwise)
Diffstat (limited to 'storage/xtradb')
-rw-r--r--storage/xtradb/CMakeLists.txt66
1 files changed, 38 insertions, 28 deletions
diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt
index 8daa0374aa5..fa7c9df9fe1 100644
--- a/storage/xtradb/CMakeLists.txt
+++ b/storage/xtradb/CMakeLists.txt
@@ -19,6 +19,20 @@ INCLUDE(CheckFunctionExists)
INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCSourceRuns)
+IF(CMAKE_CROSSCOMPILING)
+ # Use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS when
+ # cross-compiling. Not as precise, but usually good enough.
+ # This only make sense for atomic tests in this file, this trick doesn't
+ # work in a general case.
+ MACRO(CHECK_C_SOURCE SOURCE VAR)
+ CHECK_C_SOURCE_COMPILES("${SOURCE}" "${VAR}")
+ ENDMACRO()
+ELSE()
+ MACRO(CHECK_C_SOURCE SOURCE VAR)
+ CHECK_C_SOURCE_RUNS("${SOURCE}" "${VAR}")
+ ENDMACRO()
+ENDIF()
+
# OS tests
IF(UNIX)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@@ -63,15 +77,14 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG -DUNIV_SYNC_DEB
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
IF(NOT MSVC)
-# either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
-IF(NOT CMAKE_CROSSCOMPILING)
+ # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
# workaround for gcc 4.1.2 RHEL5/x86, gcc atomic ops only work under -march=i686
IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND CMAKE_COMPILER_IS_GNUCC AND
CMAKE_C_COMPILER_VERSION VERSION_LESS "4.1.3")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
ENDIF()
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE(
"
int main()
{
@@ -102,7 +115,7 @@ IF(NOT CMAKE_CROSSCOMPILING)
}"
HAVE_IB_GCC_ATOMIC_BUILTINS
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE(
"
int main()
{
@@ -118,7 +131,7 @@ IF(NOT CMAKE_CROSSCOMPILING)
}"
HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE(
"#include<stdint.h>
int main()
{
@@ -138,7 +151,7 @@ IF(NOT CMAKE_CROSSCOMPILING)
}"
HAVE_IB_GCC_ATOMIC_BUILTINS_64
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE(
"#include<stdint.h>
int main()
{
@@ -147,7 +160,7 @@ IF(NOT CMAKE_CROSSCOMPILING)
}"
HAVE_IB_GCC_SYNC_SYNCHRONISE
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE(
"#include<stdint.h>
int main()
{
@@ -157,7 +170,6 @@ IF(NOT CMAKE_CROSSCOMPILING)
}"
HAVE_IB_GCC_ATOMIC_THREAD_FENCE
)
-ENDIF()
IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
@@ -180,28 +192,27 @@ IF(HAVE_IB_GCC_ATOMIC_THREAD_FENCE)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_THREAD_FENCE=1)
ENDIF()
- # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
-IF(NOT CMAKE_CROSSCOMPILING)
- CHECK_C_SOURCE_RUNS(
- "
- #include <pthread.h>
- #include <string.h>
+# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
+CHECK_C_SOURCE(
+"
+#include <pthread.h>
+#include <string.h>
- int main() {
- pthread_t x1;
- pthread_t x2;
- pthread_t x3;
+int main() {
+ pthread_t x1;
+ pthread_t x2;
+ pthread_t x3;
- memset(&x1, 0x0, sizeof(x1));
- memset(&x2, 0x0, sizeof(x2));
- memset(&x3, 0x0, sizeof(x3));
+ memset(&x1, 0x0, sizeof(x1));
+ memset(&x2, 0x0, sizeof(x2));
+ memset(&x3, 0x0, sizeof(x3));
- __sync_bool_compare_and_swap(&x1, x2, x3);
+ __sync_bool_compare_and_swap(&x1, x2, x3);
+
+ return(0);
+}"
+HAVE_IB_ATOMIC_PTHREAD_T_GCC)
- return(0);
- }"
- HAVE_IB_ATOMIC_PTHREAD_T_GCC)
-ENDIF()
IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
ENDIF()
@@ -233,7 +244,6 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
SET(XTRADB_OK 1)
ENDIF()
- IF(NOT CMAKE_CROSSCOMPILING)
# either define HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS or not
CHECK_C_SOURCE_COMPILES(
" #include <pthread.h>
@@ -272,7 +282,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
return(0);
}"
HAVE_IB_MACHINE_BARRIER_SOLARIS)
- ENDIF()
+
IF(HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS)
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_SOLARIS=1)
ENDIF()