Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Interprocedural Optimization #3585

Draft
wants to merge 10 commits into
base: 10.6
Choose a base branch
from
1 change: 1 addition & 0 deletions cmake/ctest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ MACRO(MY_ADD_TESTS)

FOREACH(name ${ARG_UNPARSED_ARGUMENTS})
ADD_EXECUTABLE(${name}-t "${name}-t.${ARG_EXT}")
SET_TARGET_PROPERTIES(${name}-t PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
TARGET_LINK_LIBRARIES(${name}-t mytap ${ARG_LINK_LIBRARIES})
MY_ADD_TEST(${name})
ENDFOREACH()
Expand Down
9 changes: 7 additions & 2 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INCLUDE (CheckFunctionExists)
INCLUDE (CheckCCompilerFlag)
INCLUDE (CheckCSourceRuns)
INCLUDE (CheckSymbolExists)

INCLUDE (CheckIPOSupported)

# WITH_PIC options.Not of much use, PIC is taken care of on platforms
# where it makes sense anyway.
Expand All @@ -41,7 +41,12 @@ IF(UNIX)
ENDIF()
ENDIF()


# With INTERPROCEDURAL OPTMIZATION
CHECK_IPO_SUPPORTED(RESULT IPO_SUPPORTED LANGUAGES C CXX)
IF(IPO_SUPPORTED)
SET(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
ENDIF()
ADD_FEATURE_INFO(INTERPROCEDURAL_OPTIMIZATION IPO_SUPPORTED "Support Interprocedural Optmization (LTO)")

# System type affects version_compile_os variable
IF(NOT SYSTEM_TYPE)
Expand Down
3 changes: 3 additions & 0 deletions plugin/metadata_lock_info/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
SET(METADATA_LOCK_INFO_SOURCES metadata_lock_info.cc)
MYSQL_ADD_PLUGIN(metadata_lock_info ${METADATA_LOCK_INFO_SOURCES}
RECOMPILE_FOR_EMBEDDED)

# mdl elements need extern defination
SET_TARGET_PROPERTIES(metadata_lock_info PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
2 changes: 1 addition & 1 deletion sql/mdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ class MDL_context
MDL_context &operator=(MDL_context &rhs); /* not implemented */

/* metadata_lock_info plugin */
friend int i_s_metadata_lock_info_fill_row(MDL_ticket*, void*);
friend int i_s_metadata_lock_info_fill_row(MDL_ticket*, void*, bool);
#ifndef DBUG_OFF
public:
/**
Expand Down
2 changes: 1 addition & 1 deletion sql/set_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ inline bool IS_SYSVAR_AUTOSIZE(void *ptr)
bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type);

sql_mode_t expand_sql_mode(sql_mode_t sql_mode);
const char *sql_mode_string_representation(uint bit_number);
const char *sql_mode_string_representation_for_bit(uint bit_number);
bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode,
LEX_CSTRING *ls);
int default_regex_flags_pcre(THD *thd);
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_mode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void Sql_mode_dependency::push_dependency_warnings(THD *thd) const
push_warning_printf(thd,
Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
"Expression depends on the @@%s value %s",
"sql_mode", sql_mode_string_representation(i));
"sql_mode", sql_mode_string_representation_for_bit(i));
}
}
}
2 changes: 1 addition & 1 deletion sql/sys_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3766,7 +3766,7 @@ static const char *sql_mode_names[]=
};


const char *sql_mode_string_representation(uint bit_number)
const char *sql_mode_string_representation_for_bit(uint bit_number)
{
DBUG_ASSERT(bit_number < array_elements(sql_mode_names));
return sql_mode_names[bit_number];
Expand Down
4 changes: 4 additions & 0 deletions storage/archive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
SET(ARCHIVE_SOURCES azio.c ha_archive.cc ha_archive.h)
MYSQL_ADD_PLUGIN(archive ${ARCHIVE_SOURCES} STORAGE_ENGINE LINK_LIBRARIES ${ZLIB_LIBRARIES})



# Unresolved symbols need be extern
SET_TARGET_PROPERTIES(archive PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
2 changes: 2 additions & 0 deletions storage/connect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ IF(NOT TARGET connect)
RETURN()
ENDIF()

SET_TARGET_PROPERTIES(connect PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)

IF(MSVC AND (CMAKE_CXX_FLAGS MATCHES "/MP"))
# domdoc.cpp uses compiler directive #import which is not compatible
# with the /MP option, resulting in compiler error C2813.
Expand Down
3 changes: 3 additions & 0 deletions storage/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@

SET(EXAMPLE_SOURCES ha_example.cc)
MYSQL_ADD_PLUGIN(example ${EXAMPLE_SOURCES} STORAGE_ENGINE MODULE_ONLY COMPONENT Test)

# Unresolved symbols need be extern - same list as ha_test_sql_discover
SET_TARGET_PROPERTIES(example PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
2 changes: 1 addition & 1 deletion storage/perfschema/unittest/pfs_server_stubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void sql_print_warning(const char *format, ...)
/* Do not pollute the unit test output with annoying messages. */
}

class sys_var { public: enum where { AUTO }; };
class sys_var { public: enum where { CONFIG, COMMAND_LINE, AUTO, SQL, COMPILE_TIME, ENV }; };
void set_sys_var_value_origin(void *, enum sys_var::where, const char *)
{
}
Expand Down
4 changes: 4 additions & 0 deletions storage/test_sql_discovery/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
MYSQL_ADD_PLUGIN(test_sql_discovery test_sql_discovery.cc STORAGE_ENGINE
COMPONENT Test)

# missing symbols needs to be defined as extern?
SET_TARGET_PROPERTIES(test_sql_discovery PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)

3 changes: 3 additions & 0 deletions unittest/strings/strings-t.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,9 @@ test_strnncollsp_char()
return failed;
}

static void my_init() {};
static int my_end(int infoflag) { return 0; };
static const char *my_progname= NULL;

int main(int ac, char **av)
{
Expand Down