Bug #112995 MySQL fails to compile on Alpine Linux 3.18
Submitted: 7 Nov 2023 20:35 Modified: 8 Nov 2023 13:31
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.035 OS:Linux (Alpine Linux 3.18)
Assigned to: CPU Architecture:x86

[7 Nov 2023 20:35] Daniël van Eeden
Description:
The first issue:

/mysql-8.0.35/sql/memory/aligned_atomic.h: In function 'size_t memory::_cache_line_size()':
/mysql-8.0.35/sql/memory/aligned_atomic.h:82:23: error: '_SC_LEVEL1_DCACHE_LINESIZE' was not declared in this scope; did you mean 'CPU_LEVEL1_DCACHE_LINESIZE'?
   82 |   long size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                       CPU_LEVEL1_DCACHE_LINESIZE

This is easily fixed with making the suggested replacement.

The second problem is this:

/mysql-8.0.35/libmysql/dns_srv.cc: In function 'bool get_dns_srv(Dns_srv_data&, const char*, int&)':
/mysql-8.0.35/libmysql/dns_srv.cc:44:3: error: 'res_ninit' was not declared in this scope; did you mean 'res_init'?
   44 |   res_ninit(&state);
      |   ^~~~~~~~~
      |   res_init
/mysql-8.0.35/libmysql/dns_srv.cc:50:13: error: 'res_nsearch' was not declared in this scope; did you mean 'res_search'?
   50 |   int res = res_nsearch(&state, dnsname, ns_c_in, ns_t_srv, query_buffer,
      |             ^~~~~~~~~~~
      |             res_search
/mysql-8.0.35/libmysql/dns_srv.cc:87:3: error: 'res_nclose' was not declared in this scope
   87 |   res_nclose(&state);
      |   ^~~~~~~~~~

How to repeat:
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.35.tar.gz
tar zxf mysql-8.0.35.tar.gz 
rm mysql-8.0.35.tar.gz
cd mysql-8.0.35
mkdir build
cd build
cmake -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/boost -DWITHOUT_SERVER=ON -DWITH_BUILD_ID=OFF ..
make -j4
[7 Nov 2023 20:42] Daniël van Eeden
Note that https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-2.html#mysqld-8-0-2-compiling has a note about compilation on Alpine.
[8 Nov 2023 11:16] MySQL Verification Team
HI Mr. Eeden,

Thank you for your bug report.

We would like to inform you that we do not support Alpine Linux, any version.

Hence, it is of utmost importance that you let us know what cmake command line options have you used, before you have ran the `make` commands.

If you are using all the correct cmake commands then we do not know how to help you, since we do not support this Linux variant.

Thanks in advance.
[8 Nov 2023 12:25] Daniël van Eeden
The orignal report had the cmake commandline, here it is again:

cmake -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/boost -DWITHOUT_SERVER=ON -DWITH_BUILD_ID=OFF ..
[8 Nov 2023 12:40] MySQL Verification Team
HI,

Yes, we saw the original cmake ........

Are you sure that this is the entire cmake configuration ???

Can you try downloading the package with boost 1_77_0 included ???

Next, we have never got the error on SC_LEVEL1_DCACHE_LINESIZE, nor about nres_*

This opens the possibility that cmake needs additional options on your Linux variant.

Also, on an unrelated issue, do you use gcc or clang and is it the last stable release ????
[8 Nov 2023 13:21] MySQL Verification Team
Looks like
https://bugs.mysql.com/bug.php?id=110808
[8 Nov 2023 13:31] MySQL Verification Team
Hi Daniel,

Your bug is a duplicate of the bug:

https://bugs.mysql.com/bug.php?id=110808