From fce22fcfe82bdc7a63a8636484806cc987286538 Mon Sep 17 00:00:00 2001 From: Evgeniy Patlan Date: Wed, 19 Aug 2026 13:00:22 +0300 Subject: [PATCH] Relax warnings-as-errors on the parser plugin link line The generated bison parsers already build with -Wno-error because they are generated code the project does not control. With LTO enabled the compiler diagnoses them again at link time, where per-source COMPILE_FLAGS no longer apply, so the global -Werror makes those diagnostics fatal. This is what breaks Debian and Ubuntu builds, which enable -flto=auto by default: sql_yacc.cc and sql_hints.yy.cc each define a file-scope enum yysymbol_kind_t with different enumerators, and -Wodr reports the resulting ODR violation as an error: sql_yacc.cc:104:6: error: type 'yysymbol_kind_t' violates the C++ One Definition Rule [-Werror=odr] lto1: all warnings being treated as errors Apply the same relaxation to the link line that the sources already get. --- mysqlshdk/libs/yparser/mysql/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysqlshdk/libs/yparser/mysql/CMakeLists.txt b/mysqlshdk/libs/yparser/mysql/CMakeLists.txt index 3eaec7060..eee35419f 100644 --- a/mysqlshdk/libs/yparser/mysql/CMakeLists.txt +++ b/mysqlshdk/libs/yparser/mysql/CMakeLists.txt @@ -188,6 +188,13 @@ function(create_parser_plugin) # create the plugin add_library(${PLUGIN_NAME} MODULE ${MYSQL_SOURCES} ${PLUGIN_SOURCES}) + + # The generated parser sources are diagnosed again at link time when LTO is + # enabled, where the per-source COMPILE_FLAGS above no longer apply, so + # relax warnings on the link line as well + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_link_options(${PLUGIN_NAME} PRIVATE "-Wno-error") + endif() target_compile_definitions(${PLUGIN_NAME} PRIVATE "BUILDING_PARSER_PLUGIN" "PARSER_VERSION=\"${ARG_VERSION}\""