From 50680a3d9b2242b83e38094cefb6377dbfb4fd52 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 14 Nov 2023 14:07:04 +0800 Subject: [PATCH] Set symbol visibility to hidden This suppresses compiler warnings in GHA CI: >ld: warning: direct access in function 'std::__1::__function::__func, libtorrent::storage_interface* (libtorrent::storage_params const&, libtorrent::file_pool&)>::target(std::type_info const&) const' from file '/usr/local/lib/libtorrent-rasterbar.a(create_torrent.cpp.o)' to global weak symbol 'typeinfo name for libtorrent::storage_interface* (*)(libtorrent::storage_params const&, libtorrent::file_pool&)' from file 'src/base/libqbt_base.a(mocs_compilation.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. And also makes the binary a bit smaller. https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Code-Gen-Options.html#index-fvisibility PR #19921. --- cmake/Modules/CommonConfig.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/Modules/CommonConfig.cmake b/cmake/Modules/CommonConfig.cmake index 1e3a1d006..7cfc0641c 100644 --- a/cmake/Modules/CommonConfig.cmake +++ b/cmake/Modules/CommonConfig.cmake @@ -19,6 +19,9 @@ target_compile_features(qbt_common_cfg INTERFACE cxx_std_20 ) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) + target_compile_definitions(qbt_common_cfg INTERFACE QT_DISABLE_DEPRECATED_UP_TO=0x060500 QT_NO_CAST_FROM_ASCII