Skip to content

Commit b651af1

Browse files
Underlinking fix (#787)
* CMakeLists.txt: Stop hardcoding the ZLIB string, it is automatically done via find_package(ZLIB) already * Make sure dlt_daemon links zlib, this is because it uses internal symbols of zlib dpkg-shlibdeps: warning: symbol gzfwrite used by debian/libdlt-dev/usr/lib/x86_64-linux-gnu/libdlt_daemon.so found in * Try harder to fix underlink, and use the dlt_daemon library if available to avoid code duplication * Fix build when zlib is not installed
1 parent b33aa40 commit b651af1

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ set(LICENSE "Mozilla Public License Version 2.0")
130130
find_package(Threads REQUIRED)
131131
if(WITH_DLT_LOGSTORAGE_GZIP)
132132
find_package(ZLIB 1.2.9 REQUIRED)
133-
set(ZLIB_LIBRARY "ZLIB::ZLIB")
134133
elseif(WITH_DLT_COREDUMPHANDLER OR WITH_DLT_FILETRANSFER)
135134
find_package(ZLIB REQUIRED)
136-
set(ZLIB_LIBRARY "ZLIB::ZLIB")
137135
else()
138136
set(ZLIB_LIBRARY "")
139137
endif()

src/daemon/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if (WITH_SYSTEMD_SOCKET_ACTIVATION)
6767
target_link_libraries(dlt-daemon systemd)
6868
endif()
6969
if (WITH_DLT_LOGSTORAGE_GZIP)
70-
target_link_libraries(dlt-daemon ${ZLIB_LIBRARY})
70+
target_link_libraries(dlt-daemon ${ZLIB_LIBRARY})
7171
endif()
7272

7373
install(TARGETS dlt-daemon
@@ -87,12 +87,24 @@ if (WITH_DLT_UNIT_TESTS)
8787

8888
add_library(dlt_daemon ${library_SRCS})
8989
target_link_libraries(dlt_daemon ${RT_LIBRARY} ${SOCKET_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
90+
if (WITH_DLT_LOGSTORAGE_GZIP)
91+
target_link_libraries(dlt_daemon ${ZLIB_LIBRARY})
92+
endif()
9093

9194
install(TARGETS dlt_daemon
9295
RUNTIME DESTINATION bin
9396
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
9497
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
9598
COMPONENT base)
99+
100+
if(NOT WITH_LIB_NO_VERSION)
101+
if(WITH_LIB_SHORT_VERSION)
102+
set_target_properties(dlt_daemon PROPERTIES VERSION ${PROJECT_VERSION_MAJOR} SOVERSION ${PROJECT_VERSION_MAJOR})
103+
else()
104+
set_target_properties(dlt_daemon PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
105+
endif()
106+
endif()
107+
96108
endif(WITH_DLT_UNIT_TESTS)
97109

98110
INSTALL(FILES dlt.conf

src/offlinelogstorage/dlt_offline_logstorage.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353

5454
#include <search.h>
5555
#include <stdbool.h>
56+
#ifdef DLT_LOGSTORAGE_USE_GZIP
5657
#include <zlib.h>
58+
#endif
5759
#include "dlt_common.h"
5860
#include "dlt-daemon_cfg.h"
5961
#include "dlt_config_file_parser.h"
@@ -214,7 +216,9 @@ struct DltLogStorageFilterConfig
214216
int status);
215217
FILE *log; /* current open log file */
216218
int fd; /* The file descriptor for the active log file */
219+
#ifdef DLT_LOGSTORAGE_USE_GZIP
217220
gzFile *gzlog; /* current open gz log file */
221+
#endif
218222
void *cache; /* log data cache */
219223
unsigned int specific_size; /* cache size used for specific_size sync strategy */
220224
unsigned int current_write_file_offset; /* file offset for specific_size sync strategy */

src/offlinelogstorage/dlt_offline_logstorage_behavior.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,11 +1108,15 @@ int dlt_logstorage_prepare_on_msg(DltLogStorageFilterConfig *config,
11081108
if ((config->sync == DLT_LOGSTORAGE_SYNC_ON_MSG) ||
11091109
(config->sync == DLT_LOGSTORAGE_SYNC_UNSET)) {
11101110
if (config->gzip_compression == DLT_LOGSTORAGE_GZIP_ON) {
1111+
#ifdef DLT_LOGSTORAGE_USE_GZIP
11111112
if (fsync(fileno(config->gzlog)) != 0) {
11121113
if (errno != ENOSYS) {
11131114
dlt_vlog(LOG_ERR, "%s: failed to sync gzip log file\n", __func__);
11141115
}
11151116
}
1117+
#else
1118+
dlt_vlog(LOG_ERR, "%s: dlt-daemon not compiled with logstorage gzip support\n", __func__);
1119+
#endif
11161120
}
11171121
else {
11181122
if (fsync(fileno(config->log)) != 0) {

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ foreach(target IN LISTS TARGET_LIST)
9898
endif()
9999

100100
add_executable(${target} ${target_SRCS})
101-
target_link_libraries(${target} ${DLT_LIBRARIES})
101+
target_link_libraries(${target} ${DLT_LIBRARIES} ${ZLIB_LIBRARY})
102102
if(WITH_DLT_INSTALLED_TESTS)
103103
install(TARGETS ${target} RUNTIME DESTINATION ${DLT_TEST_DIR})
104104
if(EXISTS ${PROJECT_SOURCE_DIR}/tests/${target}.sh)

0 commit comments

Comments
 (0)