Skip to content

Commit

Permalink
#1105: cmake: use gold linker by default (faster, less memory)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander authored and Braden Mailloux committed Oct 15, 2020
1 parent dc03ef0 commit 5d618a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ include(cmake/build_git_info.cmake)

include(cmake/check_compiler.cmake)

option(vt_gold_linker_enabled "Build VT using the `gold' linker" ON)

option(vt_fcontext_enabled "Build VT with fcontext (ULT) enabled" OFF)

string(TOLOWER ${CMAKE_BUILD_TYPE} LOWERCASE_CMAKE_BUILD_TYPE)
Expand Down
20 changes: 20 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,26 @@ target_compile_features(
target_compile_options(${VIRTUAL_TRANSPORT_LIBRARY} PUBLIC ${CXX_STANDARD_FLAGS})
target_compile_options(${VIRTUAL_TRANSPORT_LIBRARY} PUBLIC ${VT_TARGET_CXX_FLAGS})

if (vt_gold_linker_enabled)
if (UNIX AND NOT APPLE)
execute_process(
COMMAND
${CMAKE_C_COMPILER}
-fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version
)
if ("${ld_version}" MATCHES "GNU gold")
set(
CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags"
)
set(
CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags"
)
endif()
endif()
endif()

link_target_with_vt(
TARGET ${VIRTUAL_TRANSPORT_LIBRARY}
LINK_VT_LIB
Expand Down

0 comments on commit 5d618a2

Please sign in to comment.