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

Support mold linker #5331

Merged
merged 2 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions cmake/ClangTidy.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright (c) 2020 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
#

if (ENABLE_CLANG_TIDY)
if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
message(FATAL_ERROR "clang-tidy requires CMake version at least 3.6.")
Expand Down
18 changes: 18 additions & 0 deletions cmake/FindMoldLinker.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2023 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
#

find_program (MOLD NAMES "mold")
if (NOT MOLD)
message(FATAL_ERROR "Could not find the mold linker")
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1.0)
get_filename_component(MOLD_PATH ${MOLD} DIRECTORY)
nebula_add_exe_linker_flag(-B${MOLD_PATH}/../libexec/mold)
nebula_add_shared_linker_flag(-B${MOLD_PATH}/../libexec/mold)
else()
nebula_add_exe_linker_flag(-fuse-ld=mold)
nebula_add_shared_linker_flag(-fuse-ld=mold)
endif()
11 changes: 8 additions & 3 deletions cmake/nebula/LinkerConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(NEBULA_USE_LINKER
"bfd"
CACHE STRING "Linker to be used")
set(USER_LINKER_OPTION_VALUES "lld" "gold" "bfd")
set(USER_LINKER_OPTION_VALUES "lld" "gold" "bfd" "mold")
set_property(CACHE NEBULA_USE_LINKER PROPERTY STRINGS ${USER_LINKER_OPTION_VALUES})
list(
FIND
Expand All @@ -17,8 +17,13 @@ endif()

print_config(NEBULA_USE_LINKER)

nebula_add_exe_linker_flag(-fuse-ld=${NEBULA_USE_LINKER})
nebula_add_shared_linker_flag(-fuse-ld=${NEBULA_USE_LINKER})
if (${NEBULA_USE_LINKER} STREQUAL "mold")
include(FindMoldLinker)
else()
nebula_add_exe_linker_flag(-fuse-ld=${NEBULA_USE_LINKER})
nebula_add_shared_linker_flag(-fuse-ld=${NEBULA_USE_LINKER})
endif()

nebula_add_exe_linker_flag(-static-libstdc++)
nebula_add_exe_linker_flag(-static-libgcc)
nebula_add_exe_linker_flag(-no-pie)
Expand Down