summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2020-05-04 14:17:06 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2020-05-04 14:17:06 +0200
commitd50f776930425e540678238798b4f7666b9cbb76 (patch)
tree63e5c65d22496bc4e8ed35ab04de0251e6711c96
parentf544a712c8a2ef3f3ecba80cb2782b1839fb36ab (diff)
downloadmariadb-git-d50f776930425e540678238798b4f7666b9cbb76.tar.gz
MDEV-22454 Allow -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
Disable IPO (interprocedural optimization, aka /GL) on Windows on libraries, from which server.dll exports symbols - exporting symbols does not work for objects compiled with /GL.
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/libutils.cmake12
-rw-r--r--dbug/CMakeLists.txt1
-rw-r--r--mysys/CMakeLists.txt1
-rw-r--r--sql/CMakeLists.txt5
-rw-r--r--strings/CMakeLists.txt3
6 files changed, 22 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d93c09218a6..3db3a8f9ef3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,9 @@ ENDIF()
IF(POLICY CMP0075)
CMAKE_POLICY(SET CMP0075 NEW)
ENDIF()
+IF(POLICY CMP0069)
+ CMAKE_POLICY(SET CMP0069 NEW)
+ENDIF()
MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}")
diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake
index 6b2a2e9b2bb..c7b01bf8429 100644
--- a/cmake/libutils.cmake
+++ b/cmake/libutils.cmake
@@ -330,3 +330,15 @@ FUNCTION(RESTRICT_SYMBOL_EXPORTS target)
COMPILE_FLAGS "${COMPILE_FLAGS} ${VISIBILITY_HIDDEN_FLAG}")
ENDIF()
ENDFUNCTION()
+
+# The MSVC /GL flag, used for link-time code generation
+# creates objects files with a format not readable by tools
+# i.e exporting all symbols is not possible with IPO
+# To workaround this, we disable INTERPROCEDURAL_OPTIMIZATION
+# for some static libraries.
+
+FUNCTION (MAYBE_DISABLE_IPO target)
+ IF(MSVC AND NOT CLANG_CL)
+ SET_TARGET_PROPERTIES(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
+ ENDIF()
+ENDFUNCTION()
diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt
index 8941ac5fc27..842099f03f3 100644
--- a/dbug/CMakeLists.txt
+++ b/dbug/CMakeLists.txt
@@ -20,6 +20,7 @@ INCLUDE_DIRECTORIES(
SET(DBUG_SOURCES dbug.c)
ADD_CONVENIENCE_LIBRARY(dbug ${DBUG_SOURCES})
TARGET_LINK_LIBRARIES(dbug mysys)
+MAYBE_DISABLE_IPO(dbug)
ADD_EXECUTABLE(tests tests.c)
TARGET_LINK_LIBRARIES(tests dbug)
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index cd81e325f45..ef159748092 100644
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -71,6 +71,7 @@ IF(HAVE_MLOCK)
ENDIF()
ADD_CONVENIENCE_LIBRARY(mysys ${MYSYS_SOURCES})
+MAYBE_DISABLE_IPO(mysys)
TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY}
${LIBNSL} ${LIBM} ${LIBRT} ${LIBDL} ${LIBSOCKET} ${LIBEXECINFO} ${CRC32_LIBRARY})
DTRACE_INSTRUMENT(mysys)
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 76ac07d617a..48985ced09f 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -188,6 +188,7 @@ MYSQL_ADD_PLUGIN(sql_sequence ha_sequence.cc STORAGE_ENGINE MANDATORY STATIC_ONL
RECOMPILE_FOR_EMBEDDED)
ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
+MAYBE_DISABLE_IPO(sql)
DTRACE_INSTRUMENT(sql)
TARGET_LINK_LIBRARIES(sql
mysys mysys_ssl dbug strings vio pcre2-8
@@ -234,13 +235,13 @@ IF(MSVC)
IF(deps)
LIST(APPEND all_deps ${deps})
ENDIF()
- ENDFOREACH()
+ ENDFOREACH()
LIST(REMOVE_DUPLICATES all_deps)
FOREACH(lib ${libs_to_export_symbols})
LIST(REMOVE_ITEM all_deps ${lib})
ENDFOREACH()
- TARGET_LINK_LIBRARIES(server
+ TARGET_LINK_LIBRARIES(server PRIVATE
${all_deps}
sql_builtins
)
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index 60f5b409bfb..0e62f9e34ad 100644
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -32,7 +32,8 @@ ENDIF()
# Avoid dependencies on perschema data defined in mysys
ADD_DEFINITIONS(-DDISABLE_MYSQL_THREAD_H)
ADD_CONVENIENCE_LIBRARY(strings ${STRINGS_SOURCES})
-
+TARGET_LINK_LIBRARIES(strings dbug mysys)
+MAYBE_DISABLE_IPO(strings)
ADD_EXECUTABLE(conf_to_src EXCLUDE_FROM_ALL conf_to_src.c)
SET_TARGET_PROPERTIES(conf_to_src PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
TARGET_LINK_LIBRARIES(conf_to_src mysys strings)