Skip to content

Commit d4816ce

Browse files
author
Daniel Blanchard
committed
Bug #16021844: ABI CHECK NOT IMPLEMENTED ON WINDOWS
Implement ABI check run on windows using WSL (gcc and sed). RB#27025
1 parent 0e4e7c4 commit d4816ce

File tree

7 files changed

+98
-64
lines changed

7 files changed

+98
-64
lines changed

Diff for: cmake/abi_check.cmake

+54-39
Original file line numberDiff line numberDiff line change
@@ -18,78 +18,93 @@
1818
#
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program; if not, write to the Free Software
21-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22-
21+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22+
2323
#
2424
# Headers which need to be checked for abi/api compatibility are in
2525
# API_PREPROCESSOR_HEADER. plugin.h is tested implicitly via
2626
# plugin_audit.h and plugin_ftparser.h.
2727
#
28-
# We use gcc specific preprocessing command and sed/diff, so it will
29-
# only be run on Unix and only if gcc is used. On some Unixes,
30-
# (Solaris) sed or diff might act differently from GNU, so we run only
28+
# We use gcc specific preprocessing command and sed/diff, so it will
29+
# only be run on Unix and only if gcc is used. On some Unixes,
30+
# (Solaris) sed or diff might act differently from GNU, so we run only
3131
# on systems we can trust.
32+
# On Windows we use the Windows subsystem for Linux and gcc and sed
33+
# installed in it, if available.
3234
IF(LINUX)
3335
SET(RUN_ABI_CHECK 1)
36+
ELSEIF(WIN32)
37+
FIND_PROGRAM(WSL_EXECUTABLE wsl HINTS C:/Windows/Sysnative)
38+
IF (WSL_EXECUTABLE)
39+
SET (COMPILER "gcc")
40+
SET(RUN_ABI_CHECK 1)
41+
MESSAGE(STATUS "Will do ABI check using ${WSL_EXECUTABLE} (gcc/sed)")
42+
ELSE()
43+
SET(RUN_ABI_CHECK 0)
44+
ENDIF()
3445
ELSE()
3546
SET(RUN_ABI_CHECK 0)
3647
ENDIF()
3748

38-
IF(MY_COMPILER_IS_GNU AND RUN_ABI_CHECK)
49+
SET(API_PREPROCESSOR_HEADER
50+
${CMAKE_SOURCE_DIR}/include/mysql/plugin_audit.h
51+
${CMAKE_SOURCE_DIR}/include/mysql/plugin_ftparser.h
52+
${CMAKE_SOURCE_DIR}/include/mysql.h
53+
${CMAKE_SOURCE_DIR}/include/mysql/client_plugin.h
54+
${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h
55+
${CMAKE_SOURCE_DIR}/include/mysql/plugin_keyring.h
56+
)
57+
IF(NOT WITHOUT_SERVER)
58+
SET(API_PREPROCESSOR_HEADER
59+
${API_PREPROCESSOR_HEADER}
60+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_thread_v1.h
61+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_mutex_v1.h
62+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_rwlock_v1.h
63+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_cond_v1.h
64+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_file_v1.h
65+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_socket_v1.h
66+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_table_v1.h
67+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_mdl_v1.h
68+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_idle_v1.h
69+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_stage_v1.h
70+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_statement_v1.h
71+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_transaction_v1.h
72+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_memory_v1.h
73+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_error_v1.h
74+
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_system_v1.h
75+
${CMAKE_SOURCE_DIR}/include/mysql/services.h
76+
)
77+
ENDIF()
78+
79+
IF(MY_COMPILER_IS_GNU)
3980
IF(CMAKE_C_COMPILER MATCHES "ccache$")
4081
SET(COMPILER ${CMAKE_C_COMPILER_ARG1})
4182
STRING(REGEX REPLACE "^ " "" COMPILER ${COMPILER})
4283
ELSE()
4384
SET(COMPILER ${CMAKE_C_COMPILER})
4485
ENDIF()
45-
SET(API_PREPROCESSOR_HEADER
46-
${CMAKE_SOURCE_DIR}/include/mysql/plugin_audit.h
47-
${CMAKE_SOURCE_DIR}/include/mysql/plugin_ftparser.h
48-
${CMAKE_SOURCE_DIR}/include/mysql.h
49-
${CMAKE_SOURCE_DIR}/include/mysql/client_plugin.h
50-
${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h
51-
${CMAKE_SOURCE_DIR}/include/mysql/plugin_keyring.h
52-
)
53-
IF(NOT WITHOUT_SERVER)
54-
SET(API_PREPROCESSOR_HEADER
55-
${API_PREPROCESSOR_HEADER}
56-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_thread_v1.h
57-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_mutex_v1.h
58-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_rwlock_v1.h
59-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_cond_v1.h
60-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_file_v1.h
61-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_socket_v1.h
62-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_table_v1.h
63-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_mdl_v1.h
64-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_idle_v1.h
65-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_stage_v1.h
66-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_statement_v1.h
67-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_transaction_v1.h
68-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_memory_v1.h
69-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_error_v1.h
70-
${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_system_v1.h
71-
${CMAKE_SOURCE_DIR}/include/mysql/services.h
72-
)
73-
ENDIF()
86+
ENDIF()
7487

88+
IF(RUN_ABI_CHECK)
7589
ADD_CUSTOM_TARGET(abi_check ALL
76-
COMMAND ${CMAKE_COMMAND}
90+
COMMAND ${CMAKE_COMMAND}
7791
-DCOMPILER=${COMPILER}
7892
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
7993
-DBINARY_DIR=${CMAKE_BINARY_DIR}
94+
-DWSL_EXECUTABLE=${WSL_EXECUTABLE}
8095
"-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
8196
-P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
8297
VERBATIM
8398
)
8499

85100
ADD_CUSTOM_TARGET(abi_check_all
86-
COMMAND ${CMAKE_COMMAND}
87-
-DCOMPILER=${COMPILER}
101+
COMMAND ${CMAKE_COMMAND}
102+
-DCOMPILER=${COMPILER}
88103
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
89104
-DBINARY_DIR=${CMAKE_BINARY_DIR}
105+
-DWSL_EXECUTABLE=${WSL_EXECUTABLE}
90106
"-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
91107
-P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
92108
VERBATIM
93109
)
94110
ENDIF()
95-

Diff for: cmake/do_abi_check.cmake

+31-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright (c) 2009, 2021, Oracle and/or its affiliates.
2-
#
2+
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
55
# as published by the Free Software Foundation.
@@ -18,7 +18,7 @@
1818
#
1919
# You should have received a copy of the GNU General Public License
2020
# along with this program; if not, write to the Free Software
21-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222

2323
#
2424
# Rules for checking that the abi/api has not changed.
@@ -31,7 +31,7 @@
3131
# results in messages in stderr saying that these headers
3232
# were not found. Redirect the stderr output to /dev/null
3333
# to prevent seeing these messages.
34-
# 2) sed the output to
34+
# 2) sed the output to
3535
# 2.1) remove blank lines and lines that begin with "# "
3636
# 2.2) When gcc -E is run on the Mac OS and solaris sparc platforms it
3737
# introduces a line of output that shows up as a difference between
@@ -53,25 +53,45 @@
5353
# leave a <build directory>/abi_check.out file.
5454
#
5555
# A developer with a justified API change will then do a
56-
# mv <build directory>/abi_check.out include/mysql/plugin.pp
56+
# mv <build directory>/abi_check.out include/mysql/plugin.pp
5757
# to replace the old canons with the new ones.
5858
#
5959

6060
SET(abi_check_out ${BINARY_DIR}/abi_check.out)
6161

62+
63+
SET(ABI_SOURCE_DIR ${SOURCE_DIR})
64+
SET(ABI_BINARY_DIR ${BINARY_DIR})
65+
66+
# If we're using WSL on Windows, we have to translate paths using wslpath
67+
IF(WSL_EXECUTABLE)
68+
EXECUTE_PROCESS(
69+
COMMAND ${WSL_EXECUTABLE} wslpath ${ABI_SOURCE_DIR}
70+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ABI_SOURCE_DIR)
71+
EXECUTE_PROCESS(
72+
COMMAND ${WSL_EXECUTABLE} wslpath ${ABI_BINARY_DIR}
73+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ABI_BINARY_DIR)
74+
ENDIF()
75+
6276
FOREACH(file ${ABI_HEADERS})
6377
GET_FILENAME_COMPONENT(header_basename ${file} NAME)
6478
SET(tmpfile ${BINARY_DIR}/${header_basename}.pp.tmp)
79+
SET(abi_file ${file})
80+
IF(WSL_EXECUTABLE)
81+
EXECUTE_PROCESS(
82+
COMMAND ${WSL_EXECUTABLE} wslpath ${abi_file}
83+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE abi_file)
84+
ENDIF()
6585

6686
EXECUTE_PROCESS(
67-
COMMAND ${COMPILER}
68-
-E -nostdinc -dI -DMYSQL_ABI_CHECK -I${SOURCE_DIR}/include
69-
-I${BINARY_DIR}/include -I${SOURCE_DIR}/include/mysql -I${SOURCE_DIR}/sql
70-
-I${SOURCE_DIR}/libbinlogevents/export
71-
${file}
87+
COMMAND ${WSL_EXECUTABLE} ${COMPILER}
88+
-E -nostdinc -dI -DMYSQL_ABI_CHECK -I${ABI_SOURCE_DIR}/include
89+
-I${ABI_BINARY_DIR}/include -I${ABI_SOURCE_DIR}/include/mysql
90+
-I${ABI_SOURCE_DIR}/sql -I${ABI_SOURCE_DIR}/libbinlogevents/export
91+
${abi_file}
7292
ERROR_QUIET OUTPUT_FILE ${tmpfile})
7393
EXECUTE_PROCESS(
74-
COMMAND sed -e "/^# /d"
94+
COMMAND ${WSL_EXECUTABLE} sed -e "/^# /d"
7595
-e "/^[ ]*$/d"
7696
-e "/^#pragma GCC set_debug_pwd/d"
7797
-e "/^#ident/d"
@@ -83,9 +103,8 @@ FOREACH(file ${ABI_HEADERS})
83103
EXECUTE_PROCESS(
84104
COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result)
85105
IF(NOT ${result} EQUAL 0)
86-
MESSAGE(FATAL_ERROR
106+
MESSAGE(FATAL_ERROR
87107
"ABI check found difference between ${file}.pp and ${abi_check_out}")
88108
ENDIF()
89109
FILE(REMOVE ${abi_check_out})
90110
ENDFOREACH()
91-

Diff for: include/my_inttypes.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
#include <sys/types.h>
4040
#endif
4141

42-
#ifdef _WIN32
42+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
4343
#include <BaseTsd.h>
4444
typedef unsigned int uint;
4545
typedef unsigned short ushort;
4646
#endif
47-
#if !defined(HAVE_ULONG)
47+
#if !defined(HAVE_ULONG) && !defined(MYSQL_ABI_CHECK)
4848
typedef unsigned long ulong; /* Short for unsigned long */
4949
#endif
5050

@@ -101,15 +101,15 @@ typedef int myf; /* Type of MyFlags in my_funcs */
101101
/* Length of decimal number represented by INT64. */
102102
#define MY_INT64_NUM_DECIMAL_DIGITS 21U
103103

104-
#ifdef _WIN32
104+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
105105
typedef SSIZE_T ssize_t;
106106
#endif
107107

108108
/*
109109
This doesn't really belong here, but it was the only reasonable place
110110
at the time.
111111
*/
112-
#ifdef _WIN32
112+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
113113
typedef int sigset_t;
114114
#endif
115115

Diff for: include/mysql.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ typedef uint64_t my_ulonglong;
5454

5555
#ifndef my_socket_defined
5656
#define my_socket_defined
57-
#ifdef _WIN32
57+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
5858
#include <windows.h>
5959
#ifdef WIN32_LEAN_AND_MEAN
6060
#include <winsock2.h>
6161
#endif
6262
#define my_socket SOCKET
6363
#else
6464
typedef int my_socket;
65-
#endif /* _WIN32 */
65+
#endif /* _WIN32 && ! MYSQL_ABI_CHECK */
6666
#endif /* my_socket_defined */
6767

6868
// Small extra definition to avoid pulling in my_compiler.h in client code.
6969
// IWYU pragma: no_include "my_compiler.h"
7070
#ifndef MY_COMPILER_INCLUDED
71-
#if !defined(_WIN32)
71+
#if !defined(_WIN32) || defined(MYSQL_ABI_CHECK)
7272
#define STDCALL
7373
#else
7474
#define STDCALL __stdcall

Diff for: include/mysql/components/services/my_io_bits.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Types to make file and socket I/O compatible.
2929
*/
3030

31-
#ifdef _WIN32
31+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
3232
/* Include common headers.*/
3333
#include <io.h> /* access(), chmod() */
3434
#ifdef WIN32_LEAN_AND_MEAN
@@ -48,7 +48,7 @@
4848
#endif
4949

5050
typedef int File; /* File descriptor */
51-
#ifdef _WIN32
51+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
5252
typedef int MY_MODE;
5353
typedef int mode_t;
5454
typedef int socket_len_t;

Diff for: include/mysql/components/services/my_thread_bits.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#endif
3838
#endif /* MYSQL_ABI_CHECK */
3939

40-
#ifdef _WIN32
40+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
4141
typedef DWORD my_thread_t;
4242
typedef struct thread_attr {
4343
DWORD dwStackSize;
@@ -50,7 +50,7 @@ typedef pthread_attr_t my_thread_attr_t;
5050

5151
struct my_thread_handle {
5252
my_thread_t thread{0};
53-
#ifdef _WIN32
53+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
5454
HANDLE handle{INVALID_HANDLE_VALUE};
5555
#endif
5656
};

Diff for: include/mysql/plugin_auth_common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ authenticated_as when proxy mapping should be done by the server.
110110
We need HANDLE definition if on Windows. Define WIN32_LEAN_AND_MEAN (if
111111
not already done) to minimize amount of imported declarations.
112112
*/
113-
#ifdef _WIN32
113+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
114114
#ifndef WIN32_LEAN_AND_MEAN
115115
#define WIN32_LEAN_AND_MEAN
116116
#endif
@@ -126,7 +126,7 @@ struct MYSQL_PLUGIN_VIO_INFO {
126126
MYSQL_VIO_MEMORY
127127
} protocol;
128128
int socket; /**< it's set, if the protocol is SOCKET or TCP */
129-
#ifdef _WIN32
129+
#if defined(_WIN32) && !defined(MYSQL_ABI_CHECK)
130130
HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */
131131
#endif
132132
};

0 commit comments

Comments
 (0)