Skip to content

Commit

Permalink
Bug#28542723: SWITCH TO GCC 7 ON SLES 12
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jhauglid authored and bjornmu committed Aug 31, 2018
1 parent 7634e1f commit bc367bf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
41 changes: 36 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio [1-9][0-9].*" AND
ENDIF()

# On Linux el6/el7 the default gcc is too old, see if devtoolset is installed.
# Same with SLES 12, look for gcc 7 there.
# We need to look for gcc before calling PROJECT below.
OPTION(FORCE_UNSUPPORTED_COMPILER "Disable compiler version checks" OFF)
MARK_AS_ADVANCED(WITHOUT_SERVER DISABLE_SHARED FORCE_UNSUPPORTED_COMPILER)
Expand Down Expand Up @@ -176,16 +177,35 @@ IF(CMAKE_HOST_UNIX AND NOT FORCE_UNSUPPORTED_COMPILER
ELSE()
MESSAGE(WARNING "Could not find devtoolset gcc")
ENDIF()
ELSEIF(MY_HOST_SYSTEM_NAME MATCHES "Linux" AND
EXISTS "/etc/os-release")
FILE(READ "/etc/os-release" MY_OS_RELEASE)
IF (MY_OS_RELEASE MATCHES "SUSE Linux Enterprise Server 12")
MESSAGE(STATUS "We need to look for a newer GCC on SLES 12")

FIND_PROGRAM(ALTERNATIVE_GCC gcc-7
NO_DEFAULT_PATH
PATHS "/usr/bin")
FIND_PROGRAM(ALTERNATIVE_GPP g++-7
NO_DEFAULT_PATH
PATHS "/usr/bin")
IF (ALTERNATIVE_GCC AND ALTERNATIVE_GPP)
SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC})
SET(CMAKE_CXX_COMPILER ${ALTERNATIVE_GPP})
MESSAGE(STATUS "Using ${ALTERNATIVE_GCC}")
MESSAGE(STATUS "Using ${ALTERNATIVE_GPP}")
# Use the new ABI so that std::string can be used with allocators
# that are not default-constructible (e.g. Memroot_allocator)
ADD_DEFINITIONS(-D_GLIBCXX_USE_CXX11_ABI=1)
ELSE()
MESSAGE(WARNING "Could not find newer gcc")
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDIF()
ENDIF()

IF(ALTERNATIVE_ENABLE)
GET_FILENAME_COMPONENT(ALTERNATIVE_ENABLE_DIR ${ALTERNATIVE_ENABLE} PATH)
SET(DEVTOOLSET_ROOT "${ALTERNATIVE_ENABLE_DIR}/root")
ENDIF()

# Optionally set project name, e.g.
# foo.xcodeproj (mac) or foo.sln (windows)
SET(MYSQL_PROJECT_NAME_DOCSTRING "MySQL project name")
Expand Down Expand Up @@ -795,12 +815,23 @@ IF(WITH_LTO)
# to get the right plugins for supporting -flto output from gcc.
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
IF(ALTERNATIVE_ENABLE)
GET_FILENAME_COMPONENT(ALTERNATIVE_ENABLE_DIR ${ALTERNATIVE_ENABLE} PATH)
SET(DEVTOOLSET_ROOT "${ALTERNATIVE_ENABLE_DIR}/root")
FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar
NO_DEFAULT_PATH
PATHS "${DEVTOOLSET_ROOT}/usr/bin")
FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib
NO_DEFAULT_PATH
PATHS "${DEVTOOLSET_ROOT}/usr/bin")
ELSEIF(ALTERNATIVE_GCC)
STRING(REGEX MATCH "^([0-9])" ALTERNATIVE_GCC_MAJ_VER ${CMAKE_C_COMPILER_VERSION})
GET_FILENAME_COMPONENT(ALTERNATIVE_GCC_DIR ${ALTERNATIVE_GCC} PATH)
FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar-${ALTERNATIVE_GCC_MAJ_VER}
NO_DEFAULT_PATH
PATHS "${ALTERNATIVE_GCC_DIR}")
FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib-${ALTERNATIVE_GCC_MAJ_VER}
NO_DEFAULT_PATH
PATHS "${ALTERNATIVE_GCC_DIR}")
ELSE()
FIND_PROGRAM(GCC_AR_EXECUTABLE gcc-ar)
FIND_PROGRAM(GCC_RANLIB_EXECUTABLE gcc-ranlib)
Expand Down
1 change: 1 addition & 0 deletions packaging/rpm-sles/mysql.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ BuildRequires: ncurses-devel
BuildRequires: openssl-devel
BuildRequires: zlib-devel
%{?sles11:BuildRequires: gcc48 gcc48-c++}
%{?sles12:BuildRequires: gcc7 gcc7-c++}
%if 0%{?systemd}
BuildRequires: systemd
BuildRequires: pkgconfig(systemd)
Expand Down

0 comments on commit bc367bf

Please sign in to comment.