Skip to content

Commit

Permalink
feat(stonedb): To support gcc 9 and adds WITH_ROCKSDB and `WITH_MAR…
Browse files Browse the repository at this point in the history
…ISA` to specify where (stoneatom#377)

rocksdb and marisa installed, respectively.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
RingsC and mergify[bot] authored Aug 9, 2022
1 parent cd93ce1 commit 2dffcab
Show file tree
Hide file tree
Showing 7 changed files with 481 additions and 42 deletions.
28 changes: 5 additions & 23 deletions .github/workflows/integration-compile-mtr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ env:

jobs:
stonedb-build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
Expand All @@ -49,34 +49,14 @@ jobs:
- name: install libs
run: |
sudo git clone https://github.com/hustjieke/stonedb-libs.git
sudo git clone https://github.com/stoneatom/stonedb-libs.git
cd stonedb-libs
sudo tar -zxvf stonedb-boost.tar.gz
sudo tar -zxvf stonedb-gcc-rocksdb.tar.gz
sudo tar -zxvf stonedb-marisa.tar.gz
cd gcc7.3
sudo tar -zxvf bin.tar.gz
sudo tar -zxvf include.tar.gz
sudo tar -zxvf lib64.tar.gz
sudo tar -zxvf lib.tar.gz
sudo tar -zxvf share.tar.gz
cd libexec/gcc/x86_64-pc-linux-gnu/7.3.0
sudo tar -zxvf all.tar.gz
sudo tar -zxvf cc1plus.tar.gz
sudo tar -zxvf cc1.tar.gz
cd - && cd ..
sudo cp -r stonedb-boost /usr/local/stonedb-boost
sudo cp -r stonedb-boost/lib /usr/local/stonedb-boost/include
sudo cp -r stonedb-gcc-rocksdb /usr/local/stonedb-gcc-rocksdb
sudo cp -r stonedb-marisa /usr/local/stonedb-marisa
sudo cp -r gcc7.3 /usr/local/gcc7.3
sudo rm /usr/bin/gcc
sudo ln -s /usr/local/gcc7.3/bin/gcc /usr/bin/gcc
sudo rm /usr/bin/g++
sudo ln -s /usr/local/gcc7.3/bin/g++ /usr/bin/g++
sudo rm /usr/bin/c++
sudo ln -s /usr/local/gcc7.3/bin/c++ /usr/bin/c++
cd ..
- name: compile stonedb
run: |
Expand All @@ -96,7 +76,9 @@ jobs:
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_BOOST=/usr/local/stonedb-boost/include
-DWITH_BOOST=/usr/local/stonedb-boost \
-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb \
-DWITH_MARISA=/usr/local/stonedb-marisa
sudo make VERBOSE=1 -j`nproc`
sudo make install -j`nproc`
Expand Down
33 changes: 31 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,29 @@ OPTION(WITH_AUTHENTICATION_LDAP
OPTION(FORCE_UNSUPPORTED_COMPILER "Disable compiler version checks" OFF)
MARK_AS_ADVANCED(WITHOUT_SERVER DISABLE_SHARED FORCE_UNSUPPORTED_COMPILER)

#for boost, to check boost params.
INCLUDE(cmake/boost.cmake)
#Link directories under boost, etc.
IF (WITH_BOOST)
INCLUDE_DIRECTORIES("${WITH_BOOST}/include")
LINK_DIRECTORIES("${WITH_BOOST}/lib/")
ENDIF ()

#for rocksdb, to check rocksdb
INCLUDE(cmake/rocksdb.cmake)
#Link directories under rocksdb, etc.
IF (WITH_ROCKSDB)
INCLUDE_DIRECTORIES("${WITH_ROCKSDB}" "${WITH_ROCKSDB}/include")
LINK_DIRECTORIES("${WITH_ROCKSDB}")
ENDIF ()

#for marisa, to check marisa
INCLUDE(cmake/marisa.cmake)
#Link directories under marisa, etc.
IF (WITH_MARISA)
INCLUDE_DIRECTORIES("${WITH_MARISA}" "${WITH_MARISA}/include")
LINK_DIRECTORIES("${WITH_MARISA}" "${WITH_MARISA}/lib")
ENDIF ()

include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
Expand Down Expand Up @@ -481,6 +504,13 @@ IF (USE_CXX11 AND CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} -static-libstdc++ -static-libgcc")
ENDIF()

IF(WITH_BOOST AND WITH_ROCKSDB AND WITH_MARISA)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${WITH_BOOST}/lib;${WITH_ROCKSDB};${WITH_MARISA}/lib")
ELSE()
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${BOOST_INCLUDE_DIR};${ROCKSDB_INCLUDE_DIR};${MARISA_INCLUDE_DIR}")
ENDIF()
MESSAGE(STATUS "TO SET INSTALL RPATH FOR STONEDB: ${CMAKE_INSTALL_RPATH}")

OPTION(ENABLED_LOCAL_INFILE
"If we should enable LOAD DATA LOCAL by default" ${IF_WIN})
MARK_AS_ADVANCED(ENABLED_LOCAL_INFILE)
Expand Down Expand Up @@ -565,8 +595,6 @@ ELSE()
SET(DEFAULT_TMPDIR "\"${TMPDIR}\"")
ENDIF()

INCLUDE(cmake/boost.cmake)

IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
OPTION(WITH_SYSTEMD "Enable installation of systemd support files" OFF)
IF (WITH_SYSTEMD)
Expand All @@ -584,6 +612,7 @@ INCLUDE(configure.cmake)
# Common defines and includes
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
ADD_DEFINITIONS(-DTIANMU)
ADD_DEFINITIONS(-D_GLIBCXX_USE_CXX11_ABI=1)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_SOURCE_DIR}/extra/rapidjson/include
Expand Down
18 changes: 8 additions & 10 deletions cmake/boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

# We want boost 1.59.0 in order to build our boost/geometry code.
# We want boost 1.66.0 in order to build our boost/geometry code.
# The boost tarball is fairly big, and takes several minutes
# to download. So we recommend downloading/unpacking it
# only once, in a place visible from any bzr sandbox.
Expand Down Expand Up @@ -149,9 +149,8 @@ IF (WITH_BOOST)
)
## Did we get a path name to an unzippped version?
FIND_PATH(LOCAL_BOOST_DIR
NAMES "boost/version.hpp"
NAMES "include/boost/version.hpp"
PATHS ${WITH_BOOST}
${WITH_BOOST}/include
NO_DEFAULT_PATH
)
IF(LOCAL_BOOST_DIR)
Expand All @@ -165,7 +164,7 @@ ENDIF()
# There is a similar option in unittest/gunit.
# But the boost tarball is much bigger, so we have a separate option.
OPTION(DOWNLOAD_BOOST "Download boost from sourceforge." OFF)
SET(DOWNLOAD_BOOST_TIMEOUT 600 CACHE STRING
SET(DOWNLOAD_BOOST_TIMEOUT 6000 CACHE STRING
"Timeout in seconds when downloading boost.")

# If we could not find it, then maybe download it.
Expand Down Expand Up @@ -229,32 +228,31 @@ ENDIF()

# Search for the version file, first in LOCAL_BOOST_DIR or WITH_BOOST
FIND_PATH(BOOST_INCLUDE_DIR
NAMES boost/version.hpp
NAMES include/boost/version.hpp
NO_DEFAULT_PATH
PATHS ${LOCAL_BOOST_DIR}
${LOCAL_BOOST_DIR}/${BOOST_PACKAGE_NAME}
${WITH_BOOST}
${WITH_BOOST}/include
)
# Then search in standard places (if not found above).
FIND_PATH(BOOST_INCLUDE_DIR
NAMES boost/version.hpp
NAMES include/boost/version.hpp
)

IF(NOT BOOST_INCLUDE_DIR)
MESSAGE(STATUS
"Looked for boost/version.hpp in ${LOCAL_BOOST_DIR} and ${WITH_BOOST}")
"Looked for include/boost/version.hpp in ${LOCAL_BOOST_DIR} and ${WITH_BOOST}")
COULD_NOT_FIND_BOOST()
ELSE()
MESSAGE(STATUS "Found ${BOOST_INCLUDE_DIR}/boost/version.hpp ")
MESSAGE(STATUS "Found ${BOOST_INCLUDE_DIR}/include/boost/version.hpp ")
ENDIF()

# Verify version number. Version information looks like:
# // BOOST_VERSION % 100 is the patch level
# // BOOST_VERSION / 100 % 1000 is the minor version
# // BOOST_VERSION / 100000 is the major version
# #define BOOST_VERSION 105900
FILE(STRINGS "${BOOST_INCLUDE_DIR}/boost/version.hpp"
FILE(STRINGS "${BOOST_INCLUDE_DIR}/include/boost/version.hpp"
BOOST_VERSION_NUMBER
REGEX "^#define[\t ]+BOOST_VERSION[\t ][0-9]+.*"
)
Expand Down
139 changes: 139 additions & 0 deletions cmake/marisa.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Copyright (c) 2014, 2021, 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,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

# We want marisa in order to build our stonedb code.
# The marisa tarball is fairly big, and takes several minutes
# to download. So we recommend downloading/unpacking it
# only once, in a place visible from any bzr sandbox.
# We use only header files, so there should be no binary dependencies.

# Invoke with -DWITH_MARISA=<directory> or set WITH_MARISA in environment.
# If WITH_MARISA is *not* set, or is set to the special value "system",
# we assume that the correct version (see below)
# is installed on the compile host in the standard location.

SET(MARISA_PACKAGE_NAME "marisa-trie")
SET(MARISA_DOWNLOAD_URL
"https://github.com/s-yata/marisa-trie.gi"
)
SET(MARISA_TARBALL "${MARISA_PACKAGE_NAME}")

SET(OLD_PACKAGE_NAMES "")

MACRO(RESET_MARISA_VARIABLES)
UNSET(MARISA_INCLUDE_DIR)
UNSET(MARISA_INCLUDE_DIR CACHE)
UNSET(LOCAL_MARISA_DIR)
UNSET(LOCAL_MARISA_DIR CACHE)
ENDMACRO()

MACRO(ECHO_MARISA_VARIABLES)
MESSAGE(STATUS "MARISA_INCLUDE_DIR ${MARISA_INCLUDE_DIR}")
MESSAGE(STATUS "LOCAL_MARISA_DIR ${LOCAL_MARISA_DIR}")
ENDMACRO()

MACRO(COULD_NOT_FIND_MARISA)
ECHO_MARISA_VARIABLES()
RESET_MARISA_VARIABLES()
MESSAGE(STATUS "Could not find (the correct version of) marisa.")
MESSAGE(STATUS "MySQL currently requires ${MARISA_PACKAGE_NAME}\n")
MESSAGE(FATAL_ERROR
"You can download it, install it, then specify the marisa path "
"with -DWITH_MARISA=<director>\n"
"This CMake script will look for marisa in <directory>. "
)
ENDMACRO()

# Pick value from environment if not set on command line.
IF(DEFINED ENV{WITH_MARISA} AND NOT DEFINED WITH_MARISA)
SET(WITH_MARISA "$ENV{WITH_MARISA}")
ENDIF()

# Pick value from environment if not set on command line.
IF(DEFINED ENV{MARISA_ROOT} AND NOT DEFINED WITH_MARISA)
SET(WITH_MARISA "$ENV{MARISA_ROOT}")
ENDIF()

IF(WITH_MARISA AND WITH_MARISA STREQUAL "system")
UNSET(WITH_MARISA)
UNSET(WITH_MARISA CACHE)
ENDIF()

# Update the cache, to make it visible in cmake-gui.
SET(WITH_MARISA ${WITH_MARISA} CACHE PATH
"Path to marisa sources: a directory, or a tarball to be unzipped.")

# If the value of WITH_MARISA changes, we must unset all dependent variables:
IF(OLD_WITH_MARISA)
IF(NOT "${OLD_WITH_MARISA}" STREQUAL "${WITH_MARISA}")
RESET_MARISA_VARIABLES()
ENDIF()
ENDIF()

SET(OLD_WITH_MARISA ${WITH_MARISA} CACHE INTERNAL
"Previous version of WITH_MARISA" FORCE)

IF (WITH_MARISA)
## Did we get a path name to an unzippped version?
FIND_PATH(LOCAL_MARISA_DIR
NAMES "include/marisa.h"
PATHS ${WITH_MARISA}
NO_DEFAULT_PATH
)
IF(LOCAL_MARISA_DIR)
MESSAGE(STATUS "Local marisa dir ${LOCAL_MARISA_DIR}")
ENDIF()
ENDIF()

# Search for the header file, first in LOCAL_MARISA_DIR or WITH_MARISA
FIND_PATH(MARISA_INCLUDE_DIR
NAMES "include/marisa.h"
NO_DEFAULT_PATH
PATHS ${LOCAL_MARISA_DIR}
${LOCAL_MARISA_DIR}/${MARISA_PACKAGE_NAME}
${WITH_MARISA}
)
MESSAGE("found MARISA_INCLUDE_DIR:${MARISA_INCLUDE_DIR}")
# Then search in standard places (if not found above).
FIND_PATH(MARISA_INCLUDE_DIR
NAMES include/marisa.h
)
IF(NOT MARISA_INCLUDE_DIR)
MESSAGE(STATUS
"Looked for include/marisa.h in ${LOCAL_MARISA_DIR} and ${WITH_MARISA}")
COULD_NOT_FIND_MARISA()
ELSE()
MESSAGE(STATUS "Found ${MARISA_INCLUDE_DIR}/include/marisa.h ")
ENDIF()

MESSAGE(STATUS "MARISA_INCLUDE_DIR ${MARISA_INCLUDE_DIR}")

# Bug in sqrt(NaN) on 32bit platforms
IF(SIZEOF_VOIDP EQUAL 4)
ADD_DEFINITIONS(-DMARISA_GEOMETRY_SQRT_CHECK_FINITENESS)
ENDIF()

IF(LOCAL_MARISA_DIR OR LOCAL_MARISA_ZIP)
SET(USING_LOCAL_MARISA 1)
ELSE()
SET(USING_SYSTEM_MARISA 1)
ENDIF()
Loading

0 comments on commit 2dffcab

Please sign in to comment.