From a2a7b2043b4c77715841e44950a9fe7926dbafd1 Mon Sep 17 00:00:00 2001 From: dragon Date: Wed, 8 Jul 2026 19:47:10 +0300 Subject: [PATCH] build(cmake): fix dead code elimination for common static libs - force the linker to include all symbols from common_lib and common_proto_lib by wrapping them with -Wl,--whole-archive - this prevents the compiler from discarding essential unreferenced code during the optimization phase for both gnb_app and ue_app executables Close #75 --- gnb/CMakeLists.txt | 8 +++++++- ue/CMakeLists.txt | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gnb/CMakeLists.txt b/gnb/CMakeLists.txt index 861c52d..7d74466 100644 --- a/gnb/CMakeLists.txt +++ b/gnb/CMakeLists.txt @@ -29,7 +29,13 @@ target_link_libraries(gnb_lib PUBLIC if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/gnb_main.cpp") add_executable(gnb_app src/gnb_main.cpp) - target_link_libraries(gnb_app PRIVATE gnb_lib) + target_link_libraries(gnb_app PRIVATE + gnb_lib + -Wl,--whole-archive + common_lib + common_proto_lib + -Wl,--no-whole-archive + ) endif() if(BUILD_TESTS) diff --git a/ue/CMakeLists.txt b/ue/CMakeLists.txt index 2b42b9f..31fcd9b 100644 --- a/ue/CMakeLists.txt +++ b/ue/CMakeLists.txt @@ -27,7 +27,13 @@ target_link_libraries(ue_lib PUBLIC if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/ue_main.cpp") add_executable(ue_app src/ue_main.cpp) - target_link_libraries(ue_app PRIVATE ue_lib) + target_link_libraries(ue_app PRIVATE + ue_lib + -Wl,--whole-archive + common_lib + common_proto_lib + -Wl,--no-whole-archive + ) endif() if(BUILD_TESTS)