8000 build: link libucontext for Alpine by DifferentialOrange · Pull Request #66 · tarantool/mysql · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

build: link libucontext for Alpine #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

DifferentialOrange
Copy link
Member

Fibers library requires 'makecontext', 'getcontext', 'setcontext' and 'swapcontext' symbols. There are no such symbols in Alpine musl c library implementation [1]: third party library expected to be used for them. This patch adds PkgConfig and libucontext requirement to CMake if ucontext wasn't found in libc and libucontext linking.

  1. https://www.openwall.com/lists/musl/2018/01/29/2

Closes #65

Fibers library requires 'makecontext', 'getcontext', 'setcontext' and
'swapcontext' symbols. There are no such symbols in Alpine musl
c library implementation [1]: third party library expected to be used
for them. This patch adds PkgConfig and libucontext requirement to CMake
if ucontext wasn't found in libc and libucontext linking.

1. https://www.openwall.com/lists/musl/2018/01/29/2

Closes #65
@Totktonada
Copy link
Member

It seems, those functions are needed only for the asynchronous API. We don't use this API (instead we use syncronous API with our own socket ready check). Can we just disable the async API / ucontext dependency?

If we'll keep the dependency, can we solve the problem on the mariadb-connector-c side? Maybe it was already solved in the upstream and we can just backport a patch. Did you look over the issue tracker?

I don't mind current solution, though.

@DifferentialOrange DifferentialOrange requested review from 0x501D and removed request for LeonidVas July 28, 2022 10:42
@0x501D
Copy link
Member
0x501D commented Jul 28, 2022

It seems, those functions are needed only for the asynchronous API. We don't use this API (instead we use syncronous API with our own socket ready check). Can we just disable the async API / ucontext dependency?

If we'll keep the dependency, can we solve the problem on the mariadb-connector-c side? Maybe it was already solved in the upstream and we can just backport a patch. Did you look over the issue tracker?

I don't mind current solution, though.

from mariadb-connector-c:

cmake/CheckFunctions.cmake

IF(HAVE_FILE_UCONTEXT_H)
  CHECK_FUNCTION_EXISTS (makecontext HAVE_UCONTEXT_H)
ENDIF()

include/ma_context.h

#ifdef _WIN32                                                                   
#define MY_CONTEXT_USE_WIN32_FIBERS 1                                           
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__x86_64__) && !defined(__ILP32__)
#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 

libmariadb/ma_context.c

#ifdef MY_CONTEXT_USE_UCONTEXT 
....
  makecontext(&c->spawned_context, my_context_spawn_internal, 2,                
              u.a[0], u.a[1]); 
...
#endif

Thus, on the aarch64 architecture, if ucontext.h is found library calls will be used.
In your case, the headers are located but there is no actual implementation of the functions.

@Totktonada
Copy link
Member

They're exist, okay. It does not mean that they're called. Again, we don't use the API, which calls them.

@DifferentialOrange
Copy link
Member Author

There is a discussion in mariadb jira: https://jira.mariadb.org/browse/MDEV-13775 , but I don't see a way to fix this without changing mariadbconnector sources (I'm not really experienced in CMake btw). I also haven't found any flags to disable async in mariadbconnector build.

Copy link
Member
@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so.

@DifferentialOrange DifferentialOrange merged commit 1ea04a2 into master Jul 29, 2022
@DifferentialOrange DifferentialOrange deleted the DifferentialOrange/gh-65-apline-aarch64 branch July 29, 2022 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alpine on aarch64 error "swapcontext: symbol not found"
3 participants
0