1 From 84d70e63fc105e3713943ed8c0bdd4e31a698226 Mon Sep 17
2 00:00:00 2001 From: Joachim Nilsson <troglobit@gmail.com> Date: Thu, 16 Jan
3 2020 22:16:51 +0100 Subject: [PATCH] Drop libcompat to simplify build deps
6 The original idea with libcompat was to keep as few objects as
7 possible for linking with libsyslog. That in turn to prevent
8 a user of libsyslog from suddenly also getting strong binding
9 to symbols like strlcpy() from libsyslog, rather than their C
12 However, this caused strlcpy.c to be built as both .o and .lo
13 files, which in turn caused really bizarre build problems due
14 to bad DAG dependency.
16 This patch drops libcompat and instead marks all replacement APIs
17 as weak symbols, which a C library can override.
19 Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
21 Upstream-Status: Backport
22 [https://github.com/troglobit/sysklogd/commit/84d70e63fc105e3713943ed8c0bdd4e31a698226]
24 Signed-off-by: Changqing Li <changqing.li@windriver.com>
26 lib/pidfile.c | 8 +++++++-
27 lib/utimensat.c | 10 ++++++++--
28 src/Makefile.am | 7 +------
29 3 files changed, 16 insertions(+), 9 deletions(-)
31 diff --git a/lib/pidfile.c b/lib/pidfile.c
32 index 81f2315..25b1c04 100644
36 * POSSIBILITY OF SUCH DAMAGE.
42 #define _GNU_SOURCE /* Needed with GLIBC to get asprintf() */
43 #include <sys/stat.h> /* utimensat() */
44 #include <sys/time.h> /* utimensat() on *BSD */
45 @@ -54,7 +57,7 @@ const char *__pidfile_path = RUNSTATEDIR;
46 const char *__pidfile_name = NULL;
49 -pidfile(const char *basename)
50 +__pidfile(const char *basename)
54 @@ -127,6 +130,9 @@ pidfile(const char *basename)
58 +weak_alias(__pidfile, pidfile);
59 +#endif /* HAVE_PIDFILE */
64 diff --git a/lib/utimensat.c b/lib/utimensat.c
65 index edf7e10..b68ce0e 100644
69 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
74 +#ifndef HAVE_UTIMENSAT
80 #include <sys/time.h> /* lutimes(), utimes(), utimensat() */
82 -int utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags)
84 +__utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags)
88 @@ -45,3 +47,7 @@ int utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int
93 +weak_alias(__utimensat, utimensat);
95 +#endif /* HAVE_UTIMENSAT */
96 diff --git a/src/Makefile.am b/src/Makefile.am
97 index 6e2a51c..1db88d3 100644
102 sbin_PROGRAMS = syslogd
103 lib_LTLIBRARIES = libsyslog.la
104 -noinst_LTLIBRARIES = libcompat.la
107 sbin_PROGRAMS += klogd
108 @@ -48,10 +47,6 @@ logger_CPPFLAGS = $(AM_CPPFLAGS) -D_XOPEN_SOURCE=600
109 logger_LDADD = $(LIBS) $(LIBOBJS)
110 logger_LDADD += libsyslog.la
112 -# Convenience library for libsyslog instead of linking with $(LTLIBOBJS),
113 -# which would pull in pidfile() and other (strong) symbols as well.
114 -libcompat_la_SOURCES = ../lib/strlcpy.c ../lib/strlcat.c
116 pkgconfigdir = $(libdir)/pkgconfig
117 pkgincludedir = $(includedir)/syslog
118 pkgconfig_DATA = libsyslog.pc
119 @@ -59,4 +54,4 @@ pkginclude_HEADERS = syslog.h
120 libsyslog_la_SOURCES = syslog.c syslog.h compat.h
121 libsyslog_la_CPPFLAGS = $(AM_CPPFLAGS) -D_XOPEN_SOURCE=600
122 libsyslog_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:0:0
123 -libsyslog_la_LIBADD = libcompat.la
124 +libsyslog_la_LIBADD = $(LTLIBOJBS)