Skip to content

Commit f186ff8

Browse files
authored
[Linux] Enable build-ids. (swiftlang#4995)
We should use build IDs on Linux so that we can identify the built artefacts, and also so that we can match them up with debug information should we choose to separate it. rdar://130582768
1 parent f28f4be commit f186ff8

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ else()
7474
endif()
7575
FetchContent_MakeAvailable(SwiftFoundationICU SwiftFoundation)
7676

77+
include(CheckLinkerFlag)
78+
79+
check_linker_flag(C "LINKER:--build-id=sha1" LINKER_SUPPORTS_BUILD_ID)
80+
7781
# Precompute module triple for installation
7882
if(NOT SwiftFoundation_MODULE_TRIPLE)
7983
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)

Sources/Foundation/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,9 @@ set_target_properties(Foundation PROPERTIES
171171
target_link_libraries(Foundation PUBLIC
172172
swiftDispatch)
173173

174+
if(LINKER_SUPPORTS_BUILD_ID)
175+
target_link_options(Foundation PRIVATE "LINKER:--build-id=sha1")
176+
endif()
177+
174178
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS Foundation)
175179
_foundation_install_target(Foundation)

Sources/FoundationNetworking/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,9 @@ target_link_options(FoundationNetworking PRIVATE
7171
set_target_properties(FoundationNetworking PROPERTIES
7272
INSTALL_RPATH "$ORIGIN")
7373

74+
if(LINKER_SUPPORTS_BUILD_ID)
75+
target_link_options(FoundationNetworking PRIVATE "LINKER:--build-id=sha1")
76+
endif()
77+
7478
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking)
7579
_foundation_install_target(FoundationNetworking)

Sources/FoundationXML/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,9 @@ target_link_options(FoundationXML PRIVATE
4646
set_target_properties(FoundationXML PROPERTIES
4747
INSTALL_RPATH "$ORIGIN")
4848

49+
if(LINKER_SUPPORTS_BUILD_ID)
50+
target_link_options(FoundationXML PRIVATE "LINKER:--build-id=sha1")
51+
endif()
52+
4953
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML)
5054
_foundation_install_target(FoundationXML)

0 commit comments

Comments
 (0)