[MDEV-13775] cross compile fail on arm/mips musl Created: 2017-09-09  Updated: 2021-10-29

Status: Open
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 5.5.57
Fix Version/s: 5.5

Type: Bug Priority: Minor
Reporter: Lucian Cristian Assignee: Vicențiu Ciorbaru
Resolution: Unresolved Votes: 0
Labels: armhf, compile, mips, musl
Environment:

Linux LEDE/OpenWRT SDK



 Description   

trying to build mariadb 5.5.x on arm/mips targets with musl it gives me the following error

*../libmysql/libmysqlclient.a(my_context.c.o): In function `my_context_spawn_internal':
my_context.c:(.text+0x3c): undefined reference to `setcontext'
my_context.c:(.text+0x40): undefined reference to `setcontext'
../libmysql/libmysqlclient.a(my_context.c.o): In function `my_context_continue':
my_context.c:(.text+0xa4): undefined reference to `swapcontext'
my_context.c:(.text+0xc4): undefined reference to `swapcontext'
../libmysql/libmysqlclient.a(my_context.c.o): In function `my_context_spawn':
my_context.c:(.text+0x140): undefined reference to `getcontext'
my_context.c:(.text+0x15c): undefined reference to `getcontext'
my_context.c:(.text+0x180): undefined reference to `makecontext'
my_context.c:(.text+0x1c0): undefined reference to `makecontext'
../libmysql/libmysqlclient.a(my_context.c.o): In function `my_context_yield':
my_context.c:(.text+0x204): undefined reference to `swapcontext'
my_context.c:(.text+0x218): undefined reference to `swapcontext'
collect2: error: ld returned 1 exit status*

with glibc it works properly, x86_64 and i386 are also working with musl and glibc

patching the my_context.h file like this

@@ -31,8 +31,6 @@
 #define MY_CONTEXT_USE_X86_64_GCC_ASM
 #elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__)
 #define MY_CONTEXT_USE_I386_GCC_ASM
-#elif defined(HAVE_UCONTEXT_H)
-#define MY_CONTEXT_USE_UCONTEXT
 #else
 #define MY_CONTEXT_DISABLE
 #endif

is working, what could be the right approach ?



 Comments   
Comment by Sergei Golubchik [ 2017-09-09 ]

Does it mean that you have <ucontext.h>, but it is not usable?

If yes, I'd say the correct approach is to check in CMakeLists.txt whether ucontext.h is usable. In configure.cmake there's a check:

CHECK_INCLUDE_FILE(ucontext.h HAVE_UCONTEXT_H)
IF(NOT HAVE_UCONTEXT_H)
  CHECK_INCLUDE_FILE(sys/ucontext.h HAVE_UCONTEXT_H)
ENDIF()

and instead of (or together with) this it should use CHECK_C_SOURCE_COMPILES.

Comment by Lucian Cristian [ 2017-09-09 ]

cat CMakeCache.txt | grep UCONTEXT
HAVE_UCONTEXT_H:INTERNAL=1

in gcc-5.4.0/fixincludes/tests/base/sys I have

cat ucontext.h

/* DO NOT EDIT THIS FILE.

It has been auto-edited by fixincludes from:

"fixinc/tests/inc/sys/ucontext.h"

This had to be done to correct non-standard usages in the
original, manufacturer supplied header file. */

#if defined( LINUX_IA64_UCONTEXT_CHECK )

  1. define _SC_GR0_OFFSET \
    __builtin_offsetof (struct sigcontext, sc_gr[0])

#endif /* LINUX_IA64_UCONTEXT_CHECK */
in config.h I have this

#define HAVE_UCONTEXT_H 1


PS: I don;t know why formatting is not working for me

Comment by Sergei Golubchik [ 2017-09-09 ]

Yes, so HAVE_UCONTEXT_H is set, but apparently it cannot be used. The fix is to test it in configure.cmake.

Your formatting didn't work because {{ ... }} is for inline code, for multi-line code snippets use {code} ... {code}.

Comment by Lucian Cristian [ 2017-09-09 ]

so if it can't be used I think is safe to assume MY_CONTEXT_DISABLE and use the patch above in building the image without messing with configure.cmake
?
I don't know how to test for the functionality and maybe this is a musl problem and not on mariadb side

Comment by Daniel Black [ 2021-10-29 ]

Yes. You're probably right both counts. This looks like something musl would omit.

Generated at Thu Feb 08 08:08:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.