summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/glibc/cross-localedef-native_2.30.bb5
-rw-r--r--meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch (renamed from meta/recipes-core/glibc/glibc/add-cross-localedef-hardlink.patch)915
-rw-r--r--meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch (renamed from meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch)50
-rw-r--r--meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch55
4 files changed, 554 insertions, 471 deletions
diff --git a/meta/recipes-core/glibc/cross-localedef-native_2.30.bb b/meta/recipes-core/glibc/cross-localedef-native_2.30.bb
index 29cd43e89a..99c3d30397 100644
--- a/meta/recipes-core/glibc/cross-localedef-native_2.30.bb
+++ b/meta/recipes-core/glibc/cross-localedef-native_2.30.bb
@@ -30,8 +30,9 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
30 file://0022-eglibc-Forward-port-cross-locale-generation-support.patch \ 30 file://0022-eglibc-Forward-port-cross-locale-generation-support.patch \
31 file://0023-Define-DUMMY_LOCALE_T-if-not-defined.patch \ 31 file://0023-Define-DUMMY_LOCALE_T-if-not-defined.patch \
32 file://0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \ 32 file://0024-localedef-add-to-archive-uses-a-hard-coded-locale-pa.patch \
33 file://add-cross-localedef-hardlink.patch \ 33 file://0029-Add-hardlink-resolver-from-util-linux.patch \
34 file://allow-compile-separate-from-util-linux-hardlink.patch \ 34 file://0030-hardlink-fix-ups-to-make-it-compile.patch \
35 file://0031-Add-hardlink-resolver-to-build.patch \
35" 36"
36# Makes for a rather long rev (22 characters), but... 37# Makes for a rather long rev (22 characters), but...
37# 38#
diff --git a/meta/recipes-core/glibc/glibc/add-cross-localedef-hardlink.patch b/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch
index 8471121949..b7fb0321c4 100644
--- a/meta/recipes-core/glibc/glibc/add-cross-localedef-hardlink.patch
+++ b/meta/recipes-core/glibc/glibc/0029-Add-hardlink-resolver-from-util-linux.patch
@@ -1,10 +1,467 @@
1From 9e5e5297d9a5ef66b3920313356bf7f25955dff3 Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Sat, 7 Dec 2019 09:59:22 -0800
4Subject: [PATCH] Add hardlink resolver from util-linux
5
6The hard link resolver that is built into localedef cannot be run in
7parallel. It will search sibling directories (which are be processed
8in parallel) and perform a creation of a .tmp file and remove the
9original and move the .tmp file in. The problem is that if a probe
10occurs a hard link can be requested to the file that is being removed.
11This will lead to a stray copy or potentially, on a loaded system
12cause race condition which pseudo cannot deal with, where it is left
13with a hard link request to a file that no longer exists. In this
14situation psuedo will inherit the permissions of what ever the target
15inode had to offer.
16
17In short, there are two problems:
18
191) You will be left with stray copies when using the hard link
20resolution that is built in while running in parallel with
21localedef.
22
232) When running under pseudo the possibility exists for uid/gid
24leakage when the source file is removed before the hard link can
25be completed.
26
27The solution is to call localedef with --no-hard-links and separately
28process the hardlinks at a later point. To do this requires the
29inclusion of the hardlink utility found in modern versions of
30util-linux. Most host systems do not have this, so it will be
31included with the cross-localedef binary.
32
33[YOCTO #11299]
34[YOCTO #12434]
35
36Upstream-Status: Pending
37
38Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
39Signed-off-by: Khem Raj <raj.khem@gmail.com>
1--- 40---
2 locale/programs/c.h | 407 ++++++++++++++++++++++ 41 locale/programs/c.h | 407 ++++++++++++++++
3 locale/programs/cross-localedef-hardlink.c | 528 +++++++++++++++++++++++++++++ 42 locale/programs/cross-localedef-hardlink.c | 528 +++++++++++++++++++++
4 locale/programs/xalloc.h | 129 +++++++ 43 locale/programs/xalloc.h | 129 +++++
5 localedef/Makefile.in | 8 44 3 files changed, 1064 insertions(+)
6 4 files changed, 1071 insertions(+), 1 deletion(-) 45 create mode 100644 locale/programs/c.h
46 create mode 100644 locale/programs/cross-localedef-hardlink.c
47 create mode 100644 locale/programs/xalloc.h
7 48
49diff --git a/locale/programs/c.h b/locale/programs/c.h
50new file mode 100644
51index 0000000000..d0a402e90e
52--- /dev/null
53+++ b/locale/programs/c.h
54@@ -0,0 +1,407 @@
55+/*
56+ * Fundamental C definitions.
57+ */
58+
59+#ifndef UTIL_LINUX_C_H
60+#define UTIL_LINUX_C_H
61+
62+#include <limits.h>
63+#include <stddef.h>
64+#include <stdint.h>
65+#include <stdio.h>
66+#include <unistd.h>
67+#include <stdarg.h>
68+#include <stdlib.h>
69+#include <string.h>
70+#include <errno.h>
71+
72+#include <assert.h>
73+
74+#ifdef HAVE_ERR_H
75+# include <err.h>
76+#endif
77+
78+#ifdef HAVE_SYS_SYSMACROS_H
79+# include <sys/sysmacros.h> /* for major, minor */
80+#endif
81+
82+#ifndef LOGIN_NAME_MAX
83+# define LOGIN_NAME_MAX 256
84+#endif
85+
86+#ifndef NAME_MAX
87+# define NAME_MAX PATH_MAX
88+#endif
89+
90+/*
91+ * __GNUC_PREREQ is deprecated in favour of __has_attribute() and
92+ * __has_feature(). The __has macros are supported by clang and gcc>=5.
93+ */
94+#ifndef __GNUC_PREREQ
95+# if defined __GNUC__ && defined __GNUC_MINOR__
96+# define __GNUC_PREREQ(maj, min) \
97+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
98+# else
99+# define __GNUC_PREREQ(maj, min) 0
100+# endif
101+#endif
102+
103+#ifdef __GNUC__
104+
105+/* &a[0] degrades to a pointer: a different type from an array */
106+# define __must_be_array(a) \
107+ UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0])))
108+
109+# define ignore_result(x) __extension__ ({ \
110+ __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \
111+})
112+
113+#else /* !__GNUC__ */
114+# define __must_be_array(a) 0
115+# define __attribute__(_arg_)
116+# define ignore_result(x) ((void) (x))
117+#endif /* !__GNUC__ */
118+
119+/*
120+ * It evaluates to 1 if the attribute/feature is supported by the current
121+ * compilation targed. Fallback for old compilers.
122+ */
123+#ifndef __has_attribute
124+ #define __has_attribute(x) 0
125+#endif
126+
127+#ifndef __has_feature
128+ #define __has_feature(x) 0
129+#endif
130+
131+/*
132+ * Function attributes
133+ */
134+#ifndef __ul_alloc_size
135+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
136+# define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result))
137+# else
138+# define __ul_alloc_size(s)
139+# endif
140+#endif
141+
142+#ifndef __ul_calloc_size
143+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
144+# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result))
145+# else
146+# define __ul_calloc_size(n, s)
147+# endif
148+#endif
149+
150+#if __has_attribute(returns_nonnull) || __GNUC_PREREQ (4, 9)
151+# define __ul_returns_nonnull __attribute__((returns_nonnull))
152+#else
153+# define __ul_returns_nonnull
154+#endif
155+
156+/*
157+ * Force a compilation error if condition is true, but also produce a
158+ * result (of value 0 and type size_t), so the expression can be used
159+ * e.g. in a structure initializer (or wherever else comma expressions
160+ * aren't permitted).
161+ */
162+#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); }))
163+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
164+
165+#ifndef ARRAY_SIZE
166+# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
167+#endif
168+
169+#ifndef PATH_MAX
170+# define PATH_MAX 4096
171+#endif
172+
173+#ifndef TRUE
174+# define TRUE 1
175+#endif
176+
177+#ifndef FALSE
178+# define FALSE 0
179+#endif
180+
181+#ifndef min
182+# define min(x, y) __extension__ ({ \
183+ __typeof__(x) _min1 = (x); \
184+ __typeof__(y) _min2 = (y); \
185+ (void) (&_min1 == &_min2); \
186+ _min1 < _min2 ? _min1 : _min2; })
187+#endif
188+
189+#ifndef max
190+# define max(x, y) __extension__ ({ \
191+ __typeof__(x) _max1 = (x); \
192+ __typeof__(y) _max2 = (y); \
193+ (void) (&_max1 == &_max2); \
194+ _max1 > _max2 ? _max1 : _max2; })
195+#endif
196+
197+#ifndef cmp_numbers
198+# define cmp_numbers(x, y) __extension__ ({ \
199+ __typeof__(x) _a = (x); \
200+ __typeof__(y) _b = (y); \
201+ (void) (&_a == &_b); \
202+ _a == _b ? 0 : _a > _b ? 1 : -1; })
203+#endif
204+
205+#ifndef offsetof
206+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
207+#endif
208+
209+/*
210+ * container_of - cast a member of a structure out to the containing structure
211+ * @ptr: the pointer to the member.
212+ * @type: the type of the container struct this is embedded in.
213+ * @member: the name of the member within the struct.
214+ */
215+#ifndef container_of
216+#define container_of(ptr, type, member) __extension__ ({ \
217+ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
218+ (type *)( (char *)__mptr - offsetof(type,member) );})
219+#endif
220+
221+#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
222+# ifdef HAVE___PROGNAME
223+extern char *__progname;
224+# define program_invocation_short_name __progname
225+# else
226+# ifdef HAVE_GETEXECNAME
227+# define program_invocation_short_name \
228+ prog_inv_sh_nm_from_file(getexecname(), 0)
229+# else
230+# define program_invocation_short_name \
231+ prog_inv_sh_nm_from_file(__FILE__, 1)
232+# endif
233+static char prog_inv_sh_nm_buf[256];
234+static inline char *
235+prog_inv_sh_nm_from_file(char *f, char stripext)
236+{
237+ char *t;
238+
239+ if ((t = strrchr(f, '/')) != NULL)
240+ t++;
241+ else
242+ t = f;
243+
244+ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
245+ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
246+
247+ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
248+ *t = '\0';
249+
250+ return prog_inv_sh_nm_buf;
251+}
252+# endif
253+#endif
254+
255+
256+#ifndef HAVE_ERR_H
257+static inline void
258+errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
259+{
260+ fprintf(stderr, "%s: ", program_invocation_short_name);
261+ if (fmt != NULL) {
262+ va_list argp;
263+ va_start(argp, fmt);
264+ vfprintf(stderr, fmt, argp);
265+ va_end(argp);
266+ if (adderr)
267+ fprintf(stderr, ": ");
268+ }
269+ if (adderr)
270+ fprintf(stderr, "%m");
271+ fprintf(stderr, "\n");
272+ if (doexit)
273+ exit(excode);
274+}
275+
276+#ifndef HAVE_ERR
277+# define err(E, FMT...) errmsg(1, E, 1, FMT)
278+#endif
279+
280+#ifndef HAVE_ERRX
281+# define errx(E, FMT...) errmsg(1, E, 0, FMT)
282+#endif
283+
284+#ifndef HAVE_WARN
285+# define warn(FMT...) errmsg(0, 0, 1, FMT)
286+#endif
287+
288+#ifndef HAVE_WARNX
289+# define warnx(FMT...) errmsg(0, 0, 0, FMT)
290+#endif
291+#endif /* !HAVE_ERR_H */
292+
293+
294+/* Don't use inline function to avoid '#include "nls.h"' in c.h
295+ */
296+#define errtryhelp(eval) __extension__ ({ \
297+ fprintf(stderr, _("Try '%s --help' for more information.\n"), \
298+ program_invocation_short_name); \
299+ exit(eval); \
300+})
301+
302+/* After failed execvp() */
303+#define EX_EXEC_FAILED 126 /* Program located, but not usable. */
304+#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */
305+#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \
306+ _("failed to execute %s"), name)
307+
308+
309+static inline __attribute__((const)) int is_power_of_2(unsigned long num)
310+{
311+ return (num != 0 && ((num & (num - 1)) == 0));
312+}
313+
314+#ifndef HAVE_LOFF_T
315+typedef int64_t loff_t;
316+#endif
317+
318+#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD)
319+#include <sys/types.h>
320+#include <dirent.h>
321+static inline int dirfd(DIR *d)
322+{
323+ return d->dd_fd;
324+}
325+#endif
326+
327+/*
328+ * Fallback defines for old versions of glibc
329+ */
330+#include <fcntl.h>
331+
332+#ifdef O_CLOEXEC
333+#define UL_CLOEXECSTR "e"
334+#else
335+#define UL_CLOEXECSTR ""
336+#endif
337+
338+#ifndef O_CLOEXEC
339+#define O_CLOEXEC 0
340+#endif
341+
342+#ifdef __FreeBSD_kernel__
343+#ifndef F_DUPFD_CLOEXEC
344+#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
345+#endif
346+#endif
347+
348+
349+#ifndef AI_ADDRCONFIG
350+#define AI_ADDRCONFIG 0x0020
351+#endif
352+
353+#ifndef IUTF8
354+#define IUTF8 0040000
355+#endif
356+
357+/*
358+ * MAXHOSTNAMELEN replacement
359+ */
360+static inline size_t get_hostname_max(void)
361+{
362+ long len = sysconf(_SC_HOST_NAME_MAX);
363+
364+ if (0 < len)
365+ return len;
366+
367+#ifdef MAXHOSTNAMELEN
368+ return MAXHOSTNAMELEN;
369+#elif HOST_NAME_MAX
370+ return HOST_NAME_MAX;
371+#endif
372+ return 64;
373+}
374+
375+
376+/*
377+ * Constant strings for usage() functions. For more info see
378+ * Documentation/{howto-usage-function.txt,boilerplate.c}
379+ */
380+#define USAGE_HEADER ("\nUsage:\n")
381+#define USAGE_OPTIONS ("\nOptions:\n")
382+#define USAGE_FUNCTIONS ("\nFunctions:\n")
383+#define USAGE_COMMANDS ("\nCommands:\n")
384+#define USAGE_COLUMNS ("\nAvailable output columns:\n")
385+#define USAGE_SEPARATOR "\n"
386+
387+#define USAGE_OPTSTR_HELP ("display this help")
388+#define USAGE_OPTSTR_VERSION ("display version")
389+
390+#define USAGE_HELP_OPTIONS(marg_dsc) \
391+ "%-" #marg_dsc "s%s\n" \
392+ "%-" #marg_dsc "s%s\n" \
393+ , " -h, --help", USAGE_OPTSTR_HELP \
394+ , " -V, --version", USAGE_OPTSTR_VERSION
395+
396+#define USAGE_MAN_TAIL(_man) ("\nFor more details see %s.\n"), _man
397+
398+#define UTIL_LINUX_VERSION ("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING
399+
400+#define print_version(eval) __extension__ ({ \
401+ printf(UTIL_LINUX_VERSION); \
402+ exit(eval); \
403+})
404+
405+/*
406+ * scanf modifiers for "strings allocation"
407+ */
408+#ifdef HAVE_SCANF_MS_MODIFIER
409+#define UL_SCNsA "%ms"
410+#elif defined(HAVE_SCANF_AS_MODIFIER)
411+#define UL_SCNsA "%as"
412+#endif
413+
414+/*
415+ * seek stuff
416+ */
417+#ifndef SEEK_DATA
418+# define SEEK_DATA 3
419+#endif
420+#ifndef SEEK_HOLE
421+# define SEEK_HOLE 4
422+#endif
423+
424+
425+/*
426+ * Macros to convert #define'itions to strings, for example
427+ * #define XYXXY 42
428+ * printf ("%s=%s\n", stringify(XYXXY), stringify_value(XYXXY));
429+ */
430+#define stringify_value(s) stringify(s)
431+#define stringify(s) #s
432+
433+/*
434+ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
435+ * instrumentation shipped with Clang and GCC) to not instrument the
436+ * annotated function. Furthermore, it will prevent the compiler from
437+ * inlining the function because inlining currently breaks the blacklisting
438+ * mechanism of AddressSanitizer.
439+ */
440+#if __has_feature(address_sanitizer) && __has_attribute(no_sanitize_memory) && __has_attribute(no_sanitize_address)
441+# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address))
442+#else
443+# define UL_ASAN_BLACKLIST /* nothing */
444+#endif
445+
446+/*
447+ * Note that sysconf(_SC_GETPW_R_SIZE_MAX) returns *initial* suggested size for
448+ * pwd buffer and in some cases it is not large enough. See POSIX and
449+ * getpwnam_r man page for more details.
450+ */
451+#define UL_GETPW_BUFSIZ (16 * 1024)
452+
453+/*
454+ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must
455+ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h.
456+ */
457+#if !defined MAP_ANONYMOUS && defined MAP_ANON
458+# define MAP_ANONYMOUS (MAP_ANON)
459+#endif
460+
461+#endif /* UTIL_LINUX_C_H */
462diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c
463new file mode 100644
464index 0000000000..63615896b0
8--- /dev/null 465--- /dev/null
9+++ b/locale/programs/cross-localedef-hardlink.c 466+++ b/locale/programs/cross-localedef-hardlink.c
10@@ -0,0 +1,528 @@ 467@@ -0,0 +1,528 @@
@@ -536,451 +993,9 @@
536+ 993+
537+ return 0; 994+ return 0;
538+} 995+}
539--- a/localedef/Makefile.in 996diff --git a/locale/programs/xalloc.h b/locale/programs/xalloc.h
540+++ b/localedef/Makefile.in 997new file mode 100644
541@@ -40,6 +40,8 @@ WARNFLAGS = -Wall -Wno-format 998index 0000000000..0129a85e2e
542 FULLCC = $(CC) $(CPPFLAGS) $(CFLAGS) \
543 $(DEFINES) $(INCLUDES) $(WARNFLAGS)
544
545+CROSS_LOCALEDEF_HARDLINK_OBJS = cross-localedef-hardlink.o
546+
547 LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \
548 ld-ctype.o ld-identification.o ld-measurement.o \
549 ld-messages.o ld-monetary.o ld-name.o ld-numeric.o \
550@@ -54,11 +56,14 @@ LOCALEDEF_OBJS = charmap.o charmap-dir.o
551 asprintf.o getdelim.o localedef_extra.o \
552 obstack_printf.o vasprintf.o
553
554-all: localedef$(EXEEXT)
555+all: localedef$(EXEEXT) cross-localedef-hardlink$(EXEEXT)
556
557 localedef$(EXEEXT): $(LOCALEDEF_OBJS)
558 $(CC) -o $@ $(LOCALEDEF_OBJS) $(LIBS)
559
560+cross-localedef-hardlink$(EXEEXT): $(CROSS_LOCALEDEF_HARDLINK_OBJS)
561+ $(CC) -o $@ $(CROSS_LOCALEDEF_HARDLINK_OBJS) $(LIBS)
562+
563 clean:
564 rm -f locale$(EXEEXT) $(LOCALEDEF_OBJS)
565
566@@ -77,6 +82,7 @@ clean:
567 %.o: $(srcdir)/%.c
568 $(FULLCC) -c -o $@ $<
569
570+cross-localedef-hardlink.o: glibc/locale/programs/cross-localedef-hardlink.c
571 charmap.o: glibc/locale/programs/charmap.c
572 charmap-dir.o: glibc/locale/programs/charmap-dir.c
573 ld-address.o: glibc/locale/programs/ld-address.c
574--- /dev/null
575+++ b/locale/programs/c.h
576@@ -0,0 +1,407 @@
577+/*
578+ * Fundamental C definitions.
579+ */
580+
581+#ifndef UTIL_LINUX_C_H
582+#define UTIL_LINUX_C_H
583+
584+#include <limits.h>
585+#include <stddef.h>
586+#include <stdint.h>
587+#include <stdio.h>
588+#include <unistd.h>
589+#include <stdarg.h>
590+#include <stdlib.h>
591+#include <string.h>
592+#include <errno.h>
593+
594+#include <assert.h>
595+
596+#ifdef HAVE_ERR_H
597+# include <err.h>
598+#endif
599+
600+#ifdef HAVE_SYS_SYSMACROS_H
601+# include <sys/sysmacros.h> /* for major, minor */
602+#endif
603+
604+#ifndef LOGIN_NAME_MAX
605+# define LOGIN_NAME_MAX 256
606+#endif
607+
608+#ifndef NAME_MAX
609+# define NAME_MAX PATH_MAX
610+#endif
611+
612+/*
613+ * __GNUC_PREREQ is deprecated in favour of __has_attribute() and
614+ * __has_feature(). The __has macros are supported by clang and gcc>=5.
615+ */
616+#ifndef __GNUC_PREREQ
617+# if defined __GNUC__ && defined __GNUC_MINOR__
618+# define __GNUC_PREREQ(maj, min) \
619+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
620+# else
621+# define __GNUC_PREREQ(maj, min) 0
622+# endif
623+#endif
624+
625+#ifdef __GNUC__
626+
627+/* &a[0] degrades to a pointer: a different type from an array */
628+# define __must_be_array(a) \
629+ UL_BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0])))
630+
631+# define ignore_result(x) __extension__ ({ \
632+ __typeof__(x) __dummy __attribute__((__unused__)) = (x); (void) __dummy; \
633+})
634+
635+#else /* !__GNUC__ */
636+# define __must_be_array(a) 0
637+# define __attribute__(_arg_)
638+# define ignore_result(x) ((void) (x))
639+#endif /* !__GNUC__ */
640+
641+/*
642+ * It evaluates to 1 if the attribute/feature is supported by the current
643+ * compilation targed. Fallback for old compilers.
644+ */
645+#ifndef __has_attribute
646+ #define __has_attribute(x) 0
647+#endif
648+
649+#ifndef __has_feature
650+ #define __has_feature(x) 0
651+#endif
652+
653+/*
654+ * Function attributes
655+ */
656+#ifndef __ul_alloc_size
657+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
658+# define __ul_alloc_size(s) __attribute__((alloc_size(s), warn_unused_result))
659+# else
660+# define __ul_alloc_size(s)
661+# endif
662+#endif
663+
664+#ifndef __ul_calloc_size
665+# if (__has_attribute(alloc_size) && __has_attribute(warn_unused_result)) || __GNUC_PREREQ (4, 3)
666+# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s), warn_unused_result))
667+# else
668+# define __ul_calloc_size(n, s)
669+# endif
670+#endif
671+
672+#if __has_attribute(returns_nonnull) || __GNUC_PREREQ (4, 9)
673+# define __ul_returns_nonnull __attribute__((returns_nonnull))
674+#else
675+# define __ul_returns_nonnull
676+#endif
677+
678+/*
679+ * Force a compilation error if condition is true, but also produce a
680+ * result (of value 0 and type size_t), so the expression can be used
681+ * e.g. in a structure initializer (or wherever else comma expressions
682+ * aren't permitted).
683+ */
684+#define UL_BUILD_BUG_ON_ZERO(e) __extension__ (sizeof(struct { int:-!!(e); }))
685+#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
686+
687+#ifndef ARRAY_SIZE
688+# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
689+#endif
690+
691+#ifndef PATH_MAX
692+# define PATH_MAX 4096
693+#endif
694+
695+#ifndef TRUE
696+# define TRUE 1
697+#endif
698+
699+#ifndef FALSE
700+# define FALSE 0
701+#endif
702+
703+#ifndef min
704+# define min(x, y) __extension__ ({ \
705+ __typeof__(x) _min1 = (x); \
706+ __typeof__(y) _min2 = (y); \
707+ (void) (&_min1 == &_min2); \
708+ _min1 < _min2 ? _min1 : _min2; })
709+#endif
710+
711+#ifndef max
712+# define max(x, y) __extension__ ({ \
713+ __typeof__(x) _max1 = (x); \
714+ __typeof__(y) _max2 = (y); \
715+ (void) (&_max1 == &_max2); \
716+ _max1 > _max2 ? _max1 : _max2; })
717+#endif
718+
719+#ifndef cmp_numbers
720+# define cmp_numbers(x, y) __extension__ ({ \
721+ __typeof__(x) _a = (x); \
722+ __typeof__(y) _b = (y); \
723+ (void) (&_a == &_b); \
724+ _a == _b ? 0 : _a > _b ? 1 : -1; })
725+#endif
726+
727+#ifndef offsetof
728+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
729+#endif
730+
731+/*
732+ * container_of - cast a member of a structure out to the containing structure
733+ * @ptr: the pointer to the member.
734+ * @type: the type of the container struct this is embedded in.
735+ * @member: the name of the member within the struct.
736+ */
737+#ifndef container_of
738+#define container_of(ptr, type, member) __extension__ ({ \
739+ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
740+ (type *)( (char *)__mptr - offsetof(type,member) );})
741+#endif
742+
743+#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
744+# ifdef HAVE___PROGNAME
745+extern char *__progname;
746+# define program_invocation_short_name __progname
747+# else
748+# ifdef HAVE_GETEXECNAME
749+# define program_invocation_short_name \
750+ prog_inv_sh_nm_from_file(getexecname(), 0)
751+# else
752+# define program_invocation_short_name \
753+ prog_inv_sh_nm_from_file(__FILE__, 1)
754+# endif
755+static char prog_inv_sh_nm_buf[256];
756+static inline char *
757+prog_inv_sh_nm_from_file(char *f, char stripext)
758+{
759+ char *t;
760+
761+ if ((t = strrchr(f, '/')) != NULL)
762+ t++;
763+ else
764+ t = f;
765+
766+ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
767+ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
768+
769+ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
770+ *t = '\0';
771+
772+ return prog_inv_sh_nm_buf;
773+}
774+# endif
775+#endif
776+
777+
778+#ifndef HAVE_ERR_H
779+static inline void
780+errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
781+{
782+ fprintf(stderr, "%s: ", program_invocation_short_name);
783+ if (fmt != NULL) {
784+ va_list argp;
785+ va_start(argp, fmt);
786+ vfprintf(stderr, fmt, argp);
787+ va_end(argp);
788+ if (adderr)
789+ fprintf(stderr, ": ");
790+ }
791+ if (adderr)
792+ fprintf(stderr, "%m");
793+ fprintf(stderr, "\n");
794+ if (doexit)
795+ exit(excode);
796+}
797+
798+#ifndef HAVE_ERR
799+# define err(E, FMT...) errmsg(1, E, 1, FMT)
800+#endif
801+
802+#ifndef HAVE_ERRX
803+# define errx(E, FMT...) errmsg(1, E, 0, FMT)
804+#endif
805+
806+#ifndef HAVE_WARN
807+# define warn(FMT...) errmsg(0, 0, 1, FMT)
808+#endif
809+
810+#ifndef HAVE_WARNX
811+# define warnx(FMT...) errmsg(0, 0, 0, FMT)
812+#endif
813+#endif /* !HAVE_ERR_H */
814+
815+
816+/* Don't use inline function to avoid '#include "nls.h"' in c.h
817+ */
818+#define errtryhelp(eval) __extension__ ({ \
819+ fprintf(stderr, _("Try '%s --help' for more information.\n"), \
820+ program_invocation_short_name); \
821+ exit(eval); \
822+})
823+
824+/* After failed execvp() */
825+#define EX_EXEC_FAILED 126 /* Program located, but not usable. */
826+#define EX_EXEC_ENOENT 127 /* Could not find program to exec. */
827+#define errexec(name) err(errno == ENOENT ? EX_EXEC_ENOENT : EX_EXEC_FAILED, \
828+ _("failed to execute %s"), name)
829+
830+
831+static inline __attribute__((const)) int is_power_of_2(unsigned long num)
832+{
833+ return (num != 0 && ((num & (num - 1)) == 0));
834+}
835+
836+#ifndef HAVE_LOFF_T
837+typedef int64_t loff_t;
838+#endif
839+
840+#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD)
841+#include <sys/types.h>
842+#include <dirent.h>
843+static inline int dirfd(DIR *d)
844+{
845+ return d->dd_fd;
846+}
847+#endif
848+
849+/*
850+ * Fallback defines for old versions of glibc
851+ */
852+#include <fcntl.h>
853+
854+#ifdef O_CLOEXEC
855+#define UL_CLOEXECSTR "e"
856+#else
857+#define UL_CLOEXECSTR ""
858+#endif
859+
860+#ifndef O_CLOEXEC
861+#define O_CLOEXEC 0
862+#endif
863+
864+#ifdef __FreeBSD_kernel__
865+#ifndef F_DUPFD_CLOEXEC
866+#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
867+#endif
868+#endif
869+
870+
871+#ifndef AI_ADDRCONFIG
872+#define AI_ADDRCONFIG 0x0020
873+#endif
874+
875+#ifndef IUTF8
876+#define IUTF8 0040000
877+#endif
878+
879+/*
880+ * MAXHOSTNAMELEN replacement
881+ */
882+static inline size_t get_hostname_max(void)
883+{
884+ long len = sysconf(_SC_HOST_NAME_MAX);
885+
886+ if (0 < len)
887+ return len;
888+
889+#ifdef MAXHOSTNAMELEN
890+ return MAXHOSTNAMELEN;
891+#elif HOST_NAME_MAX
892+ return HOST_NAME_MAX;
893+#endif
894+ return 64;
895+}
896+
897+
898+/*
899+ * Constant strings for usage() functions. For more info see
900+ * Documentation/{howto-usage-function.txt,boilerplate.c}
901+ */
902+#define USAGE_HEADER ("\nUsage:\n")
903+#define USAGE_OPTIONS ("\nOptions:\n")
904+#define USAGE_FUNCTIONS ("\nFunctions:\n")
905+#define USAGE_COMMANDS ("\nCommands:\n")
906+#define USAGE_COLUMNS ("\nAvailable output columns:\n")
907+#define USAGE_SEPARATOR "\n"
908+
909+#define USAGE_OPTSTR_HELP ("display this help")
910+#define USAGE_OPTSTR_VERSION ("display version")
911+
912+#define USAGE_HELP_OPTIONS(marg_dsc) \
913+ "%-" #marg_dsc "s%s\n" \
914+ "%-" #marg_dsc "s%s\n" \
915+ , " -h, --help", USAGE_OPTSTR_HELP \
916+ , " -V, --version", USAGE_OPTSTR_VERSION
917+
918+#define USAGE_MAN_TAIL(_man) ("\nFor more details see %s.\n"), _man
919+
920+#define UTIL_LINUX_VERSION ("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING
921+
922+#define print_version(eval) __extension__ ({ \
923+ printf(UTIL_LINUX_VERSION); \
924+ exit(eval); \
925+})
926+
927+/*
928+ * scanf modifiers for "strings allocation"
929+ */
930+#ifdef HAVE_SCANF_MS_MODIFIER
931+#define UL_SCNsA "%ms"
932+#elif defined(HAVE_SCANF_AS_MODIFIER)
933+#define UL_SCNsA "%as"
934+#endif
935+
936+/*
937+ * seek stuff
938+ */
939+#ifndef SEEK_DATA
940+# define SEEK_DATA 3
941+#endif
942+#ifndef SEEK_HOLE
943+# define SEEK_HOLE 4
944+#endif
945+
946+
947+/*
948+ * Macros to convert #define'itions to strings, for example
949+ * #define XYXXY 42
950+ * printf ("%s=%s\n", stringify(XYXXY), stringify_value(XYXXY));
951+ */
952+#define stringify_value(s) stringify(s)
953+#define stringify(s) #s
954+
955+/*
956+ * UL_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time
957+ * instrumentation shipped with Clang and GCC) to not instrument the
958+ * annotated function. Furthermore, it will prevent the compiler from
959+ * inlining the function because inlining currently breaks the blacklisting
960+ * mechanism of AddressSanitizer.
961+ */
962+#if __has_feature(address_sanitizer) && __has_attribute(no_sanitize_memory) && __has_attribute(no_sanitize_address)
963+# define UL_ASAN_BLACKLIST __attribute__((noinline)) __attribute__((no_sanitize_memory)) __attribute__((no_sanitize_address))
964+#else
965+# define UL_ASAN_BLACKLIST /* nothing */
966+#endif
967+
968+/*
969+ * Note that sysconf(_SC_GETPW_R_SIZE_MAX) returns *initial* suggested size for
970+ * pwd buffer and in some cases it is not large enough. See POSIX and
971+ * getpwnam_r man page for more details.
972+ */
973+#define UL_GETPW_BUFSIZ (16 * 1024)
974+
975+/*
976+ * Darwin or other BSDs may only have MAP_ANON. To get it on Darwin we must
977+ * define _DARWIN_C_SOURCE before including sys/mman.h. We do this in config.h.
978+ */
979+#if !defined MAP_ANONYMOUS && defined MAP_ANON
980+# define MAP_ANONYMOUS (MAP_ANON)
981+#endif
982+
983+#endif /* UTIL_LINUX_C_H */
984--- /dev/null 999--- /dev/null
985+++ b/locale/programs/xalloc.h 1000+++ b/locale/programs/xalloc.h
986@@ -0,0 +1,129 @@ 1001@@ -0,0 +1,129 @@
diff --git a/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch b/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch
index 1148ebfcc7..1a5f6b6825 100644
--- a/meta/recipes-core/glibc/glibc/allow-compile-separate-from-util-linux-hardlink.patch
+++ b/meta/recipes-core/glibc/glibc/0030-hardlink-fix-ups-to-make-it-compile.patch
@@ -1,8 +1,31 @@
1From d08f436635cb9d627ebae4512105708d28fc36fe Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Sat, 7 Dec 2019 10:01:37 -0800
4Subject: [PATCH] hardlink: fix-ups to make it compile
5
6Upstream-Status: Pending
7Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
1--- 9---
2 locale/programs/c.h | 2 10 locale/programs/c.h | 2 +-
3 locale/programs/cross-localedef-hardlink.c | 79 +++++++++++++---------------- 11 locale/programs/cross-localedef-hardlink.c | 79 +++++++++++-----------
4 2 files changed, 39 insertions(+), 42 deletions(-) 12 2 files changed, 39 insertions(+), 42 deletions(-)
5 13
14diff --git a/locale/programs/c.h b/locale/programs/c.h
15index d0a402e90e..1804d31c73 100644
16--- a/locale/programs/c.h
17+++ b/locale/programs/c.h
18@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char adderr, const char *fmt, ...)
19 /* Don't use inline function to avoid '#include "nls.h"' in c.h
20 */
21 #define errtryhelp(eval) __extension__ ({ \
22- fprintf(stderr, _("Try '%s --help' for more information.\n"), \
23+ fprintf(stderr, ("Try '%s --help' for more information.\n"), \
24 program_invocation_short_name); \
25 exit(eval); \
26 })
27diff --git a/locale/programs/cross-localedef-hardlink.c b/locale/programs/cross-localedef-hardlink.c
28index 63615896b0..726e6dd948 100644
6--- a/locale/programs/cross-localedef-hardlink.c 29--- a/locale/programs/cross-localedef-hardlink.c
7+++ b/locale/programs/cross-localedef-hardlink.c 30+++ b/locale/programs/cross-localedef-hardlink.c
8@@ -20,6 +20,8 @@ 31@@ -20,6 +20,8 @@
@@ -75,7 +98,7 @@
75 98
76 fputs(USAGE_SEPARATOR, stdout); 99 fputs(USAGE_SEPARATOR, stdout);
77 printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */ 100 printf(USAGE_HELP_OPTIONS(16)); /* char offset to align option descriptions */
78@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size 101@@ -164,7 +166,7 @@ static inline size_t add2(size_t a, size_t b)
79 size_t sum = a + b; 102 size_t sum = a + b;
80 103
81 if (sum < a) 104 if (sum < a)
@@ -84,7 +107,7 @@
84 return sum; 107 return sum;
85 } 108 }
86 109
87@@ -193,7 +195,7 @@ static void process_path(struct hardlink 110@@ -193,7 +195,7 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
88 if (st.st_dev != ctl->dev && !ctl->force) { 111 if (st.st_dev != ctl->dev && !ctl->force) {
89 if (ctl->dev) 112 if (ctl->dev)
90 errx(EXIT_FAILURE, 113 errx(EXIT_FAILURE,
@@ -93,7 +116,7 @@
93 "(use -f option to override)."), name); 116 "(use -f option to override)."), name);
94 ctl->dev = st.st_dev; 117 ctl->dev = st.st_dev;
95 } 118 }
96@@ -287,9 +289,9 @@ static void process_path(struct hardlink 119@@ -287,9 +289,9 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
97 (ssize_t) sizeof(ctl->iobuf1) : fsize; 120 (ssize_t) sizeof(ctl->iobuf1) : fsize;
98 121
99 if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) 122 if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize)
@@ -105,7 +128,7 @@
105 128
106 if (xsz != rsize) { 129 if (xsz != rsize) {
107 close(fd); 130 close(fd);
108@@ -303,13 +305,13 @@ static void process_path(struct hardlink 131@@ -303,13 +305,13 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
109 if (fsize > 0) 132 if (fsize > 0)
110 continue; 133 continue;
111 if (lstat(name, &st3)) { 134 if (lstat(name, &st3)) {
@@ -121,7 +144,7 @@
121 close(fd); 144 close(fd);
122 return; 145 return;
123 } 146 }
124@@ -329,18 +331,18 @@ static void process_path(struct hardlink 147@@ -329,18 +331,18 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
125 suffixlen + 1); 148 suffixlen + 1);
126 /* First create a temporary link to n1 under a new name */ 149 /* First create a temporary link to n1 under a new name */
127 if (link(n1, nam2.buf)) { 150 if (link(n1, nam2.buf)) {
@@ -143,7 +166,7 @@
143 free(nam2.buf); 166 free(nam2.buf);
144 continue; 167 continue;
145 } 168 }
146@@ -351,16 +353,16 @@ static void process_path(struct hardlink 169@@ -351,16 +353,16 @@ static void process_path(struct hardlink_ctl *ctl, const char *name)
147 /* We actually did not save anything this time, since the link second argument 170 /* We actually did not save anything this time, since the link second argument
148 had some other links as well. */ 171 had some other links as well. */
149 if (ctl->verbose > 1) 172 if (ctl->verbose > 1)
@@ -213,14 +236,3 @@
213 } 236 }
214 continue; 237 continue;
215 } 238 }
216--- a/locale/programs/c.h
217+++ b/locale/programs/c.h
218@@ -240,7 +240,7 @@ errmsg(char doexit, int excode, char add
219 /* Don't use inline function to avoid '#include "nls.h"' in c.h
220 */
221 #define errtryhelp(eval) __extension__ ({ \
222- fprintf(stderr, _("Try '%s --help' for more information.\n"), \
223+ fprintf(stderr, ("Try '%s --help' for more information.\n"), \
224 program_invocation_short_name); \
225 exit(eval); \
226 })
diff --git a/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch b/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch
new file mode 100644
index 0000000000..e87a3bfb6f
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc/0031-Add-hardlink-resolver-to-build.patch
@@ -0,0 +1,55 @@
1From 1ef58f566e6ed575f7caee35308025e2b0f4101c Mon Sep 17 00:00:00 2001
2From: Jason Wessel <jason.wessel@windriver.com>
3Date: Sat, 7 Dec 2019 09:56:23 -0800
4Subject: [PATCH] Add hardlink resolver to build
5
6The sourcecode for this is imported from util-linux and is kept with
7glibc sources
8
9Upstream-Status: Pending
10Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 Makefile.in | 8 +++++++-
14 1 file changed, 7 insertions(+), 1 deletion(-)
15
16diff --git a/localedef/Makefile.in b/localedef/Makefile.in
17index 77fbded..a87e5b2 100644
18--- a/localedef/Makefile.in
19+++ b/localedef/Makefile.in
20@@ -40,6 +40,8 @@ WARNFLAGS = -Wall -Wno-format
21 FULLCC = $(CC) $(CPPFLAGS) $(CFLAGS) \
22 $(DEFINES) $(INCLUDES) $(WARNFLAGS)
23
24+CROSS_LOCALEDEF_HARDLINK_OBJS = cross-localedef-hardlink.o
25+
26 LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \
27 ld-ctype.o ld-identification.o ld-measurement.o \
28 ld-messages.o ld-monetary.o ld-name.o ld-numeric.o \
29@@ -54,11 +56,14 @@ LOCALEDEF_OBJS = charmap.o charmap-dir.o ld-address.o ld-collate.o \
30 asprintf.o getdelim.o localedef_extra.o \
31 obstack_printf.o vasprintf.o
32
33-all: localedef$(EXEEXT)
34+all: localedef$(EXEEXT) cross-localedef-hardlink$(EXEEXT)
35
36 localedef$(EXEEXT): $(LOCALEDEF_OBJS)
37 $(CC) -o $@ $(LOCALEDEF_OBJS) $(LIBS)
38
39+cross-localedef-hardlink$(EXEEXT): $(CROSS_LOCALEDEF_HARDLINK_OBJS)
40+ $(CC) -o $@ $(CROSS_LOCALEDEF_HARDLINK_OBJS) $(LIBS)
41+
42 clean:
43 rm -f locale$(EXEEXT) $(LOCALEDEF_OBJS)
44
45@@ -77,6 +82,7 @@ clean:
46 %.o: $(srcdir)/%.c
47 $(FULLCC) -c -o $@ $<
48
49+cross-localedef-hardlink.o: glibc/locale/programs/cross-localedef-hardlink.c
50 charmap.o: glibc/locale/programs/charmap.c
51 charmap-dir.o: glibc/locale/programs/charmap-dir.c
52 ld-address.o: glibc/locale/programs/ld-address.c
53--
542.24.0
55