From 5bcfd5caeee90df18809a6f4c9a2e7e8f7734f8b Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Thu, 5 Aug 2021 08:36:21 +0200 Subject: [PATCH] cmake: Check -flto flags We should check if -flto-partition=none is defined when the compiler does not support symver attribute and fail the build if it is not. Fixes: https://tracker.ceph.com/issues/40060 Co-authored-by: Kefu Chai Signed-off-by: Boris Ranto --- cmake/modules/CephChecks.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/modules/CephChecks.cmake b/cmake/modules/CephChecks.cmake index 4317e4f4eec..01e1c7695e5 100644 --- a/cmake/modules/CephChecks.cmake +++ b/cmake/modules/CephChecks.cmake @@ -155,6 +155,12 @@ __attribute__((__symver__ (\"func@v2\"))) void func_v2() {}; int main() {}" HAVE_ATTR_SYMVER) + if(NOT HAVE_ATTR_SYMVER) + if(CMAKE_CXX_FLAGS MATCHES "-flto" AND NOT CMAKE_CXX_FLAGS MATCHES "-flto-partition=none") + # https://tracker.ceph.com/issues/40060 + message(FATAL_ERROR "please pass -flto-partition=none as part of CXXFLAGS") + endif() + endif() set(CMAKE_REQUIRED_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/version_script.txt) check_c_source_compiles(" void func_v1() {} -- 2.39.5