Enable LTO
This commit is contained in:
parent
18b2713fdb
commit
c56966d2fa
119
community-mysql-lto.patch
Normal file
119
community-mysql-lto.patch
Normal file
@ -0,0 +1,119 @@
|
||||
commit dfd43f7d5527680fd27a29c80e8eb3b9b5165220
|
||||
Author: Tor Didriksen <tor.didriksen@oracle.com>
|
||||
Date: Mon Aug 3 16:39:21 2020 +0200
|
||||
|
||||
Bug #31701553 CMAKE CODE TO DISABLE LTO IS TOO SIMPLE
|
||||
|
||||
Parts of our codebase (3rd party libraries) fail to compile/link if built with -flto.
|
||||
For these we simply remove "-flto[=n|auto|jobserver] from
|
||||
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS.
|
||||
|
||||
We also disable linkers lld and gold by default if building with
|
||||
link-time optimization.
|
||||
|
||||
Change-Id: I84e9f7128a4d263056aa60c188e6430ea7161655
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index dc118b37472..919e7cbd783 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -639,6 +639,10 @@ OPTION(WITH_LTO
|
||||
${WITH_LTO_DEFAULT}
|
||||
)
|
||||
|
||||
+IF(CMAKE_C_FLAGS MATCHES " -flto" OR CMAKE_CXX_FLAGS MATCHES " -flto")
|
||||
+ SET(CMAKE_COMPILER_FLAG_WITH_LTO 1)
|
||||
+ENDIF()
|
||||
+
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckCXXSourceCompiles)
|
||||
# We need some extra FAIL_REGEX patterns
|
||||
@@ -848,7 +852,7 @@ ENDIF()
|
||||
# Use lld for Clang if available and not explicitly disabled.
|
||||
# Also works for gcc on Debian/Ubuntu. Do 'apt install lld'.
|
||||
# LTO build fails with lld, so turn it off by default.
|
||||
-IF(LINUX AND NOT WITH_LTO)
|
||||
+IF(LINUX AND NOT WITH_LTO AND NOT CMAKE_COMPILER_FLAG_WITH_LTO)
|
||||
OPTION(USE_LD_LLD "Use llvm lld linker" ON)
|
||||
ELSE()
|
||||
OPTION(USE_LD_LLD "Use llvm lld linker" OFF)
|
||||
@@ -879,7 +883,11 @@ IF(USE_LD_LLD)
|
||||
ENDIF()
|
||||
|
||||
# Use gold on x86 if available and not explicitly disabled.
|
||||
-IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT WIN32)
|
||||
+# LTO build fails with gold, so turn it off by default.
|
||||
+IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
|
||||
+ AND NOT WIN32
|
||||
+ AND NOT WITH_LTO
|
||||
+ AND NOT CMAKE_COMPILER_FLAG_WITH_LTO)
|
||||
OPTION(USE_LD_GOLD "Use GNU gold linker" ON)
|
||||
ELSE()
|
||||
OPTION(USE_LD_GOLD "Use GNU gold linker" OFF)
|
||||
diff --git a/cmake/compile_flags.cmake b/cmake/compile_flags.cmake
|
||||
index 053e48b9e70..bb1338ee9f8 100644
|
||||
--- a/cmake/compile_flags.cmake
|
||||
+++ b/cmake/compile_flags.cmake
|
||||
@@ -1,4 +1,4 @@
|
||||
-# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
+# Copyright (c) 2014, 2020, Oracle and/or its affiliates.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License, version 2.0,
|
||||
@@ -83,3 +83,12 @@ FUNCTION(ADD_COMPILE_DEFINITIONS)
|
||||
${FILE} PROPERTIES COMPILE_DEFINITIONS "${DEFS}")
|
||||
ENDFOREACH()
|
||||
ENDFUNCTION()
|
||||
+
|
||||
+# -flto[=n] or -flto=auto or -flto=jobserver
|
||||
+SET(MY_COMPILER_FLAG_FLTO " -flto(=[0-9a-z]+)?")
|
||||
+
|
||||
+# Remove compiler flag/pattern from CMAKE_C_FLAGS or CMAKE_CXX_FLAGS
|
||||
+FUNCTION(REMOVE_CMAKE_COMPILER_FLAGS FLAG_VAR PATTERN)
|
||||
+ STRING(REGEX REPLACE "${PATTERN}" "" ${FLAG_VAR} "${${FLAG_VAR}}")
|
||||
+ SET(${FLAG_VAR} "${${FLAG_VAR}}" PARENT_SCOPE)
|
||||
+ENDFUNCTION()
|
||||
diff --git a/extra/icu/CMakeLists.txt b/extra/icu/CMakeLists.txt
|
||||
index aa1cfb1a90e..81ef19335a0 100644
|
||||
--- a/extra/icu/CMakeLists.txt
|
||||
+++ b/extra/icu/CMakeLists.txt
|
||||
@@ -1,4 +1,4 @@
|
||||
-# Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
+# Copyright (c) 2017, 2020, Oracle and/or its affiliates.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License, version 2.0,
|
||||
@@ -91,8 +91,10 @@ IF(MSVC AND NOT WIN32_CLANG)
|
||||
STRING_APPEND(CMAKE_CXX_FLAGS " /wd4229")
|
||||
ENDIF()
|
||||
|
||||
-STRING(REPLACE "-flto" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
-STRING(REPLACE "-flto" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
+IF(WITH_ICU STREQUAL "bundled")
|
||||
+ REMOVE_CMAKE_COMPILER_FLAGS(CMAKE_C_FLAGS "${MY_COMPILER_FLAG_FLTO}")
|
||||
+ REMOVE_CMAKE_COMPILER_FLAGS(CMAKE_CXX_FLAGS "${MY_COMPILER_FLAG_FLTO}")
|
||||
+ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(source/common)
|
||||
ADD_SUBDIRECTORY(source/i18n)
|
||||
diff --git a/plugin/innodb_memcached/CMakeLists.txt b/plugin/innodb_memcached/CMakeLists.txt
|
||||
index b9d93da5f20..00bbddeb3ec 100644
|
||||
--- a/plugin/innodb_memcached/CMakeLists.txt
|
||||
+++ b/plugin/innodb_memcached/CMakeLists.txt
|
||||
@@ -1,4 +1,4 @@
|
||||
-# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
+# Copyright (c) 2011, 2020, Oracle and/or its affiliates.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License, version 2.0,
|
||||
@@ -76,8 +76,8 @@ IF(WITH_INNODB_MEMCACHED AND UNIX)
|
||||
ENDIF()
|
||||
|
||||
# -Werror=lto-type-mismatch for misc functions.
|
||||
- STRING(REPLACE "-flto" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
- STRING(REPLACE "-flto" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
+ REMOVE_CMAKE_COMPILER_FLAGS(CMAKE_C_FLAGS "${MY_COMPILER_FLAG_FLTO}")
|
||||
+ REMOVE_CMAKE_COMPILER_FLAGS(CMAKE_CXX_FLAGS "${MY_COMPILER_FLAG_FLTO}")
|
||||
|
||||
ADD_SUBDIRECTORY(daemon_memcached)
|
||||
ADD_SUBDIRECTORY(innodb_memcache)
|
@ -73,7 +73,7 @@
|
||||
|
||||
Name: community-mysql
|
||||
Version: 8.0.21
|
||||
Release: 6%{?with_debug:.debug}%{?dist}
|
||||
Release: 7%{?with_debug:.debug}%{?dist}
|
||||
Summary: MySQL client programs and shared libraries
|
||||
URL: http://www.mysql.com
|
||||
|
||||
@ -112,6 +112,7 @@ Patch52: %{pkgnamepatch}-sharedir.patch
|
||||
Patch55: %{pkgnamepatch}-rpath.patch
|
||||
Patch75: %{pkgnamepatch}-arm32-timer.patch
|
||||
Patch76: %{pkgnamepatch}-certs-expired.patch
|
||||
Patch77: %{pkgnamepatch}-lto.patch
|
||||
|
||||
# Patches taken from boost 1.59
|
||||
Patch115: boost-1.58.0-pool.patch
|
||||
@ -379,6 +380,7 @@ the MySQL sources.
|
||||
%patch55 -p1
|
||||
%patch75 -p1
|
||||
%patch76 -p1
|
||||
%patch77 -p1
|
||||
|
||||
# Patch Boost
|
||||
pushd boost/boost_$(echo %{boost_bundled_version}| tr . _)
|
||||
@ -451,10 +453,10 @@ cp %{SOURCE2} %{SOURCE3} %{SOURCE10} %{SOURCE11} %{SOURCE12} \
|
||||
%{SOURCE14} %{SOURCE15} %{SOURCE17} %{SOURCE18} %{SOURCE31} scripts
|
||||
|
||||
%build
|
||||
# This package internally tries to eliminate LTO flags
|
||||
# but fails miserably. Just disable for the whole package
|
||||
# until the package internals are fixed
|
||||
# arm build ends with out of memory error for LTO enabled build
|
||||
%ifarch %arm
|
||||
%define _lto_cflags %{nil}
|
||||
%endif
|
||||
|
||||
# fail quickly and obviously if user tries to build as root
|
||||
%if %runselftest
|
||||
@ -858,6 +860,10 @@ fi
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Aug 10 2020 Lars Tangvald <lars.tangvald@oracle.com> - 8.0.21-7
|
||||
- Use upstream patch to enable LTO
|
||||
- Skip LTO on ARM due to out of memory issue
|
||||
|
||||
* Thu Aug 13 2020 Michal Schorm <mschorm@redhat.com> - 8.0.21-6
|
||||
- Do a proper out-of-source CMake builds
|
||||
- Force the CMake change regarding the in-source builds also to F31 and F32
|
||||
|
Loading…
Reference in New Issue
Block a user