Skip to content

Commit 689ebde

Browse files
author
Tor Didriksen
committed
Bug#36286802 RPM packaging does "make test" even when unit tests are disabled
Change the meaning of the EXCLUDE_FROM_PGO option for misc. cmake macros/functions. We now skip building when generating profile data, but we *do* build when *using* profile data. This is done in order to be able to run unit tests also for PGO/LTO builds. There are lots of new warnings during linking: - we are building executables that were not built prior to this patch - we are doing PGO/LTO builds also for el8 (earlier only el7) Add a convenience macro DOWNGRADE_STRINGOP_WARNINGS, and use this for misc. test binaries. TODO: consider silencing these warnings completely, rather than downgrading from error to warning. A few tests fail to link on el8. The common issue is usage of std::filesystem. The solution is to skip building them altogether when doing profiling. Change some RPM spec files to run 'ctest' explicitly, rather than 'make test'. Fix a couple of 'may be used unitialized' warnings. Change-Id: I19b94c04cf13225e0d18f79d76bc79bc67c3c5e4
1 parent 8595d6f commit 689ebde

File tree

37 files changed

+89
-31
lines changed

37 files changed

+89
-31
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ IF(WIN32)
814814
OPTION(WITH_MSCRT_DEBUG "MS Visual Studio Debug CRT instrumentation" OFF)
815815
ENDIF()
816816
IF(NOT WITHOUT_SERVER)
817-
IF(FPROFILE_GENERATE OR FPROFILE_USE)
817+
IF(FPROFILE_GENERATE)
818818
# Do not use data from unit testing when optimizing.
819819
OPTION(WITH_UNIT_TESTS "Compile MySQL with unit tests" OFF)
820820
ELSE()
@@ -2672,6 +2672,7 @@ ENDIF(DOXYGEN_FOUND)
26722672

26732673
MYSQL_ADD_EXECUTABLE(stack_direction
26742674
${CMAKE_SOURCE_DIR}/cmake/stack_direction.c
2675+
EXCLUDE_FROM_PGO
26752676
SKIP_INSTALL
26762677
)
26772678

cmake/fprofile.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,12 @@ IF(FPROFILE_USE AND NOT MSVC)
182182
# LTO combined with PGO boosts performance even more.
183183
SET(WITH_LTO_DEFAULT ON CACHE INTERNAL "")
184184
ENDIF()
185+
186+
MACRO(DOWNGRADE_STRINGOP_WARNINGS target)
187+
IF(MY_COMPILER_IS_GNU AND WITH_LTO AND FPROFILE_USE)
188+
TARGET_LINK_OPTIONS(${target} PRIVATE
189+
-Wno-error=stringop-overflow
190+
-Wno-error=stringop-overread
191+
)
192+
ENDIF()
193+
ENDMACRO()

cmake/libutils.cmake

+4-10
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ FUNCTION(ADD_STATIC_LIBRARY TARGET)
8383
)
8484

8585
IF(ARG_EXCLUDE_FROM_PGO)
86-
IF(FPROFILE_GENERATE OR FPROFILE_USE)
86+
IF(FPROFILE_GENERATE)
8787
RETURN()
8888
ENDIF()
8989
ENDIF()
@@ -96,12 +96,6 @@ FUNCTION(ADD_STATIC_LIBRARY TARGET)
9696
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES
9797
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archive_output_directory)
9898

99-
IF(ARG_EXCLUDE_FROM_PGO)
100-
IF(FPROFILE_GENERATE OR FPROFILE_USE)
101-
SET(ARG_EXCLUDE_FROM_ALL TRUE)
102-
ENDIF()
103-
ENDIF()
104-
10599
IF(ARG_EXCLUDE_FROM_ALL)
106100
SET_PROPERTY(TARGET ${TARGET} PROPERTY EXCLUDE_FROM_ALL TRUE)
107101
IF(WIN32)
@@ -195,7 +189,7 @@ MACRO(ADD_CONVENIENCE_LIBRARY TARGET_ARG)
195189
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archive_output_directory)
196190

197191
IF(ARG_EXCLUDE_FROM_PGO)
198-
IF(FPROFILE_GENERATE OR FPROFILE_USE)
192+
IF(FPROFILE_GENERATE)
199193
SET(ARG_EXCLUDE_FROM_ALL TRUE)
200194
ENDIF()
201195
ENDIF()
@@ -260,7 +254,7 @@ ENDMACRO()
260254
MACRO(MERGE_LIBRARIES_SHARED TARGET_ARG)
261255
SET(SHLIB_OPTIONS
262256
EXCLUDE_FROM_ALL
263-
EXCLUDE_FROM_PGO # add target, but do not build for PGO
257+
EXCLUDE_FROM_PGO # add target, but do not build for FPROFILE_GENERATE
264258
LINK_PUBLIC # All source libs become part of the PUBLIC interface of target.
265259
# See documentation for INTERFACE_LINK_LIBRARIES
266260
# The default is STATIC, i.e. the property
@@ -308,7 +302,7 @@ MACRO(MERGE_LIBRARIES_SHARED TARGET_ARG)
308302
ENDIF()
309303

310304
IF(ARG_EXCLUDE_FROM_PGO)
311-
IF(FPROFILE_GENERATE OR FPROFILE_USE)
305+
IF(FPROFILE_GENERATE)
312306
SET(ARG_EXCLUDE_FROM_ALL TRUE)
313307
SET(ARG_SKIP_INSTALL TRUE)
314308
ENDIF()

cmake/mysql_add_executable.cmake

+7-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ FUNCTION(MYSQL_ADD_EXECUTABLE target_arg)
8181
# command, which is probably not what you want
8282
# (except for mysqld.lib which is used by plugins).
8383
EXCLUDE_FROM_ALL # add target, but do not build it by default
84-
EXCLUDE_FROM_PGO # add target, but do not build for PGO
84+
EXCLUDE_FROM_PGO # add target, but do not build for FPROFILE_GENERATE
8585
SKIP_INSTALL # do not install it
8686
)
8787
SET(EXECUTABLE_ONE_VALUE_KW
@@ -107,7 +107,7 @@ FUNCTION(MYSQL_ADD_EXECUTABLE target_arg)
107107
)
108108

109109
IF(ARG_EXCLUDE_FROM_PGO)
110-
IF(FPROFILE_GENERATE OR FPROFILE_USE)
110+
IF(FPROFILE_GENERATE)
111111
RETURN()
112112
ENDIF()
113113
ENDIF()
@@ -154,10 +154,11 @@ FUNCTION(MYSQL_ADD_EXECUTABLE target_arg)
154154
ENDIF()
155155

156156
IF(ARG_EXCLUDE_FROM_PGO)
157-
IF(FPROFILE_GENERATE OR FPROFILE_USE)
158-
SET(ARG_EXCLUDE_FROM_ALL TRUE)
159-
SET(ARG_SKIP_INSTALL TRUE)
160-
UNSET(ARG_ADD_TEST)
157+
IF(FPROFILE_USE)
158+
MY_CHECK_CXX_COMPILER_WARNING("-Wmissing-profile" HAS_MISSING_PROFILE)
159+
IF(HAS_MISSING_PROFILE)
160+
TARGET_COMPILE_OPTIONS(${target} PRIVATE ${HAS_MISSING_PROFILE})
161+
ENDIF()
161162
ENDIF()
162163
ENDIF()
163164

components/keyrings/keyring_file/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ MYSQL_ADD_COMPONENT(keyring_file
8181
LINK_LIBRARIES ${KEYRING_FILE_LIBRARIES}
8282
MODULE_ONLY
8383
)
84+
85+
DOWNGRADE_STRINGOP_WARNINGS(component_keyring_file)

extra/libbacktrace/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
INCLUDE(libutils)
2525

26+
DISABLE_MISSING_PROFILE_WARNING()
27+
2628
SET(BACKTRACE_VERSION sha9ae4f4a)
2729
SET(BACKTRACE_SOURCES
2830
${BACKTRACE_VERSION}/backtrace.c

extra/libedit/libedit-20221030-3.1/src/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# See src/Makefile.am for original build dependencies.
22

3+
DISABLE_MISSING_PROFILE_WARNING()
4+
35
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} )
46
INCLUDE(CheckIncludeFile)
57
include(CheckFunctionExists)

libmysql/fido_client/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# along with this program; if not, write to the Free Software
2222
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2323

24+
DISABLE_MISSING_PROFILE_WARNING()
25+
2426
# Common
2527
ADD_SUBDIRECTORY(common)
2628

libs/mysql/gtid/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# along with this program; if not, write to the Free Software
2222
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2323

24+
DISABLE_MISSING_PROFILE_WARNING()
25+
2426
SET(LINKED_LIBRARIES
2527
)
2628

libs/mysql/serialization/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# along with this program; if not, write to the Free Software
2222
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2323

24+
DISABLE_MISSING_PROFILE_WARNING()
25+
2426
SET(TARGET_HEADERS
2527
archive_binary_field_max_size_calculator.h
2628
archive_binary.h

mysys/CMakeLists.txt

+12-5
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ IF(FREEBSD)
185185
ADD_COMPILE_FLAGS(stacktrace.cc COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
186186
ENDIF()
187187

188+
MY_CHECK_CXX_COMPILER_WARNING("-Wmissing-profile" HAS_MISSING_PROFILE)
189+
IF(HAS_MISSING_PROFILE)
190+
ADD_COMPILE_FLAGS(mf_path.cc COMPILE_FLAGS "${HAS_MISSING_PROFILE}")
191+
ENDIF()
192+
188193
ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES}
189194
LINK_LIBRARIES
190195
mytime
@@ -231,28 +236,30 @@ IF(MSVC_CPPCHECK AND MSVC AND MSVC_VERSION GREATER 1935)
231236
ADD_COMPILE_FLAGS(my_conio.cc COMPILE_FLAGS "/wd28286")
232237
ENDIF()
233238

234-
# We are not interesting in profiling tests.
235-
DISABLE_MISSING_PROFILE_WARNING()
236-
237239
MYSQL_ADD_EXECUTABLE(thr_lock
238240
thr_lock.cc
241+
EXCLUDE_FROM_PGO
239242
LINK_LIBRARIES mysys
240243
SKIP_INSTALL
244+
COMPILE_DEFINITIONS MAIN
241245
)
242-
SET_TARGET_PROPERTIES(thr_lock PROPERTIES COMPILE_FLAGS "-DMAIN")
243246

244247
MYSQL_ADD_EXECUTABLE(mf_iocache_test
245248
mf_iocache.cc
249+
EXCLUDE_FROM_PGO
246250
LINK_LIBRARIES mysys
247251
SKIP_INSTALL
252+
COMPILE_DEFINITIONS MAIN
248253
)
249-
SET_TARGET_PROPERTIES(mf_iocache_test PROPERTIES COMPILE_FLAGS "-DMAIN")
250254

251255
IF(HAVE_BUILD_ID_SUPPORT)
252256
MYSQL_ADD_EXECUTABLE(build_id_test
253257
build_id_test.cc build_id.cc
254258
SKIP_INSTALL
255259
)
260+
IF(HAS_MISSING_PROFILE)
261+
TARGET_COMPILE_OPTIONS(build_id_test PRIVATE ${HAS_MISSING_PROFILE})
262+
ENDIF()
256263
# Verify that we can read our own build-id:
257264
ADD_CUSTOM_COMMAND(TARGET build_id_test POST_BUILD
258265
# COMMAND ./build_id_test

packaging/deb-in/rules.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ override_dh_auto_build:
6565
$(MAKE) $(JOBS) VERBOSE=1
6666
touch $@
6767

68+
# timeout in seconds
6869
override_dh_auto_test:
6970
@echo "RULES.$@"
7071
export CTEST_OUTPUT_ON_FAILURE=1
72+
export CTEST_PARALLEL_LEVEL=$(expr $(nproc) / 2)
7173
cd release && \
72-
make test || true
74+
ctest --test-timeout 120 || true
7375
touch $@
7476

7577
@DEB_RULES_STRIP@

packaging/rpm-docker/mysql.spec.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ rm -rf %{buildroot}%{_libdir}/mysql/libndbclient.so
428428
%if 0%{?runselftest} || 0%{?with_unittests}
429429
pushd release
430430
export CTEST_OUTPUT_ON_FAILURE=1
431-
make test || true
431+
export CTEST_PARALLEL_LEVEL=$(expr $(nproc) / 2)
432+
ctest --test-timeout 120 || true
432433
%endif
433434
%if 0%{?runselftest}
434435
export MTR_BUILD_THREAD=auto

packaging/rpm-fedora/mysql.spec.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,8 @@ fi
626626
%if 0%{?runselftest} || 0%{?with_unittests}
627627
pushd release
628628
export CTEST_OUTPUT_ON_FAILURE=1
629-
make test || true
629+
export CTEST_PARALLEL_LEVEL=$(expr $(nproc) / 2)
630+
ctest --test-timeout 120 || true
630631
%endif
631632
%if 0%{?runselftest}
632633
export MTR_BUILD_THREAD=auto

packaging/rpm-oel/mysql.spec.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,8 @@ install -D -p -m 0644 packaging/rpm-common/mysqlrouter.conf %{buildroot}%{_sysco
10511051
%if 0%{?runselftest} || 0%{?with_unittests}
10521052
pushd release
10531053
export CTEST_OUTPUT_ON_FAILURE=1
1054-
make test || true
1054+
export CTEST_PARALLEL_LEVEL=$(expr $(nproc) / 2)
1055+
ctest%{?el7:3} --test-timeout 120 || true
10551056
%endif
10561057
%if 0%{?runselftest}
10571058
export MTR_BUILD_THREAD=auto

packaging/rpm-sles/mysql.spec.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcmysql
719719
%if 0%{?runselftest} || 0%{?with_unittests}
720720
pushd release
721721
export CTEST_OUTPUT_ON_FAILURE=1
722-
make test || true
722+
export CTEST_PARALLEL_LEVEL=$(expr $(nproc) / 2)
723+
ctest --test-timeout 120 || true
723724
%endif
724725
%if 0%{?runselftest}
725726
export MTR_BUILD_THREAD=auto

plugin/keyring_udf/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# along with this program; if not, write to the Free Software
2222
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2323

24+
DISABLE_MISSING_PROFILE_WARNING()
25+
2426
MYSQL_ADD_PLUGIN(keyring_udf
2527
keyring_udf.cc
2628
MODULE_ONLY

plugin/rewriter/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ IF(NOT TARGET rewriter)
3737
RETURN()
3838
ENDIF()
3939

40+
DOWNGRADE_STRINGOP_WARNINGS(rewriter)
41+
4042
ADD_DEFINITIONS(-DMYSQL_SERVER)
4143
ADD_DEFINITIONS(-DLOG_COMPONENT_TAG="Rewriter")
4244

plugin/test_service_sql_api/test_sql_stmt.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static const char *test_decimal_as_string(char *buff, const decimal_t *val,
453453
}
454454

455455
static int handle_store_decimal(void *pctx, const decimal_t *value) {
456-
char buffer[LARGE_STRING_BUFFER_SIZE];
456+
char buffer[LARGE_STRING_BUFFER_SIZE]{};
457457
Server_context *ctx = (Server_context *)pctx;
458458
DBUG_TRACE;
459459
const uint col = ctx->current_col;

plugin/x/protocol/plugin/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ MYSQL_ADD_EXECUTABLE(
3838
${PROTOC_PLUGIN_SRC}
3939
SKIP_INSTALL
4040
)
41+
DOWNGRADE_STRINGOP_WARNINGS(xprotocol_plugin)
4142

4243
TARGET_LINK_LIBRARIES(
4344
xprotocol_plugin

router/src/router/tests/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ ADD_HARNESS_TEST_FILE(test_keyring_frontend.cc
203203
../src/
204204
SYSTEM_INCLUDE_DIRS ${GMOCK_INCLUDE_DIRS}
205205
)
206+
DOWNGRADE_STRINGOP_WARNINGS(routertest_router_keyring_frontend)
206207

207208
FOREACH(test_file
208209
issues/test_bug22084430.cc
@@ -220,6 +221,7 @@ FOREACH(test_file
220221
SYSTEM_INCLUDE_DIRS ${GMOCK_INCLUDE_DIRS}
221222
)
222223
ENDFOREACH()
224+
DOWNGRADE_STRINGOP_WARNINGS(routertest_issues_bug24909259)
223225

224226
ADD_HARNESS_TEST_FILE(test_default_paths.cc
225227
MODULE ${TEST_MODULE}

router/src/routing/src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ INSTALL(TARGETS routing
219219
NAMELINK_SKIP
220220
)
221221
ADD_DEPENDENCIES(routing GenLiteProtos)
222+
DOWNGRADE_STRINGOP_WARNINGS(routing)
222223

223224
ADD_INSTALL_RPATH_FOR_OPENSSL(routing)
224225
SET_PATH_TO_CUSTOM_SSL_FOR_APPLE(routing)

router/src/routing/tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ FOREACH(test_file ${test_files})
6363
${CMAKE_CURRENT_SOURCE_DIR}/../../harness/tests # mock_io_service.h
6464
)
6565
ENDFOREACH()
66+
DOWNGRADE_STRINGOP_WARNINGS(routertest_routing_setup_tcp_service)
6667

6768
ADD_TEST_FILE(${CMAKE_CURRENT_SOURCE_DIR}/plugin/test_plugin.cc
6869
MODULE "routing"

router/tests/component/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ add_test_file(${CMAKE_CURRENT_SOURCE_DIR}/${test_file}
129129
routertestplugin_logger
130130
signal_me
131131
)
132+
ROUTERTEST_GET_TARGET(ttt ${test_file} "component")
133+
DOWNGRADE_STRINGOP_WARNINGS(${ttt})
132134
ENDFOREACH()
133135

134136
FOREACH(test_file

sql/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,7 @@ MYSQL_ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc SKIP_INSTALL)
13871387
IF(HAS_MISSING_PROFILE)
13881388
ADD_COMPILE_FLAGS(
13891389
gen_lex_hash.cc
1390+
binlog/log_sanitizer.cc
13901391
COMPILE_FLAGS ${HAS_MISSING_PROFILE})
13911392
ENDIF()
13921393

storage/archive/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2323

2424
MSVC_CPPCHECK_DISABLE()
25+
DISABLE_MISSING_PROFILE_WARNING()
2526

2627
MYSQL_ADD_PLUGIN(archive azio.cc ha_archive.cc
2728
DEFAULT_LEGACY_ENGINE

storage/heap/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# along with this program; if not, write to the Free Software
2222
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2323

24+
DISABLE_MISSING_PROFILE_WARNING()
25+
2426
SET(HEAP_SOURCES
2527
# _check.cc only for debug, see below.
2628
_rectest.cc

storage/ndb/src/ndbapi/ndb_cluster_connection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ int Ndb_cluster_connection_impl::connect(int no_retries,
13281328
}
13291329

13301330
// the allocNodeId function will connect if not connected
1331-
int alloc_error;
1331+
int alloc_error = 0;
13321332
Uint32 nodeId = m_config_retriever->allocNodeId(
13331333
no_retries, retry_delay_in_seconds, verbose, alloc_error);
13341334
if (!nodeId) {

storage/perfschema/unittest/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ SET(tests
5050
)
5151
FOREACH(testname ${tests})
5252
PFS_ADD_TEST(${testname})
53+
DOWNGRADE_STRINGOP_WARNINGS(${testname}-t)
5354
ENDFOREACH()
5455

5556
# Add sql_builtin.cc, to force linkage of plugins below.

testclients/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ MYSQL_ADD_EXECUTABLE(mysql_client_test mysql_client_test.cc COMPONENT Test)
2727
TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient extra::rapidjson)
2828

2929
IF(WITH_UNIT_TESTS)
30-
MYSQL_ADD_EXECUTABLE(bug25714 bug25714.cc SKIP_INSTALL)
30+
MYSQL_ADD_EXECUTABLE(bug25714 bug25714.cc SKIP_INSTALL EXCLUDE_FROM_PGO)
3131
TARGET_LINK_LIBRARIES(bug25714 mysqlclient)
3232
ENDIF()

0 commit comments

Comments
 (0)