Bug #113126 Contribution: libmysql: workaround missing res_n* functions on e.g. musl
Submitted: 17 Nov 2023 18:54 Modified: 20 Nov 2023 11:27
Reporter: OCA Admin (OCA) Email Updates:
Status: Analyzing Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[17 Nov 2023 18:54] OCA Admin
Description:
This bug tracks a contribution by Sam James (Github user: thesamesam) as described in http://github.com/mysql/mysql-server/pull/505

How to repeat:
See description

Suggested fix:
See contribution code attached
[17 Nov 2023 18:54] OCA Admin
Contribution submitted via Github - libmysql: workaround missing res_n* functions on e.g. musl 
(*) Contribution by Sam James (Github thesamesam, mysql-server/pull/505#issuecomment-1814854142): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_1602229674.txt (text/plain), 2.34 KiB.

[20 Nov 2023 11:27] MySQL Verification Team
Hi,

Please, when you create bug reports for the OCA contributions, do not leave them in "Open" status.
[20 Nov 2023 11:43] Sam James
I wasn't aware I even had permissions to change the bug status, but I didn't create it anyway - the bot did.
[20 Jan 2024 17:23] Terje Røsten
Seems issue was resolved by:

 https://github.com/mysql/mysql-server/commit/dc6b9e2556bf247cda80670b824cb24b271946f2

present in MySQL 8.0.36.

Can you check if this version works for you?
[22 Jan 2024 6:57] Daniël van Eeden
Building MySQL 8.0.36 with the steps from https://bugs.mysql.com/bug.php?id=112995 works for me on Alpine Linux with musl.

The steps:
  docker run -it alpine:latest
  apk add perl gcc perl-app-cpanminus perl-devel-checklib perl-dbi make gcompat openssl openssl-dev libpthread-stubs build-base perl-dev libaio libnsl libc6-compat cmake ncurses-dev libtirpc-dev libtirpc rpcgen
  wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.36.tar.gz
  tar zxf mysql-8.0.36.tar.gz 
  rm mysql-8.0.36.tar.gz
  cd mysql-8.0.36
  mkdir build
  cd build
  cmake -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/boost -DWITHOUT_SERVER=ON -DWITH_BUILD_ID=OFF ..
  make -j4

Result:
  /mysql-8.0.36/build # ./runtime_output_directory/mysql --version
  ./runtime_output_directory/mysql  Ver 8.0.36 for Linux on x86_64 (Source distribution)
  /mysql-8.0.36/build # file ./runtime_output_directory/mysql
  ./runtime_output_directory/mysql: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, with debug_info, not stripped
  /mysql-8.0.36/build # ldd ./runtime_output_directory/mysql
	  /lib/ld-musl-x86_64.so.1 (0x7f6d31907000)
	  libssl.so.3 => /lib/libssl.so.3 (0x7f6d31881000)
	  libcrypto.so.3 => /lib/libcrypto.so.3 (0x7f6d30a00000)
	  libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x7f6d3182d000)
	  libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f6d30600000)
	  libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f6d3180f000)
	  libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f6d31907000)

Thanks!
[22 Jan 2024 7:14] Sam James
I would've preferred my version as it was more portable rather than checking for Alpine Linux (it's not the only musl distro), but we can spoof the test on our end for musl systems, so it should be fine.

I would still ask you to consider my patch in light of that, but I won't insist.