mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-20 14:05:23 +01:00
Merge bitcoin/bitcoin#31359: cmake: Add CheckLinkerSupportsPIE
module
81c174e318
cmake: Refer to the configure log instead of printing PIE test error (Hennadii Stepanov)65a0920ca6
cmake: Add `CheckLinkerSupportsPIE` module (Hennadii Stepanov) Pull request description: This new module is a wrapper around CMake's `CheckPIESupported` module that fixes an upstream bug. See: https://gitlab.kitware.com/cmake/cmake/-/issues/26463. Fixes https://github.com/bitcoin/bitcoin/issues/30771. ACKs for top commit: theuni: utACK81c174e318
. vasild: ACK81c174e318
Tree-SHA512: 77d7022238551a4e69c59d1fe6b78975bb552cbbed5339459853d7ebf0086813036081f464fed230be330b3bd7d6cf8590b536b064028d2f786d6ae40f342f95
This commit is contained in:
commit
06b9236f43
2 changed files with 29 additions and 10 deletions
|
@ -194,16 +194,8 @@ string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")
|
|||
|
||||
set(configure_warnings)
|
||||
|
||||
include(CheckPIESupported)
|
||||
check_pie_supported(OUTPUT_VARIABLE check_pie_output LANGUAGES CXX)
|
||||
if(CMAKE_CXX_LINK_PIE_SUPPORTED)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
elseif(NOT WIN32)
|
||||
# The warning is superfluous for Windows.
|
||||
message(WARNING "PIE is not supported at link time: ${check_pie_output}")
|
||||
list(APPEND configure_warnings "Position independent code disabled.")
|
||||
endif()
|
||||
unset(check_pie_output)
|
||||
include(CheckLinkerSupportsPIE)
|
||||
check_linker_supports_pie(configure_warnings)
|
||||
|
||||
# The core_interface library aims to encapsulate common build flags.
|
||||
# It is a usage requirement for all targets except for secp256k1, which
|
||||
|
|
27
cmake/module/CheckLinkerSupportsPIE.cmake
Normal file
27
cmake/module/CheckLinkerSupportsPIE.cmake
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Copyright (c) 2024-present The Bitcoin Core developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://opensource.org/license/mit/.
|
||||
|
||||
include_guard(GLOBAL)
|
||||
|
||||
function(check_linker_supports_pie warnings)
|
||||
# Workaround for a bug in the check_pie_supported() function.
|
||||
# See:
|
||||
# - https://gitlab.kitware.com/cmake/cmake/-/issues/26463
|
||||
# - https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10034
|
||||
if(CMAKE_VERSION VERSION_LESS 3.32)
|
||||
# CMAKE_CXX_COMPILE_OPTIONS_PIE is a list, whereas CMAKE_REQUIRED_FLAGS
|
||||
# must be a string. Therefore, a proper conversion is required.
|
||||
list(JOIN CMAKE_CXX_COMPILE_OPTIONS_PIE " " CMAKE_REQUIRED_FLAGS)
|
||||
endif()
|
||||
|
||||
include(CheckPIESupported)
|
||||
check_pie_supported(OUTPUT_VARIABLE output LANGUAGES CXX)
|
||||
if(CMAKE_CXX_LINK_PIE_SUPPORTED)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
|
||||
elseif(NOT WIN32)
|
||||
# The warning is superfluous for Windows.
|
||||
message(WARNING "PIE is not supported at link time. See the configure log for details.")
|
||||
set(${warnings} ${${warnings}} "Position independent code disabled." PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
Loading…
Add table
Reference in a new issue