Skip to content

Commit 9512507

Browse files
committed
[Linux] Enable build IDs.
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://130582882
1 parent e0c3868 commit 9512507

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ endif()
2323

2424
include(SwiftSupport)
2525
include(GNUInstallDirs)
26+
include(CheckLinkerFlag)
27+
28+
if(CMAKE_SYSTEM_NAME STREQUAL Linux
29+
OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD
30+
OR CMAKE_SYSTEM_NAME STREQUAL OpenBSD)
31+
enable_language(C)
32+
check_linker_flag(C "LINKER:--build-id=sha1" LINKER_SUPPORTS_BUILD_ID)
33+
endif()
2634

2735
add_library(XCTest
2836
Sources/XCTest/Private/WallClockTimeMetric.swift
@@ -79,6 +87,10 @@ set_target_properties(XCTest PROPERTIES
7987
Swift_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swift
8088
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/swift)
8189

90+
if(LINKER_SUPPORTS_BUILD_ID)
91+
target_link_options(XCTest PRIVATE "LINKER:--build-id=sha1")
92+
endif()
93+
8294

8395
if(ENABLE_TESTING)
8496
enable_testing()

0 commit comments

Comments
 (0)