Skip to content

Commit bc367bf

Browse files
jhauglidbjornmu
authored andcommitted
Bug#28542723: SWITCH TO GCC 7 ON SLES 12
Switch to GCC 7 when building on SLES 12. This is the same compiler used by SLES 15. This means that the lowest used version of GCC now becomes 5.3. Change-Id: I4474facd3fc23328ac5d1910b862eaa94a518243
1 parent 7634e1f commit bc367bf

File tree

2 files changed

+37
-5
lines changed

2 files changed

+37
-5
lines changed

CMakeLists.txt

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio [1-9][0-9].*" AND
141141
ENDIF()
142142

143143
# On Linux el6/el7 the default gcc is too old, see if devtoolset is installed.
144+
# Same with SLES 12, look for gcc 7 there.
144145
# We need to look for gcc before calling PROJECT below.
145146
OPTION(FORCE_UNSUPPORTED_COMPILER "Disable compiler version checks" OFF)
146147
MARK_AS_ADVANCED(WITHOUT_SERVER DISABLE_SHARED FORCE_UNSUPPORTED_COMPILER)
@@ -176,16 +177,35 @@ IF(CMAKE_HOST_UNIX AND NOT FORCE_UNSUPPORTED_COMPILER
176177
ELSE()
177178
MESSAGE(WARNING "Could not find devtoolset gcc")
178179
ENDIF()
180+
ELSEIF(MY_HOST_SYSTEM_NAME MATCHES "Linux" AND
181+
EXISTS "/etc/os-release")
182+
FILE(READ "/etc/os-release" MY_OS_RELEASE)
183+
IF (MY_OS_RELEASE MATCHES "SUSE Linux Enterprise Server 12")
184+
MESSAGE(STATUS "We need to look for a newer GCC on SLES 12")
185+
186+
FIND_PROGRAM(ALTERNATIVE_GCC gcc-7
187+
NO_DEFAULT_PATH
188+
PATHS "/usr/bin")
189+
FIND_PROGRAM(ALTERNATIVE_GPP g++-7
190+
NO_DEFAULT_PATH
191+
PATHS "/usr/bin")
192+
IF (ALTERNATIVE_GCC AND ALTERNATIVE_GPP)
193+
SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC})
194+
SET(CMAKE_CXX_COMPILER ${ALTERNATIVE_GPP})
195+
MESSAGE(STATUS "Using ${ALTERNATIVE_GCC}")
196+
MESSAGE(STATUS "Using ${ALTERNATIVE_GPP}")
197+
# Use the new ABI so that std::string can be used with allocators
198+
# that are not default-constructible (e.g. Memroot_allocator)
199+
ADD_DEFINITIONS(-D_GLIBCXX_USE_CXX11_ABI=1)
200+
ELSE()
201+
MESSAGE(WARNING "Could not find newer gcc")
202+
ENDIF()
203+
ENDIF()
179204
ENDIF()
180205
ENDIF()
181206
ENDIF()
182207
ENDIF()
183208

184-
IF(ALTERNATIVE_ENABLE)
185-
GET_FILENAME_COMPONENT(ALTERNATIVE_ENABLE_DIR ${ALTERNATIVE_ENABLE} PATH)
186-
SET(DEVTOOLSET_ROOT "${ALTERNATIVE_ENABLE_DIR}/root")
187-
ENDIF()
188-
189209
# Optionally set project name, e.g.
190210
# foo.xcodeproj (mac) or foo.sln (windows)
191211
SET(MYSQL_PROJECT_NAME_DOCSTRING "MySQL project name")
@@ -795,12 +815,23 @@ IF(WITH_LTO)
795815
# to get the right plugins for supporting -flto output from gcc.
796816
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
797817
IF(ALTERNATIVE_ENABLE)
818+
GET_FILENAME_COMPONENT(ALTERNATIVE_ENABLE_DIR ${ALTERNATIVE_ENABLE} PATH)
819+
SET(DEVTOOLSET_ROOT "${ALTERNATIVE_ENABLE_DIR}/root")
798820
FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar
799821
NO_DEFAULT_PATH
800822
PATHS "${DEVTOOLSET_ROOT}/usr/bin")
801823
FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib
802824
NO_DEFAULT_PATH
803825
PATHS "${DEVTOOLSET_ROOT}/usr/bin")
826+
ELSEIF(ALTERNATIVE_GCC)
827+
STRING(REGEX MATCH "^([0-9])" ALTERNATIVE_GCC_MAJ_VER ${CMAKE_C_COMPILER_VERSION})
828+
GET_FILENAME_COMPONENT(ALTERNATIVE_GCC_DIR ${ALTERNATIVE_GCC} PATH)
829+
FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar-${ALTERNATIVE_GCC_MAJ_VER}
830+
NO_DEFAULT_PATH
831+
PATHS "${ALTERNATIVE_GCC_DIR}")
832+
FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib-${ALTERNATIVE_GCC_MAJ_VER}
833+
NO_DEFAULT_PATH
834+
PATHS "${ALTERNATIVE_GCC_DIR}")
804835
ELSE()
805836
FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar)
806837
FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib)

packaging/rpm-sles/mysql.spec.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ BuildRequires: ncurses-devel
133133
BuildRequires: openssl-devel
134134
BuildRequires: zlib-devel
135135
%{?sles11:BuildRequires: gcc48 gcc48-c++}
136+
%{?sles12:BuildRequires: gcc7 gcc7-c++}
136137
%if 0%{?systemd}
137138
BuildRequires: systemd
138139
BuildRequires: pkgconfig(systemd)

0 commit comments

Comments
 (0)