Summary: | dev-db/mysql-connector-c-8.0.22 does not compile on musl | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Marco Rebhan <me> |
Component: | Current packages | Assignee: | Gentoo musl team <musl> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | brahmajit.xyz, grobian, jstein, mysql-bugs, sam, stijn+gentoo, toralf |
Priority: | Normal | Keywords: | PullRequest |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://bugs.mysql.com/bug.php?id=106034 | ||
See Also: |
https://github.com/gentoo/gentoo/pull/26353 https://github.com/mysql/mysql-server/pull/385 https://bugs.gentoo.org/show_bug.cgi?id=863188 https://github.com/mysql/mysql-server/pull/505 |
||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | 864779 | ||
Bug Blocks: | 430702 | ||
Attachments: |
build.log
mysql-connector-c musl patch |
Description
Marco Rebhan
2020-12-23 11:54:31 UTC
Created attachment 679302 [details]
build.log
Created attachment 710094 [details, diff]
mysql-connector-c musl patch
This is harder to solve, it requires detection for availability of the res_n* suite of functions.
As a workaround to make this somewhat operational you can apply this (conditional) patch
Nice, that at least makes it compile. Unfortunately I can't test how well it works since I don't actually use mysql on this box. Thanks! My attempt at upstreaming a fix: https://github.com/mysql/mysql-server/pull/385 hmmm, is res_ninit supposed to be defined as macro? At least on solaris it's a function, so this patch wouldn't work there *** This bug has been marked as a duplicate of bug 713370 *** *** Bug 713370 has been marked as a duplicate of this bug. *** (In reply to Fabian Groffen from comment #5) > hmmm, is res_ninit supposed to be defined as macro? At least on solaris > it's a function, so this patch wouldn't work there Fabian do you think something like this would be okay? I modified Stijn Tintel's PR a little bit. diff --git a/libmysql/dns_srv.cc b/libmysql/dns_srv.cc index dec43644..3223274a 100644 --- a/libmysql/dns_srv.cc +++ b/libmysql/dns_srv.cc @@ -41,14 +41,21 @@ static bool get_dns_srv(Dns_srv_data &data, const char *dnsname, int &error) { struct __res_state state {}; +#if defined(__GLIBC__) res_ninit(&state); +#endif unsigned char query_buffer[NS_PACKETSZ]; bool ret = true; data.clear(); +#if defined(__GLIBC__) int res = res_nsearch(&state, dnsname, ns_c_in, ns_t_srv, query_buffer, sizeof(query_buffer)); +#else + int res = res_search(dnsname, ns_c_in, ns_t_srv, query_buffer, + sizeof(query_buffer)); +#endif if (res >= 0) { ns_msg msg; @@ -84,7 +91,9 @@ static bool get_dns_srv(Dns_srv_data &data, const char *dnsname, int &error) { error = h_errno; } +#if defined(__GLIBC__) res_nclose(&state); +#endif return ret; } I personally feel you better take a look at my patch in that case, since it would allow easier/more localised updating of the defines. Darwin and Solaris for instance defines the n* variants as well, so disabling there because musl doesn't have them is a waste. (In reply to Fabian Groffen from comment #9) > I personally feel you better take a look at my patch in that case, since it > would allow easier/more localised updating of the defines. Darwin and > Solaris for instance defines the n* variants as well, so disabling there > because musl doesn't have them is a waste. Can you make a version which can be applied unconditionally? no: (In reply to Fabian Groffen from comment #2) > Created attachment 710094 [details, diff] [details, diff] > mysql-connector-c musl patch > > This is harder to solve, it requires detection for availability of the > res_n* suite of functions. > > As a workaround to make this somewhat operational you can apply this > (conditional) patch I don't know how to do AC_CHECK_FUNCS with cmake. (In reply to Fabian Groffen from comment #11) > I don't know how to do AC_CHECK_FUNCS with cmake. Oh, right. I didn't take your original comment to say that you didn't know how, I thought it was more as a proof of concept pending comment from maintainers. (In reply to Fabian Groffen from comment #9) > I personally feel you better take a look at my patch in that case, since it > would allow easier/more localised updating of the defines. Darwin and > Solaris for instance defines the n* variants as well, so disabling there > because musl doesn't have them is a waste. Okay, got you Fabian, and sorry for late reply was not in cc list. I couldn't you configure.ac, but used CMake to add in your patch conditionally. See if it looks any better diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 1bd8bd54..ac0d0937 100644 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -423,6 +423,10 @@ IF(HAS_WARN_FLAG) ) ENDIF() +check_symbol_exists(res_ninit "resolv.h" HAVE_RES_NINIT_FUNCTION) +check_symbol_exists(res_nsearch "resolv.h" HAVE_RES_NSEARCH_FUNCTION) +check_symbol_exists(res_nclose "resolv.h" HAVE_RES_NCLOSE_FUNCTION) + # Verify that libmysql_api_test runs OK ADD_CUSTOM_COMMAND(TARGET libmysql_api_test POST_BUILD COMMAND libmysql_api_test diff --git a/libmysql/dns_srv.cc b/libmysql/dns_srv.cc index dec43644..f5c8f6f6 100644 --- a/libmysql/dns_srv.cc +++ b/libmysql/dns_srv.cc @@ -37,6 +37,16 @@ #include <netdb.h> #include <resolv.h> +#if !defined(HAVE_RES_NINIT_FUNCTION) +#define res_ninit(X) (void)X +#endif +#if !defined(HAVE_RES_NSEARCH_FUNCTION) +#define res_nsearch(X,D,I,S,B,L) res_search(D,I,S,B,L) +#endif +#if !define(HAVE_RES_NCLOSE_FUNCTION) +#define res_nclose(X) (void)X +#endif + // POSIX version static bool get_dns_srv(Dns_srv_data &data, const char *dnsname, int &error) { If that does the trick of setting the define when necessary, then this is most likely the best way, and perhaps acceptable upstream. I'm not in the position to test at this point, but I'll try to remember to do so. Thanks! (In reply to Fabian Groffen from comment #14) > If that does the trick of setting the define when necessary, then this is > most likely the best way, and perhaps acceptable upstream. I'm not in the > position to test at this point, but I'll try to remember to do so. Thanks! I'm doing the test :) (In reply to Fabian Groffen from comment #14) > If that does the trick of setting the define when necessary, then this is > most likely the best way, and perhaps acceptable upstream. I'm not in the > position to test at this point, but I'll try to remember to do so. Thanks! Yep, built fine. However it would be very helpful if someone explained a bit what the macro "#define res_nclose(X) (void)X" is doing (In reply to listout from comment #17) > However it would be very helpful if someone explained a bit what the macro > "#define res_nclose(X) (void)X" is doing There is nothing to close when no state is being used, so could have also defined it empty, but to avoid a compiler warning about an unused variable, I do a (void)-cast, which is a common way to pacify the compiler. (In reply to Fabian Groffen from comment #18) > (In reply to listout from comment #17) > > However it would be very helpful if someone explained a bit what the macro > > "#define res_nclose(X) (void)X" is doing > > There is nothing to close when no state is being used, so could have also > defined it empty, but to avoid a compiler warning about an unused variable, > I do a (void)-cast, which is a common way to pacify the compiler. Thanks! There is flaw in this patch. Works fines on musl, but complains on glibc about redefinition. The way I was doing checking through CMakeLists.txt is wrong. I'll have to update. The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0f7808b289d1eb16cef25c2de6411cc580b97c5c commit 0f7808b289d1eb16cef25c2de6411cc580b97c5c Author: brahmajit das <brahmajit.xyz@gmail.com> AuthorDate: 2022-07-15 05:52:59 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2022-07-15 07:10:07 +0000 dev-db/mysql-connector-c: Use res_n* functions only on GLIBC The issue occurs because the package tries to use the res_n* functions (specifically res_ninit, res_nsearch and res_nclose) from resolv.h which do not exist when using musl. So we are falling back to non-thread-safe functions from resolv.h Closes: https://bugs.gentoo.org/761352 Signed-off-by: brahmajit das <brahmajit.xyz@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/26353 Signed-off-by: Sam James <sam@gentoo.org> .../files/mysql-connector-c-8.0.27-res_n.patch | 49 ++++++++ .../mysql-connector-c-8.0.27-r1.ebuild | 123 +++++++++++++++++++++ 2 files changed, 172 insertions(+) |