1 |
commit: dbabd1516a53fa57ae0204216ae78741bd4928c9 |
2 |
Author: brahmajit das <listout <AT> protonmail <DOT> com> |
3 |
AuthorDate: Sat Jul 23 18:47:48 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Sep 1 02:04:23 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dbabd151 |
7 |
|
8 |
sys-libs/libhugetlbfs: fix musl build errors |
9 |
|
10 |
Fix _SC_LEVEL2_CACHE_LINESIZE undeclared and misc issues. |
11 |
|
12 |
Patches for musl that mainly closes bug 828830, plus some other patches |
13 |
for errors that come along 828830. |
14 |
|
15 |
Closes: https://bugs.gentoo.org/828830 |
16 |
Closes: https://bugs.gentoo.org/832980 |
17 |
Signed-off-by: brahmajit das <listout <AT> protonmail.com> |
18 |
Closes: https://github.com/gentoo/gentoo/pull/26539 |
19 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
20 |
|
21 |
.../files/libhugetlbfs-2.23-musl-ino_t-fix.patch | 13 +++++++ |
22 |
.../files/libhugetlbfs-2.23-musl-nonnull-fix.patch | 31 +++++++++++++++ |
23 |
.../libhugetlbfs-2.23-musl-path-max-fix.patch | 22 +++++++++++ |
24 |
.../libhugetlbfs-2.23-musl-sc-level2-fix.patch | 45 ++++++++++++++++++++++ |
25 |
sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild | 4 ++ |
26 |
5 files changed, 115 insertions(+) |
27 |
|
28 |
diff --git a/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-ino_t-fix.patch b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-ino_t-fix.patch |
29 |
new file mode 100644 |
30 |
index 000000000000..f408f9fd6ac0 |
31 |
--- /dev/null |
32 |
+++ b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-ino_t-fix.patch |
33 |
@@ -0,0 +1,13 @@ |
34 |
+# Include dirent.h for ino_t |
35 |
+# Fixes error: unknown typename 'ino_t' |
36 |
+# Closes: https://bugs.gentoo.org/828830 |
37 |
+--- a/tests/hugetests.h |
38 |
++++ b/tests/hugetests.h |
39 |
+@@ -22,6 +22,7 @@ |
40 |
+ |
41 |
+ #include <errno.h> |
42 |
+ #include <string.h> |
43 |
++#include <dirent.h> |
44 |
+ #include <unistd.h> |
45 |
+ |
46 |
+ #include "libhugetlbfs_privutils.h" |
47 |
|
48 |
diff --git a/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-nonnull-fix.patch b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-nonnull-fix.patch |
49 |
new file mode 100644 |
50 |
index 000000000000..5e3532e50877 |
51 |
--- /dev/null |
52 |
+++ b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-nonnull-fix.patch |
53 |
@@ -0,0 +1,31 @@ |
54 |
+# Use __nonnull only on glibc system |
55 |
+# Closes: https://bugs.gentoo.org/832980 |
56 |
+--- a/shm.c |
57 |
++++ b/shm.c |
58 |
+@@ -35,6 +35,12 @@ |
59 |
+ #endif |
60 |
+ |
61 |
+ #ifdef HAVE_SHMGET_SYSCALL |
62 |
++ |
63 |
++/* define __THROW to avoid build issue when it's not available from the libc */ |
64 |
++#ifndef __THROW |
65 |
++#define __THROW |
66 |
++#endif |
67 |
++ |
68 |
+ /* |
69 |
+ * The calls to dlsym() and dlerror() in the shmget() wrapper below force |
70 |
+ * a dependency on libdl.so. This does not work for static executables |
71 |
+@@ -48,8 +54,13 @@ |
72 |
+ * system shmget() may be performed without worry as there is no dynamic |
73 |
+ * call chain. |
74 |
+ */ |
75 |
++#ifdef __GLIBC__ |
76 |
+ extern void *dlsym (void *__restrict __handle, __const char *__restrict __name) |
77 |
+ __attribute__((weak)) __THROW __nonnull ((2)); |
78 |
++#else |
79 |
++extern void *dlsym (void *__restrict __handle, __const char *__restrict __name) |
80 |
++ __attribute__((weak)) __THROW __attribute__((nonnull((2)))); |
81 |
++#endif // __GLIBC__ |
82 |
+ extern char *dlerror (void) __attribute__((weak)) __THROW; |
83 |
+ |
84 |
+ |
85 |
|
86 |
diff --git a/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-path-max-fix.patch b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-path-max-fix.patch |
87 |
new file mode 100644 |
88 |
index 000000000000..883bb3e98fc7 |
89 |
--- /dev/null |
90 |
+++ b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-path-max-fix.patch |
91 |
@@ -0,0 +1,22 @@ |
92 |
+# Include limits.h for PATH_MAX |
93 |
+# Closes: https://bugs.gentoo.org/828830 |
94 |
+--- a/hugeadm.c |
95 |
++++ b/hugeadm.c |
96 |
+@@ -33,6 +33,7 @@ |
97 |
+ #include <grp.h> |
98 |
+ #include <pwd.h> |
99 |
+ #include <fcntl.h> |
100 |
++#include <limits.h> |
101 |
+ |
102 |
+ #include <sys/stat.h> |
103 |
+ #include <sys/types.h> |
104 |
+--- a/tests/gethugepagesizes.c |
105 |
++++ b/tests/gethugepagesizes.c |
106 |
+@@ -27,6 +27,7 @@ |
107 |
+ #include <sys/types.h> |
108 |
+ #include <sys/stat.h> |
109 |
+ #include <fcntl.h> |
110 |
++#include <limits.h> |
111 |
+ #include <stdarg.h> |
112 |
+ #include <hugetlbfs.h> |
113 |
+ |
114 |
|
115 |
diff --git a/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-sc-level2-fix.patch b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-sc-level2-fix.patch |
116 |
new file mode 100644 |
117 |
index 000000000000..c42e017abec1 |
118 |
--- /dev/null |
119 |
+++ b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-musl-sc-level2-fix.patch |
120 |
@@ -0,0 +1,45 @@ |
121 |
+# _SC_LEVEL2_CACHE_LINESIZE is most probably Glibc specific define. Hence we |
122 |
+# cannot use it with other libc's. Check if _SC_LEVEL2_CACHE_LINESIZE is |
123 |
+# available or use custom function to get CPU cache size |
124 |
+# Original patch was found here [1] |
125 |
+# [1]: https://cgit.openembedded.org/meta-openembedded/plain/meta-oe/recipes-benchmark/libhugetlbfs/files/0003-alloc.c-Avoid-sysconf-_SC_LEVEL2_CACHE_LINESIZE-on-l.patch |
126 |
+# Closes: https://bugs.gentoo.org/828830 |
127 |
+--- a/alloc.c |
128 |
++++ b/alloc.c |
129 |
+@@ -245,6 +245,24 @@ void free_huge_pages(void *ptr) |
130 |
+ __free_huge_pages(ptr, 1); |
131 |
+ } |
132 |
+ |
133 |
++/* |
134 |
++ * Avoid sysconf(_SC_LEVEL2_CACHE_LINESIZE) on linux |
135 |
++ * Taken from the folling patch [1] |
136 |
++ * |
137 |
++ * [1]: https://cgit.openembedded.org/meta-openembedded/plain/meta-oe/recipes-benchmark/libhugetlbfs/files/0003-alloc.c-Avoid-sysconf-_SC_LEVEL2_CACHE_LINESIZE-on-l.patch |
138 |
++ */ |
139 |
++#if !defined(_SC_LEVEL2_CACHE_LINESIZE) |
140 |
++static size_t get_cacheline_size() { |
141 |
++ FILE * fp = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r"); |
142 |
++ unsigned int line_size = 0; |
143 |
++ if (fp) { |
144 |
++ fscanf(fp, "%d", &line_size); |
145 |
++ fclose(fp); |
146 |
++ } |
147 |
++ return line_size; |
148 |
++} |
149 |
++#endif |
150 |
++ |
151 |
+ /* |
152 |
+ * Offset the buffer using bytes wasted due to alignment to avoid using the |
153 |
+ * same cache lines for the start of every buffer returned by |
154 |
+@@ -261,7 +279,11 @@ void *cachecolor(void *buf, size_t len, size_t color_bytes) |
155 |
+ |
156 |
+ /* Lookup our cacheline size once */ |
157 |
+ if (cacheline_size == 0) { |
158 |
++#if defined(_SC_LEVEL2_CACHE_LINESIZE) |
159 |
+ cacheline_size = sysconf(_SC_LEVEL2_CACHE_LINESIZE); |
160 |
++#else |
161 |
++ cacheline_size = get_cacheline_size(); |
162 |
++#endif |
163 |
+ linemod = time(NULL); |
164 |
+ } |
165 |
+ |
166 |
|
167 |
diff --git a/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild b/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild |
168 |
index 7702cc3283c3..c7a87ce891cd 100644 |
169 |
--- a/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild |
170 |
+++ b/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild |
171 |
@@ -23,6 +23,10 @@ PATCHES=( |
172 |
"${FILESDIR}"/${PN}-2.6-fixup-testsuite.patch |
173 |
"${FILESDIR}"/${PN}-2.23-uncompressed-man-pages.patch |
174 |
"${FILESDIR}"/${PN}-2.23-allow-building-against-glibc-2.34.patch |
175 |
+ "${FILESDIR}"/${PN}-2.23-musl-sc-level2-fix.patch |
176 |
+ "${FILESDIR}"/${PN}-2.23-musl-path-max-fix.patch |
177 |
+ "${FILESDIR}"/${PN}-2.23-musl-nonnull-fix.patch |
178 |
+ "${FILESDIR}"/${PN}-2.23-musl-ino_t-fix.patch |
179 |
) |
180 |
|
181 |
src_prepare() { |