Skip to content

build: add option to use the gold linker #262

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

Merged
merged 1 commit into from
Jun 28, 2017
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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ set(USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR})

# TODO(compnerd) swift options

# TODO(compnerd) consider adding a flag for USE_GOLD_LINKER. Currently, we
# expect the user to specify `-fuse-ld=gold`
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR
CMAKE_SYSTEM_NAME STREQUAL Android)
set(USE_GOLD_LINKER_DEFAULT ON)
else()
set(USE_GOLD_LINKER_DEFAULT OFF)
endif()
option(USE_GOLD_LINKER "use the gold linker" ${USE_GOLD_LINKER_DEFAULT})

option(ENABLE_THREAD_LOCAL_STORAGE "enable usage of thread local storage via __thread" ON)
set(DISPATCH_USE_THREAD_LOCAL_STORAGE ${ENABLE_THREAD_LOCAL_STORAGE})
Expand Down
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
"-Xlinker -dead_strip"
"-Xlinker -alias_list -Xlinker ${CMAKE_SOURCE_DIR}/xcodeconfig/libdispatch.aliases")
endif()
if(USE_GOLD_LINKER)
set_property(TARGET dispatch
APPEND_STRING
PROPERTY LINK_FLAGS
-fuse-ld=gold)
endif()

install(TARGETS
dispatch
Expand Down