Skip to content

Commit dc6b9e2

Browse files
author
Tor Didriksen
committed
Bug#35330950 Contribution: sql/memory: Fix build on musl
Misc. fixes for Alpine Linux: - disable build-id - disable compiler option -ftls-model=initial-exec - add missing include of libgen.h - DNS resolver functions - include <unistd.h> rather than <sys/unistd.h> - include <sys/stat.h> to get definition of mode_t - misc sysconf() macros are only available with __GLIBC__ - no backtrace/stacktrace on Alpine Linux - disable the unit test for segfault The list of packages required or useful to build on Alpine: - BOOST version boost_1_77_0 - bash - bison - build-base - cmake - curl-dev - cyrus-sasl-dev - cyrus-sasl-scram - emacs - gcc - gcompat - git - git-review - libaio - libc6-compat - libfido2-dev - libnsl - libpthread-stubs - libtirpc - libtirpc-dev - libudev-zero-dev - linux-headers - ncurses-dev - openldap-dev make - openssl - openssl-dev - perl - perl-app-cpanminus - perl-dbi - perl-dev - perl-devel-checklib - perl-expect - perl-json - protobuf-dev - rpcgen - zip Change-Id: Iec8fc1617eb3fece5152b9b2a1221da45510562d (cherry picked from commit 4cecfd91a6e8e1b29e835ca17e3da4c94065908f)
1 parent c816527 commit dc6b9e2

File tree

8 files changed

+30
-5
lines changed

8 files changed

+30
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ IF(WITH_DEFAULT_COMPILER_OPTIONS)
789789
ENDIF()
790790

791791
# Assume, for now at least, that we want build-id for all kinds of Linux builds.
792-
IF(LINUX)
792+
IF(LINUX AND NOT LINUX_ALPINE)
793793
OPTION(WITH_BUILD_ID "Add --build-id=sha1 to all executables." ON)
794794
IF(WITH_BUILD_ID)
795795
SET(HAVE_BUILD_ID_SUPPORT 1)

cmake/build_configurations/compiler_options.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ IF(UNIX)
6565
ENDIF()
6666

6767
# Faster TLS model
68-
IF(MY_COMPILER_IS_GNU_OR_CLANG AND NOT SOLARIS AND NOT LINUX_RHEL6)
68+
IF(MY_COMPILER_IS_GNU_OR_CLANG
69+
AND NOT SOLARIS AND NOT LINUX_RHEL6 AND NOT LINUX_ALPINE)
6970
STRING_APPEND(COMMON_C_FLAGS " -ftls-model=initial-exec")
7071
STRING_APPEND(COMMON_CXX_FLAGS " -ftls-model=initial-exec")
7172
ENDIF()

libmysql/dns_srv.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,24 @@
4040
// POSIX version
4141

4242
static bool get_dns_srv(Dns_srv_data &data, const char *dnsname, int &error) {
43+
#ifdef LINUX_ALPINE
44+
res_init();
45+
#else
4346
struct __res_state state {};
4447
res_ninit(&state);
48+
#endif
4549
unsigned char query_buffer[NS_PACKETSZ];
4650
bool ret = true;
4751

4852
data.clear();
4953

54+
#ifdef LINUX_ALPINE
55+
int res = res_search(dnsname, ns_c_in, ns_t_srv, query_buffer,
56+
sizeof(query_buffer));
57+
#else
5058
int res = res_nsearch(&state, dnsname, ns_c_in, ns_t_srv, query_buffer,
5159
sizeof(query_buffer));
52-
60+
#endif
5361
if (res >= 0) {
5462
ns_msg msg;
5563
ns_initparse(query_buffer, res, &msg);
@@ -84,7 +92,11 @@ static bool get_dns_srv(Dns_srv_data &data, const char *dnsname, int &error) {
8492
error = h_errno;
8593
}
8694

95+
#ifdef LINUX_ALPINE
96+
// nothing
97+
#else
8798
res_nclose(&state);
99+
#endif
88100
return ret;
89101
}
90102

router/src/harness/include/mysql/harness/access_rights.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#else
3333
#include <sys/stat.h> // stat
3434
#include <sys/types.h>
35-
#include <sys/unistd.h>
35+
#include <unistd.h>
3636
#endif
3737

3838
#include <optional>

router/src/router/include/mysqlrouter/utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#include "mysqlrouter/router_export.h"
2929

30+
#include <sys/stat.h> // mode_t
31+
3032
#include <chrono>
3133
#include <cstdint>
3234
#include <functional>

sql/memory/aligned_atomic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static inline size_t _cache_line_size() {
7777
return line_size;
7878
}
7979

80-
#elif defined(__linux__)
80+
#elif defined(__GLIBC__)
8181
static inline size_t _cache_line_size() {
8282
long size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
8383
if (size == -1) return 64;

storage/ndb/src/common/portlib/ndb_stacktrace.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
#include <link.h>
3737
#endif
3838

39+
#ifdef HAVE_STACKTRACE
3940
static unsigned long long ndb_get_program_base_address();
41+
#endif
4042

4143
void ndb_init_stacktrace() {
4244
#ifdef HAVE_STACKTRACE
@@ -76,6 +78,8 @@ unsigned long long ndb_get_program_base_address() {
7678
#elif defined(_WIN32)
7779
unsigned long long ndb_get_program_base_address() { return ULLONG_MAX; }
7880
#else
81+
82+
#ifdef HAVE_STACKTRACE
7983
static int ndb_get_program_base_address_callback(struct dl_phdr_info *info,
8084
size_t /* size */,
8185
void *data) {
@@ -90,6 +94,8 @@ unsigned long long ndb_get_program_base_address() {
9094
dl_iterate_phdr(&ndb_get_program_base_address_callback, callback_data);
9195
return base_address;
9296
}
97+
#endif // HAVE_STACKTRACE
98+
9399
#endif
94100

95101
#endif

unittest/gunit/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ SET(SERVER_TESTS
307307
xid_extract
308308
log_event_status_size
309309
)
310+
# Endless loop in FatalSignalDeathTest
311+
IF(LINUX_ALPINE)
312+
LIST(REMOVE_ITEM SERVER_TESTS segfault)
313+
ENDIF()
310314

311315
IF(MY_COMPILER_IS_GNU AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12)
312316
ADD_COMPILE_FLAGS(regexp_engine-t.cc COMPILE_FLAGS "-Wno-restrict")

0 commit comments

Comments
 (0)