From 8e43e3ec3760f2b0d5c7ac31564ff27ef2863948 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 26 Jun 2024 13:57:01 +0100 Subject: [PATCH] [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://130582819 --- CMakeLists.txt | 3 +++ src/BlocksRuntime/CMakeLists.txt | 4 ++++ src/CMakeLists.txt | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b11d52266..4cb17649a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,7 @@ include(CheckCSourceCompiles) include(CheckFunctionExists) include(CheckIncludeFiles) include(CheckLibraryExists) +include(CheckLinkerFlag) include(CheckSymbolExists) include(GNUInstallDirs) include(CTest) @@ -175,6 +176,8 @@ option(ENABLE_THREAD_LOCAL_STORAGE "enable usage of thread local storage via _Th set(DISPATCH_USE_THREAD_LOCAL_STORAGE ${ENABLE_THREAD_LOCAL_STORAGE}) +check_linker_flag(C "LINKER:--build-id=sha1" LINKER_SUPPORTS_BUILD_ID) + check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE) if(_GNU_SOURCE) set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE) diff --git a/src/BlocksRuntime/CMakeLists.txt b/src/BlocksRuntime/CMakeLists.txt index 50123d4b7..945e87a7e 100644 --- a/src/BlocksRuntime/CMakeLists.txt +++ b/src/BlocksRuntime/CMakeLists.txt @@ -22,6 +22,10 @@ endif() set_target_properties(BlocksRuntime PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +if(LINKER_SUPPORTS_BUILD_ID) + target_link_options(BlocksRuntime PRIVATE "LINKER:--build-id=sha1") +endif() + add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime) install(FILES Block.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 570c9197f..320b6fcdc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -178,6 +178,10 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") set_target_properties(dispatch PROPERTIES INSTALL_RPATH "$ORIGIN") endif() +if(LINKER_SUPPORTS_BUILD_ID) + target_link_options(dispatch PRIVATE "LINKER:--build-id=sha1") +endif() + if(ENABLE_SWIFT) add_subdirectory(swift) endif()