Skip to content

Commit

Permalink
Add gold linker support for Swift executables and shared libraries on…
Browse files Browse the repository at this point in the history
… Linux.

This skips the Swift standard library due to the linker script incompatibility
issue.

As before for other related projects, the build-script-impl option
'--use-gold-linker' triggers usage of this.


Swift SVN r32706
  • Loading branch information
Todd Fiala committed Oct 15, 2015
1 parent 76c06ba commit 711c76e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ set(SWIFT_VENDOR "" CACHE STRING
set(SWIFT_COMPILER_VERSION "" CACHE STRING
"The internal version of the Swift compiler")

# Indicate whether Swift should attempt to use the gold linker.
# This is not used on Darwin.
set(SWIFT_ENABLE_GOLD_LINKER FALSE CACHE BOOL
"Enable using the gold linker when available")

set(_SWIFT_KNOWN_INSTALL_COMPONENTS
"compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;arclite-symlink;stdlib;stdlib-experimental;sdk-overlay;editor-integration;lang-docs;tools;testsuite-tools;dev")

Expand Down
18 changes: 18 additions & 0 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,18 @@ function(_add_swift_library_single target name)
${SWIFTLIB_SINGLE_USE_INTERNAL_SDK}
link_flags)

# Handle gold linker flags for shared libraries.
if(SWIFT_ENABLE_GOLD_LINKER AND SWIFTLIB_SINGLE_SHARED)
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "LINUX")
# Extend the link_flags for the gold linker so long as this
# isn't the standard library. The standard library uses a
# linker script that isn't supported by the gold linker.
if(NOT SWIFTLIB_SINGLE_IS_STDLIB)
list(APPEND link_flags "-fuse-ld=gold")
endif()
endif()
endif()

# Configure plist creation for OS X.
set(PLIST_INFO_PLIST "Info.plist" CACHE STRING "Plist name")
if(APPLE AND SWIFTLIB_SINGLE_IS_STDLIB)
Expand Down Expand Up @@ -1622,6 +1634,12 @@ function(_add_swift_executable_single name)
"-Xlinker" "@executable_path/../lib/swift/${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK}_LIB_SUBDIR}")
endif()

if(SWIFT_ENABLE_GOLD_LINKER AND
( "${SWIFTEXE_SINGLE_SDK}" STREQUAL "LINUX" ) )
# Extend the link_flags for the gold linker.
list(APPEND link_flags "-fuse-ld=gold")
endif()

# Find the names of dependency library targets.
#
# We don't add the ${ARCH} to the target suffix because we want to link
Expand Down

0 comments on commit 711c76e

Please sign in to comment.