Skip to content

Commit a0f6a14

Browse files
committed
Bug#25945568: MYSQL 5.7 FAILS TO BUILD WITH MUSL LIBC
DUE TO NOT FINDING SIGEV_THREAD_ID The problem was that posix_timers relied on non-posix standard features which made the code not compile on Alpine Linux. This patch rewrites the code to use standard posix. This means that the ~same code can also be used on Solaris. Also fix various minor other issues for compiling on Alpine.
1 parent 4ee6e97 commit a0f6a14

File tree

13 files changed

+31
-316
lines changed

13 files changed

+31
-316
lines changed

cmake/os/WindowsCache.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ SET(HAVE_LRAND48 CACHE INTERNAL "")
149149
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
150150
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
151151
SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
152-
SET(HAVE_SIGEV_THREAD_ID CACHE INTERNAL "")
153-
SET(HAVE_SIGEV_PORT CACHE INTERNAL "")
154152

155153
SET(HAVE_C_ISINF TRUE CACHE INTERNAL "") # Only needed by CMake
156154
SET(HAVE_CXX_ISINF TRUE CACHE INTERNAL "") # Only needed by CMake

config.h.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@
146146
#cmakedefine GWINSZ_IN_SYS_IOCTL 1
147147
#cmakedefine FIONREAD_IN_SYS_IOCTL 1
148148
#cmakedefine FIONREAD_IN_SYS_FILIO 1
149-
#cmakedefine HAVE_SIGEV_THREAD_ID 1
150-
#cmakedefine HAVE_SIGEV_PORT 1
151149

152150
#cmakedefine HAVE_ISINF 1
153151

configure.cmake

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,6 @@ CHECK_SYMBOL_EXISTS(lrand48 "stdlib.h" HAVE_LRAND48)
434434
CHECK_SYMBOL_EXISTS(TIOCGWINSZ "sys/ioctl.h" GWINSZ_IN_SYS_IOCTL)
435435
CHECK_SYMBOL_EXISTS(FIONREAD "sys/ioctl.h" FIONREAD_IN_SYS_IOCTL)
436436
CHECK_SYMBOL_EXISTS(FIONREAD "sys/filio.h" FIONREAD_IN_SYS_FILIO)
437-
CHECK_SYMBOL_EXISTS(SIGEV_THREAD_ID "signal.h;time.h" HAVE_SIGEV_THREAD_ID)
438-
CHECK_SYMBOL_EXISTS(SIGEV_PORT "signal.h;time.h;sys/siginfo.h" HAVE_SIGEV_PORT)
439437

440438
# On Solaris, it is only visible in C99 mode
441439
CHECK_SYMBOL_EXISTS(isinf "math.h" HAVE_C_ISINF)
@@ -463,9 +461,7 @@ CHECK_SYMBOL_EXISTS(EVFILT_TIMER "sys/types.h;sys/event.h;sys/time.h" HAVE_EVFIL
463461
IF(HAVE_KQUEUE AND HAVE_EVFILT_TIMER)
464462
SET(HAVE_KQUEUE_TIMERS 1 CACHE INTERNAL "Have kqueue timer-related filter")
465463
ELSEIF(HAVE_TIMER_CREATE AND HAVE_TIMER_SETTIME)
466-
IF(HAVE_SIGEV_THREAD_ID OR HAVE_SIGEV_PORT)
467-
SET(HAVE_POSIX_TIMERS 1 CACHE INTERNAL "Have POSIX timer-related functions")
468-
ENDIF()
464+
SET(HAVE_POSIX_TIMERS 1 CACHE INTERNAL "Have POSIX timer-related functions")
469465
ENDIF()
470466

471467
IF(NOT HAVE_POSIX_TIMERS AND NOT HAVE_KQUEUE_TIMERS AND NOT WIN32)

include/my_timer.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222

2323
#include "my_config.h"
24-
#include "my_macros.h"
2524

2625
struct st_my_timer;
2726

@@ -54,13 +53,11 @@ struct st_my_timer
5453
void (*notify_function)(my_timer_t *);
5554
};
5655

57-
C_MODE_START
58-
5956
/* Initialize internal components. */
60-
int my_timer_initialize(void);
57+
int my_timer_initialize();
6158

6259
/* Release any resources acquired. */
63-
void my_timer_deinitialize(void);
60+
void my_timer_deinitialize();
6461

6562
/* Create a timer object. */
6663
int my_timer_create(my_timer_t *timer);
@@ -74,6 +71,4 @@ int my_timer_cancel(my_timer_t *timer, int *state);
7471
/* Delete a timer object. */
7572
void my_timer_delete(my_timer_t *timer);
7673

77-
C_MODE_END
78-
7974
#endif /* MY_TIMER_H */

libmysql/libmysql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#include <sys/select.h>
5959
#endif
6060
#ifdef HAVE_POLL
61-
#include <sys/poll.h>
61+
#include <poll.h>
6262
#endif
6363
#ifdef HAVE_SYS_UN_H
6464
#include <sys/un.h>

mysql-test/suite/sysschema/r/pr_ps_setup_show_enabled.result

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ UPDATE performance_schema.threads
1414
SET INSTRUMENTED = 'NO'
1515
WHERE NAME LIKE 'thread/innodb/srv\_%'
1616
OR NAME LIKE '%con\_%'
17-
OR NAME LIKE '%signal_handler%';
17+
OR NAME LIKE '%signal_handler%'
18+
OR NAME LIKE '%thread_timer_notifier';
1819
CALL sys.ps_setup_show_enabled(FALSE, FALSE);
1920
performance_schema_enabled
2021
1
@@ -220,7 +221,6 @@ innodb/io_write_thread BACKGROUND
220221
innodb/io_write_thread BACKGROUND
221222
innodb/io_write_thread BACKGROUND
222223
innodb/page_flush_coordinator_thread BACKGROUND
223-
mysys/thread_timer_notifier BACKGROUND
224224
root@localhost FOREGROUND
225225
sql/compress_gtid_table FOREGROUND
226226
sql/main BACKGROUND
@@ -264,7 +264,6 @@ innodb/io_write_thread BACKGROUND
264264
innodb/io_write_thread BACKGROUND
265265
innodb/io_write_thread BACKGROUND
266266
innodb/page_flush_coordinator_thread BACKGROUND
267-
mysys/thread_timer_notifier BACKGROUND
268267
root@localhost FOREGROUND
269268
sql/compress_gtid_table FOREGROUND
270269
sql/main BACKGROUND

mysql-test/suite/sysschema/t/pr_ps_setup_show_enabled.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ UPDATE performance_schema.threads
2424
SET INSTRUMENTED = 'NO'
2525
WHERE NAME LIKE 'thread/innodb/srv\_%'
2626
OR NAME LIKE '%con\_%'
27-
OR NAME LIKE '%signal_handler%';
27+
OR NAME LIKE '%signal_handler%'
28+
OR NAME LIKE '%thread_timer_notifier';
2829

2930
# Show limited info (no thread or instrument info)
3031
CALL sys.ps_setup_show_enabled(FALSE, FALSE);

mysql-test/t/max_statement_time.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
--source include/have_statement_timeout.inc
44
--source include/have_debug.inc
5-
--source include/not_valgrind.inc
65

76
# Save the initial number of concurrent sessions.
87
--source include/count_sessions.inc

mysql-test/valgrind.supp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
pthread allocate_tls memory loss
2626
Memcheck:Leak
2727
fun:calloc
28+
...
2829
fun:_dl_allocate_tls
2930
fun:allocate_stack
3031
fun:pthread_create*

mysys/my_error.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ char *my_strerror(char *buf, size_t len, int nr)
141141
(defined _XOPEN_SOURCE && (_XOPEN_SOURCE >= 600))) && \
142142
! defined _GNU_SOURCE
143143
strerror_r(nr, buf, len); /* I can build with or without GNU */
144-
#elif defined _GNU_SOURCE && (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
144+
#elif defined(__GLIBC__) && defined (_GNU_SOURCE)
145145
char *r= strerror_r(nr, buf, len);
146146
if (r != buf) /* Want to help, GNU? */
147147
strmake(buf, r, len - 1); /* Then don't. */
@@ -154,8 +154,8 @@ char *my_strerror(char *buf, size_t len, int nr)
154154
strerror() return values are implementation-dependent, so let's
155155
be pragmatic.
156156
*/
157-
if (!buf[0])
158-
strmake(buf, "unknown error", len - 1);
157+
if (!buf[0] || !strcmp(buf, "No error information"))
158+
strmake(buf, "Unknown error", len - 1);
159159

160160
return buf;
161161
}

0 commit comments

Comments
 (0)