Skip to content

Commit

Permalink
Do not export symbols from private common utils
Browse files Browse the repository at this point in the history
Symbols from internal object files (from /common/utils) were exported
by all binaries (libdnf5.so, libdnf5-cli.so, dnf5, ...).
An archive of these object files is now created. And symbols from all
archive libraries are excluded from the automatic export.
  • Loading branch information
jrohel committed May 21, 2024
1 parent bcddeef commit a46b6d1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Give inline methods hidden visibility by default
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

# Excludes symbols in all archive libraries from automatic export
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--exclude-libs,ALL")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--exclude-libs,ALL")

# remove PROJECT_SOURCE_DIR prefix from __FILE__ macro used in asserts (available since GCC 8 and Clang 10)
add_compile_options("-fmacro-prefix-map=${PROJECT_SOURCE_DIR}/=")

Expand Down
2 changes: 1 addition & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ file(GLOB_RECURSE COMMON_SOURCES *.cpp *.c)

include_directories(.)

add_library(common OBJECT ${COMMON_SOURCES})
add_library(common STATIC ${COMMON_SOURCES})
set_property(TARGET common PROPERTY POSITION_INDEPENDENT_CODE ON)

# required by clang
Expand Down
2 changes: 2 additions & 0 deletions libdnf5-cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ install(TARGETS libdnf5-cli LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})

# link libraries and set pkg-config requires

target_link_libraries(libdnf5-cli PRIVATE common)

target_link_libraries(libdnf5-cli PUBLIC libdnf5)

pkg_check_modules(LIBFMT REQUIRED fmt)
Expand Down
2 changes: 1 addition & 1 deletion test/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ include_directories(${PROJECT_SOURCE_DIR}/libdnf5)
add_library(test_shared OBJECT ${TEST_SHARED_SOURCES})

target_link_directories(test_shared PUBLIC ${CMAKE_BINARY_DIR}/libdnf5)
target_link_libraries(test_shared PUBLIC stdc++ libdnf5 cppunit)
target_link_libraries(test_shared PUBLIC stdc++ common libdnf5 cppunit)

0 comments on commit a46b6d1

Please sign in to comment.