]> code.ossystems Code Review - openembedded-core.git/blob
9ba7ecc2b014b20235ed87a044b6b6faa7a54329
[openembedded-core.git] /
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
4 and really fix
5
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
10 library of choice.
11
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.
15
16 This patch drops libcompat and instead marks all replacement APIs
17 as weak symbols, which a C library can override.
18
19 Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
20
21 Upstream-Status: Backport
22 [https://github.com/troglobit/sysklogd/commit/84d70e63fc105e3713943ed8c0bdd4e31a698226]
23
24 Signed-off-by: Changqing Li <changqing.li@windriver.com>
25 ---
26  lib/pidfile.c   |  8 +++++++-
27  lib/utimensat.c | 10 ++++++++--
28  src/Makefile.am |  7 +------
29  3 files changed, 16 insertions(+), 9 deletions(-)
30
31 diff --git a/lib/pidfile.c b/lib/pidfile.c
32 index 81f2315..25b1c04 100644
33 --- a/lib/pidfile.c
34 +++ b/lib/pidfile.c
35 @@ -31,6 +31,9 @@
36   * POSSIBILITY OF SUCH DAMAGE.
37   */
38  
39 +#include <config.h>
40 +#ifndef HAVE_PIDFILE
41 +
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;
47  
48  int
49 -pidfile(const char *basename)
50 +__pidfile(const char *basename)
51  {
52         int save_errno;
53         int atexit_already;
54 @@ -127,6 +130,9 @@ pidfile(const char *basename)
55         return (0);
56  }
57  
58 +weak_alias(__pidfile, pidfile);
59 +#endif /* HAVE_PIDFILE */
60 +
61  static void
62  pidfile_cleanup(void)
63  {
64 diff --git a/lib/utimensat.c b/lib/utimensat.c
65 index edf7e10..b68ce0e 100644
66 --- a/lib/utimensat.c
67 +++ b/lib/utimensat.c
68 @@ -15,7 +15,8 @@
69   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
70   */
71  
72 -#include "config.h"
73 +#include <config.h>
74 +#ifndef HAVE_UTIMENSAT
75  
76  #include <errno.h>
77  #ifdef HAVE_FCNTL_H
78 @@ -23,7 +24,8 @@
79  #endif
80  #include <sys/time.h>          /* lutimes(), utimes(), utimensat() */
81  
82 -int utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags)
83 +int
84 +__utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int flags)
85  {
86         int ret = -1;
87         struct timeval tv[2];
88 @@ -45,3 +47,7 @@ int utimensat(int dirfd, const char *pathname, const struct timespec ts[2], int
89  
90         return ret;
91  }
92 +
93 +weak_alias(__utimensat, utimensat);
94 +
95 +#endif /* HAVE_UTIMENSAT */
96 diff --git a/src/Makefile.am b/src/Makefile.am
97 index 6e2a51c..1db88d3 100644
98 --- a/src/Makefile.am
99 +++ b/src/Makefile.am
100 @@ -19,7 +19,6 @@
101  bin_PROGRAMS          =
102  sbin_PROGRAMS         = syslogd
103  lib_LTLIBRARIES       = libsyslog.la
104 -noinst_LTLIBRARIES    = libcompat.la
105  
106  if ENABLE_KLOGD
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
111  
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
115 -
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)
125 -- 
126 2.7.4
127