maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #08976
Re: crosscompiling in buildroot: cannot find -laio and other link error
On 02/10/2015 18:28, Sergei Golubchik wrote:
>> 2. I patched storage/innobase/CMakeLists.txt (also attached) in order
>> > to use CHECK_C_SOURCE_COMPILES instead of CHECK_C_SOURCE_RUNS, which
>> > fails when cross compiling.
> I'm not sure we can do that, some of those checks were
> CHECK_C_SOURCE_COMPILES before and later changed to CHECK_C_SOURCE_RUNS
> because compiling was not enough (in some corner cases).
>
> I think doing CHECK_C_SOURCE_COMPILES in cross-compiling case and
> CHECK_C_SOURCE_RUNS otherwise could be a reasonable compromise.
>
Hi
For this I propose the attached patch. Tested in my buildroot
environment, works here.
In my case I do have atomic intrinsics, but trying to build without them
fails (https://mariadb.atlassian.net/browse/MDEV-9002).
Cheers and thanks for your help,
--
Sylvain Raybaud
www.green-communications.fr
If CMAKE_CROSSCOMPILING is set then use CHECK_C_SOURCE_COMPILES instead of
CHECK_C_SOURCE_RUNS.
--- a/storage/innobase/CMakeLists.txt 2015-10-23 13:34:37.558116079 +0200
+++ b/storage/innobase/CMakeLists.txt 2015-10-23 14:54:38.602244647 +0200
@@ -56,16 +56,23 @@
CHECK_FUNCTION_EXISTS(sched_getcpu HAVE_SCHED_GETCPU)
+macro(CHECK_C_SOURCE_GENERIC source result)
+ IF(NOT CMAKE_CROSSCOMPILING)
+ CHECK_C_SOURCE_RUNS("${source}" ${result})
+ ELSE()
+ CHECK_C_SOURCE_COMPILES("${source}" ${result})
+ ENDIF()
+endmacro(CHECK_C_SOURCE_GENERIC)
+
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")
+ 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_GENERIC(
"
int main()
{
@@ -96,7 +103,7 @@
}"
HAVE_IB_GCC_ATOMIC_BUILTINS
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE_GENERIC(
"
int main()
{
@@ -112,7 +119,7 @@
}"
HAVE_IB_GCC_ATOMIC_BUILTINS_BYTE
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE_GENERIC(
"#include<stdint.h>
int main()
{
@@ -132,7 +139,7 @@
}"
HAVE_IB_GCC_ATOMIC_BUILTINS_64
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE_GENERIC(
"#include<stdint.h>
int main()
{
@@ -141,7 +148,7 @@
}"
HAVE_IB_GCC_SYNC_SYNCHRONISE
)
- CHECK_C_SOURCE_RUNS(
+ CHECK_C_SOURCE_GENERIC(
"#include<stdint.h>
int main()
{
@@ -151,7 +158,6 @@
}"
HAVE_IB_GCC_ATOMIC_THREAD_FENCE
)
-ENDIF()
IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
@@ -173,28 +179,27 @@
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>
-
- 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));
+# either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
+CHECK_C_SOURCE_GENERIC(
+"
+#include <pthread.h>
+#include <string.h>
+
+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));
+
+__sync_bool_compare_and_swap(&x1, x2, x3);
+
+return(0);
+}"
+HAVE_IB_ATOMIC_PTHREAD_T_GCC)
- __sync_bool_compare_and_swap(&x1, x2, x3);
-
- 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()
Attachment:
signature.asc
Description: OpenPGP digital signature
References