Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor building #1332

Merged
merged 87 commits into from
Jan 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
3cb2757
Refactor building
dutor Nov 20, 2019
809df1c
Fix krb5 to depend on bison
dutor Nov 27, 2019
f1e87e9
Fixed required GCC version
dutor Nov 28, 2019
1611915
Fix building on ubuntu 16.04
dutor Nov 28, 2019
34ae1f2
Fixed cmake version requirement
dutor Nov 28, 2019
c3bfefc
Fixed mstch to depend on boost
dutor Nov 28, 2019
3d69e96
Added lz4
dutor Nov 28, 2019
4f89b5e
Added build-gcc.sh
dutor Nov 30, 2019
11ec02a
Added setup/resort-env.sh for GCC and CMake
dutor Nov 30, 2019
c8ac77e
Added hints for setup/restore-env.sh
dutor Nov 30, 2019
cd4ccc4
Fix to use readlink instead of realpath
dutor Nov 30, 2019
8f2b0a5
Renamed setup/restore-env to enable/disable
dutor Nov 30, 2019
a824ed4
Added binutils
dutor Nov 30, 2019
599242f
Fixed symlink creation in lz4
dutor Nov 30, 2019
e22b3e1
Stripped binutils
dutor Nov 30, 2019
980952f
Add make-package
dutor Dec 1, 2019
057d470
Add --prefix to build-gcc
dutor Dec 1, 2019
d1e8736
Fix prefix
dutor Dec 1, 2019
fb4a4f8
Fixed indentation
dutor Dec 1, 2019
66c7373
Fix make-package
dutor Dec 1, 2019
59989ed
Build binutils in source
dutor Dec 2, 2019
ed03b9d
Added gdb
dutor Dec 2, 2019
29e3928
Upgrade toolchain
dutor Dec 2, 2019
a552547
Remove gdb due to the need of a C++11 compiler
dutor Dec 3, 2019
bbc41d9
Downgrade
dutor Dec 3, 2019
326b4b3
fix typo
dutor Dec 3, 2019
8fa93ea
Fix checksum
dutor Dec 3, 2019
91c9702
Fixed building under GCC 4.4.7
dutor Dec 3, 2019
685d244
Added some comments
dutor Dec 3, 2019
ebea6f0
Add distro name
dutor Dec 4, 2019
0ce40b9
Remove --skip-old-files due to lack support by older tar command
dutor Dec 4, 2019
8471e19
Added guess-building-jobs-num.sh
dutor Dec 4, 2019
7cd974c
Added compiler testing script
dutor Dec 4, 2019
98af464
Added testing after build and install
dutor Dec 4, 2019
12fa3c7
Change enable-gcc.sh to enable
dutor Dec 4, 2019
3222c12
Fix guessing building jobs num
dutor Dec 4, 2019
b290cad
Make build log less verbose
dutor Dec 4, 2019
6c47611
Disable CMakel log
dutor Dec 4, 2019
669392f
Fixed exit on error
dutor Dec 5, 2019
50e4538
Added install-gcc.sh
dutor Dec 5, 2019
8864383
Address darionyaphet's comment
dutor Dec 5, 2019
a7843cb
Update cn docs on build
dutor Dec 5, 2019
8e5d1c7
Update cn docs on build
dutor Dec 5, 2019
33658f4
Added prebuilt GCC for glibc 2.17, 2.19
dutor Dec 5, 2019
9aa3572
Merge branch 'master' into refactor-building
dutor Dec 5, 2019
be22919
Changed prefix
dutor Dec 13, 2019
e8592e0
Ignore error when cleaning
dutor Dec 13, 2019
6934c2c
Fixed gcc/disable
dutor Dec 17, 2019
3ed629c
Reduce build size
dutor Dec 17, 2019
8ac52bd
Fixed possible depending on system libverto
dutor Dec 18, 2019
e46df1f
Merged upstream
dutor Dec 18, 2019
528b164
Removed rpath
dutor Dec 18, 2019
3c12057
Print on failure
dutor Dec 18, 2019
2aeca6e
Don't fail when grep not matched
dutor Dec 18, 2019
a0d86c9
Build third party automatically
dutor Dec 18, 2019
7a02fc8
Revert the last commit
dutor Dec 19, 2019
29f9651
Remove docs(will update in another PR)
dutor Dec 20, 2019
be2d112
Merged upstream
dutor Dec 20, 2019
b44f36c
Build third party package
dutor Dec 20, 2019
89ecc9d
Fix unknown automake building issue due to pipefail and multi-jobs
dutor Dec 20, 2019
74a4694
Changed default installation prefix to /opt/vesoft
dutor Dec 22, 2019
a8fe38c
Fixed static-libstdc++
dutor Dec 22, 2019
76406ee
Supported build with cxx11 abi
dutor Dec 22, 2019
8560842
Support for toggle cxx abi
dutor Dec 22, 2019
85bce00
Fix DISABLE_CXX11_ABI
dutor Dec 22, 2019
bc8751f
Fixed for RedHat devtoolset
dutor Dec 23, 2019
b0126da
Make Bison and krb5 relocatable
dutor Dec 23, 2019
e3e193e
Install third-party automatically
dutor Dec 23, 2019
1821ce0
Show selected version while downloading
dutor Dec 23, 2019
ed33656
Fixed relocatable for Bison in old CMake
dutor Dec 23, 2019
50acf8e
Changed presets of libc and libcxx
dutor Dec 24, 2019
9b4dc27
Add build-all-third-party.sh to build third-party with multiple versi…
dutor Dec 24, 2019
9a2351e
Unconditionally build flex and bison while building package
dutor Dec 24, 2019
1a84d71
Fixed ENV testing
dutor Dec 24, 2019
1a9d06a
Added prebuilt third party for libc-2.27
dutor Dec 24, 2019
6452f82
Deal with gold linker
dutor Dec 25, 2019
10d6a73
Renamed parser_benchmark to parser_bm
dutor Dec 25, 2019
4d38634
Merge remote-tracking branch 'upstream/master' into refactor-building
dutor Dec 25, 2019
8c5d21a
Moved setting on test binaries to nebula_add_executable
dutor Dec 25, 2019
7d699d5
Remove support for customizing level of debug info
dutor Dec 25, 2019
37dc887
Fixed for ubuntu 19.04 whose glibcxx version is messed
dutor Dec 26, 2019
78e7726
Address @laura-ding's comments
dutor Dec 27, 2019
c7d41da
Address @laura-ding's comments
dutor Dec 27, 2019
5411cf6
Merge branch 'master' into refactor-building
dutor Dec 30, 2019
64c9632
Merge branch 'master' into refactor-building
dutor Dec 31, 2019
f010158
Fixed for GCC 7
dutor Dec 31, 2019
3b3865e
Merge branch 'master' into refactor-building
dutor Jan 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 61 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@
# ENABLE_NATIVE -- Build native client
# ENABLE_TESTING -- Build unit test
#
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.5.0)

project("Nebula Graph" C CXX)

# Set the project home dir
set(NEBULA_HOME ${CMAKE_CURRENT_SOURCE_DIR})
# To include customized FindXXX.cmake modules
set(CMAKE_MODULE_PATH "${NEBULA_HOME}/cmake" ${CMAKE_MODULE_PATH})
include(LinkerConfig)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -no-pie")

set(CMAKE_SKIP_RPATH TRUE)

option(ENABLE_JEMALLOC "Whether to link jemalloc to all executables" ON)
Expand Down Expand Up @@ -53,8 +60,7 @@ endif()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -no-pie")
set(CMAKE_CXX_EXTENSIONS OFF)

# To detect if ccache available
find_program(ccache_program_found "ccache")
Expand Down Expand Up @@ -84,15 +90,31 @@ if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_definitions(-D_FORTIFY_SOURCE=2)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--compress-debug-sections=zlib")
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if (NOT ${NEBULA_USE_LINKER} STREQUAL "gold")
# gold linker is buggy for `--gc-sections', disabled for now
add_compile_options(-ffunction-sections)
add_compile_options(-fdata-sections)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
endif()
endif()

message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE} "
"(Options are: Debug, Release, RelWithDebInfo, MinSizeRel)")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "_build")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "_build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "_build")
# By default, all dynamic and static libraries will be placed at ${CMAKE_BINARY_DIR}/lib,
# while all executables at ${CMAKE_BINARY_DIR}/bin.
# But for the sake of cleanliness, all executables ending with `_test' will be placed
# at ${CMAKE_BINARY_DIR}/bin/test, while those ending with `_bm' at ${CMAKE_BINARY_DIR}/bin/bench.
# Please see `nebula_add_executable' for this rule.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

# Set the project home dir
set(NEBULA_HOME ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(-DNEBULA_HOME=${NEBULA_HOME})

# Let s2 use glog
Expand Down Expand Up @@ -121,12 +143,22 @@ if (GIT_INFO_SHA)
add_definitions(-DGIT_INFO_SHA=${GIT_INFO_SHA})
endif()

# To include customized FindXXX.cmake modules
set(CMAKE_MODULE_PATH "${NEBULA_HOME}/cmake" ${CMAKE_MODULE_PATH})

# When NEBULA_THIRDPARTY_ROOT is null, set default value as /opt/nebula/third-party
# The precedence to decide NEBULA_THIRDPARTY_ROOT is:
# 1. The path defined with CMake argument, i.e -DNEBULA_THIRDPARTY_ROOT=path
# 2. ${CMAKE_BINARY_DIR}/third-party/install, if exists
# 3. The path specified with environment variable NEBULA_THIRDPARTY_ROOT=path
# 4. /opt/vesoft/third-party, if exists
# 5. At last, one copy will be downloaded and installed to ${CMAKE_BINARY_DIR}/third-party/install
if("${NEBULA_THIRDPARTY_ROOT}" STREQUAL "")
SET(NEBULA_THIRDPARTY_ROOT "/opt/nebula/third-party")
if(EXISTS ${CMAKE_BINARY_DIR}/third-party/install)
SET(NEBULA_THIRDPARTY_ROOT ${CMAKE_BINARY_DIR}/third-party/install)
elseif(NOT $ENV{NEBULA_THIRDPARTY_ROOT} STREQUAL "")
SET(NEBULA_THIRDPARTY_ROOT $ENV{NEBULA_THIRDPARTY_ROOT})
elseif(EXISTS /opt/vesoft/third-party)
SET(NEBULA_THIRDPARTY_ROOT "/opt/vesoft/third-party")
else()
include(InstallThirdParty)
endif()
endif()

if ("${NEBULA_CLANG_USED_GCC_TOOLCHAIN}" STREQUAL "")
Expand Down Expand Up @@ -190,6 +222,7 @@ find_package(Krb5 REQUIRED gssapi)
find_package(GPERF 2.8 REQUIRED)
find_package(Libunwind REQUIRED)
find_package(BISON 3.0.5 REQUIRED)
include(MakeBisonRelocatable)
find_package(FLEX REQUIRED)
find_package(Readline REQUIRED)
find_package(NCURSES REQUIRED)
Expand Down Expand Up @@ -274,6 +307,18 @@ macro(nebula_add_executable)
${nebula_exec_NAME}
${nebula_exec_LIBRARIES}
)

if(${nebula_exec_NAME} MATCHES "_test$")
set_target_properties(
${nebula_exec_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test
)
elseif(${nebula_exec_NAME} MATCHES "_bm$")
set_target_properties(
${nebula_exec_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/bench
)
endif()
endmacro()

macro(nebula_add_test)
Expand Down Expand Up @@ -364,7 +409,7 @@ set(THRIFT_LIBRARIES
set(ROCKSDB_LIBRARIES ${Rocksdb_LIBRARY})

# All compression libraries
set(COMPRESSION_LIBRARIES bz2 snappy zstd z)
set(COMPRESSION_LIBRARIES bz2 snappy zstd z lz4)
if (LIBLZMA_FOUND)
include_directories(SYSTEM ${LIBLZMA_INCLUDE_DIRS})
list(APPEND COMPRESSION_LIBRARIES ${LIBLZMA_LIBRARIES})
Expand Down Expand Up @@ -404,14 +449,15 @@ macro(nebula_link_libraries target)
boost_system
event
double-conversion
resolv
s2
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
${KRB5_LIBRARIES}
${COMPRESSION_LIBRARIES}
${JEMALLOC_LIB}
${LIBUNWIND_LIBRARIES}
keyutils
dutor marked this conversation as resolved.
Show resolved Hide resolved
resolv
dutor marked this conversation as resolved.
Show resolved Hide resolved
dl
${GETTIME_LIB}
-pthread
Expand Down
7 changes: 7 additions & 0 deletions cmake/BuildThirdParty.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
execute_process(
COMMAND
${CMAKE_SOURCE_DIR}/third-party/build-third-party.sh
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}
)
set(NEBULA_THIRDPARTY_ROOT ${CMAKE_BINARY_DIR}/third-party/install)
2 changes: 1 addition & 1 deletion cmake/FindDoubleConversion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# DoubleConversion_INCLUDE_DIR The double-conversion includes directories.
# DoubleConversion_LIBRARY The double-conversion library.

find_path(DoubleConversion_INCLUDE_DIR NAMES double-conversion.h)
find_path(DoubleConversion_INCLUDE_DIR NAMES double-conversion/double-conversion.h)
find_library(DoubleConversion_LIBRARY NAMES libdouble-conversion.a)

if(DoubleConversion_INCLUDE_DIR AND DoubleConversion_LIBRARY)
Expand Down
12 changes: 12 additions & 0 deletions cmake/InstallThirdParty.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(third_party_install_prefix ${CMAKE_BINARY_DIR}/third-party/install)
message(STATUS "Downloading prebuilt third party automatically...")
execute_process(
COMMAND
env CXX=${CMAKE_CXX_COMPILER} ${CMAKE_SOURCE_DIR}/third-party/install-third-party.sh --prefix=${third_party_install_prefix}
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}
)
if(EXISTS ${third_party_install_prefix})
set(NEBULA_THIRDPARTY_ROOT ${third_party_install_prefix})
endif()
unset(third_party_install_prefix)
22 changes: 22 additions & 0 deletions cmake/LinkerConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
execute_process(
COMMAND
ld --version
COMMAND
head -1
COMMAND
cut -d " " -f2
OUTPUT_VARIABLE default_linker_type
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (${default_linker_type} STREQUAL "ld")
set(default_linker_type "bfd")
endif()

if (NOT DEFINED NEBULA_USE_LINKER)
set(NEBULA_USE_LINKER ${default_linker_type})
endif()

message(STATUS "NEBULA_USE_LINKER: ${NEBULA_USE_LINKER}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${NEBULA_USE_LINKER}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=${NEBULA_USE_LINKER}")
17 changes: 17 additions & 0 deletions cmake/MakeBisonRelocatable.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(BISON_EXECUTE_ENV "")
execute_process(
COMMAND ${BISON_EXECUTABLE} --print-datadir
OUTPUT_VARIABLE bison_encoded_data_dir
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT EXISTS ${bison_encoded_data_dir})
get_filename_component(bison_prefix ${BISON_EXECUTABLE} DIRECTORY)
get_filename_component(bison_prefix ${bison_prefix} DIRECTORY)
if(EXISTS ${bison_prefix}/share/bison)
set(BISON_EXECUTE_ENV "BISON_PKGDATADIR=${bison_prefix}/share/bison")
endif()
endif()
if(NOT ${BISON_EXECUTE_ENV} STREQUAL "")
set(BISON_EXECUTABLE ${CMAKE_COMMAND} -E env ${BISON_EXECUTE_ENV} ${BISON_EXECUTABLE})
endif()

4 changes: 2 additions & 2 deletions src/graph/GroupByExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ Status GroupByExecutor::generateOutputSchema() {
StatusOr<std::unique_ptr<InterimResult>> GroupByExecutor::setupInterimResult() {
auto result = std::make_unique<InterimResult>(getResultColumnNames());
if (rows_.empty() || resultSchema_ == nullptr) {
return result;
return std::move(result);
}
// Generate results
std::unique_ptr<RowSetWriter> rsWriter = std::make_unique<RowSetWriter>(resultSchema_);
Expand All @@ -399,7 +399,7 @@ StatusOr<std::unique_ptr<InterimResult>> GroupByExecutor::setupInterimResult() {
if (rsWriter != nullptr) {
result->setInterim(std::move(rsWriter));
}
return result;
dutor marked this conversation as resolved.
Show resolved Hide resolved
return std::move(result);
}


Expand Down
4 changes: 2 additions & 2 deletions src/graph/LimitExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void LimitExecutor::feedResult(std::unique_ptr<InterimResult> result) {
StatusOr<std::unique_ptr<InterimResult>> LimitExecutor::setupInterimResult() {
auto result = std::make_unique<InterimResult>(std::move(colNames_));
if (rows_.empty()) {
return result;
return std::move(result);
}

auto rsWriter = std::make_unique<RowSetWriter>(inputs_->schema());
Expand Down Expand Up @@ -121,7 +121,7 @@ StatusOr<std::unique_ptr<InterimResult>> LimitExecutor::setupInterimResult() {
if (rsWriter != nullptr) {
result->setInterim(std::move(rsWriter));
}
return result;
return std::move(result);
}


Expand Down
4 changes: 2 additions & 2 deletions src/graph/OrderByExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Status OrderByExecutor::beforeExecute() {
StatusOr<std::unique_ptr<InterimResult>> OrderByExecutor::setupInterimResult() {
auto result = std::make_unique<InterimResult>(std::move(colNames_));
if (rows_.empty()) {
return result;
return std::move(result);
}

auto schema = inputs_->schema();
Expand Down Expand Up @@ -201,7 +201,7 @@ StatusOr<std::unique_ptr<InterimResult>> OrderByExecutor::setupInterimResult() {
}

result->setInterim(std::move(rsWriter));
return result;
return std::move(result);
}

void OrderByExecutor::setupResponse(cpp2::ExecutionResponse &resp) {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ nebula_add_test(
)

nebula_add_executable(
NAME parser_benchmark
NAME parser_bm
SOURCES ParserBenchmark.cpp
OBJECTS ${PARSER_TEST_LIBS}
LIBRARIES follybenchmark boost_regex ${THRIFT_LIBRARIES} wangle
Expand Down
Loading