stress-ng: backport immintrin.h header detection for GCC 13
[feed/packages.git] / utils / stress-ng / patches / 002-core-stress-Add-musl-gcc-detection-and-HAVE_COMPILER.patch
1 From cd84c46ce780242879e8aaa7d698b9cd87996dbd Mon Sep 17 00:00:00 2001
2 From: Colin Ian King <colin.i.king@gmail.com>
3 Date: Sun, 15 Oct 2023 15:50:07 +0100
4 Subject: [PATCH] core-*, stress-*: Add musl-gcc detection and
5 HAVE_COMPILER_MUSL
6
7 Detect for musl-gcc and define HAVE_COMPILER_MUSL and also define
8 HAVE_COMPILER_GCC_OR_MUSL for GCC or MUSL compilers. Allows one
9 to differentiate between gcc tool chains with and without glibc/musl
10 libc.
11
12 Fixes https://github.com/ColinIanKing/stress-ng/issues/325
13
14 Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
15 ---
16 core-attribute.h | 56 ++++++++++++++++++++++----------------------
17 core-helper.c | 4 ++--
18 core-pragma.h | 18 +++++++-------
19 core-shim.c | 2 +-
20 core-target-clones.h | 2 +-
21 core-vecmath.h | 4 ++--
22 stress-atomic.c | 4 ++--
23 stress-flushcache.c | 2 +-
24 stress-lockbus.c | 4 ++--
25 stress-malloc.c | 4 ++--
26 stress-memthrash.c | 12 +++++-----
27 stress-ng.h | 32 ++++++++++++++++---------
28 stress-regs.c | 8 +++----
29 stress-rseq.c | 14 +++++------
30 stress-vnni.c | 4 ++++
31 15 files changed, 92 insertions(+), 78 deletions(-)
32
33 --- a/core-attribute.h
34 +++ b/core-attribute.h
35 @@ -20,7 +20,7 @@
36 #define CORE_ATTRIBUTE_H
37
38 /* warn unused attribute */
39 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(4, 2, 0)) || \
40 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(4, 2, 0)) || \
41 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0))
42 #define WARN_UNUSED __attribute__((warn_unused_result))
43 #else
44 @@ -36,7 +36,7 @@
45
46 #if defined(HAVE_ATTRIBUTE_FAST_MATH) && \
47 !defined(HAVE_COMPILER_ICC) && \
48 - defined(HAVE_COMPILER_GCC) && \
49 + defined(HAVE_COMPILER_GCC_OR_MUSL) && \
50 NEED_GNUC(10, 0, 0)
51 #define OPTIMIZE_FAST_MATH __attribute__((optimize("fast-math")))
52 #else
53 @@ -44,7 +44,7 @@
54 #endif
55
56 /* no return hint */
57 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(2, 5, 0)) || \
58 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(2, 5, 0)) || \
59 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0))
60 #define NORETURN __attribute__((noreturn))
61 #else
62 @@ -52,7 +52,7 @@
63 #endif
64
65 /* weak attribute */
66 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(4, 0, 0)) || \
67 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(4, 0, 0)) || \
68 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 4, 0))
69 #define WEAK __attribute__((weak))
70 #define HAVE_WEAK_ATTRIBUTE
71 @@ -64,7 +64,7 @@
72 #undef ALWAYS_INLINE
73 #endif
74 /* force inlining hint */
75 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(3, 4, 0) \
76 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(3, 4, 0) \
77 && ((!defined(__s390__) && !defined(__s390x__)) || NEED_GNUC(6, 0, 1))) || \
78 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0))
79 #define ALWAYS_INLINE __attribute__((always_inline))
80 @@ -73,7 +73,7 @@
81 #endif
82
83 /* force no inlining hint */
84 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(3, 4, 0)) || \
85 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(3, 4, 0)) || \
86 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0))
87 #define NOINLINE __attribute__((noinline))
88 #else
89 @@ -81,9 +81,9 @@
90 #endif
91
92 /* -O3 attribute support */
93 -#if defined(HAVE_COMPILER_GCC) && \
94 - !defined(HAVE_COMPILER_CLANG) && \
95 - !defined(HAVE_COMPILER_ICC) && \
96 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
97 + !defined(HAVE_COMPILER_CLANG) && \
98 + !defined(HAVE_COMPILER_ICC) && \
99 NEED_GNUC(4, 6, 0)
100 #define OPTIMIZE3 __attribute__((optimize("-O3")))
101 #else
102 @@ -91,9 +91,9 @@
103 #endif
104
105 /* -O2 attribute support */
106 -#if defined(HAVE_COMPILER_GCC) && \
107 - !defined(HAVE_COMPILER_CLANG) && \
108 - !defined(HAVE_COMPILER_ICC) && \
109 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
110 + !defined(HAVE_COMPILER_CLANG) && \
111 + !defined(HAVE_COMPILER_ICC) && \
112 NEED_GNUC(4, 6, 0)
113 #define OPTIMIZE2 __attribute__((optimize("-O2")))
114 #else
115 @@ -101,9 +101,9 @@
116 #endif
117
118 /* -O1 attribute support */
119 -#if defined(HAVE_COMPILER_GCC) && \
120 - !defined(HAVE_COMPILER_CLANG) && \
121 - !defined(HAVE_COMPILER_ICC) && \
122 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
123 + !defined(HAVE_COMPILER_CLANG) && \
124 + !defined(HAVE_COMPILER_ICC) && \
125 NEED_GNUC(4, 6, 0)
126 #define OPTIMIZE1 __attribute__((optimize("-O1")))
127 #else
128 @@ -111,8 +111,8 @@
129 #endif
130
131 /* -O0 attribute support */
132 -#if defined(HAVE_COMPILER_GCC) && \
133 - !defined(HAVE_COMPILER_ICC) && \
134 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
135 + !defined(HAVE_COMPILER_ICC) && \
136 NEED_GNUC(4, 6, 0)
137 #define OPTIMIZE0 __attribute__((optimize("-O0")))
138 #elif (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(10, 0, 0))
139 @@ -121,10 +121,10 @@
140 #define OPTIMIZE0
141 #endif
142
143 -#if ((defined(HAVE_COMPILER_GCC) && NEED_GNUC(3, 3, 0)) || \
144 - (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0)) || \
145 - (defined(HAVE_COMPILER_ICC) && NEED_ICC(2021, 0, 0))) && \
146 - !defined(HAVE_COMPILER_PCC) && \
147 +#if ((defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(3, 3, 0)) || \
148 + (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0)) || \
149 + (defined(HAVE_COMPILER_ICC) && NEED_ICC(2021, 0, 0))) && \
150 + !defined(HAVE_COMPILER_PCC) && \
151 !defined(__minix__)
152 #define ALIGNED(a) __attribute__((aligned(a)))
153 #else
154 @@ -136,7 +136,7 @@
155 #define ALIGN64 ALIGNED(64)
156
157
158 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(4, 6, 0)) || \
159 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(4, 6, 0)) || \
160 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0))
161 #if (defined(__APPLE__) && defined(__MACH__))
162 #define SECTION(s) __attribute__((__section__(# s "," # s)))
163 @@ -148,7 +148,7 @@
164 #endif
165
166 /* GCC hot attribute */
167 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(4, 6, 0)) || \
168 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(4, 6, 0)) || \
169 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 3, 0))
170 #define HOT __attribute__((hot))
171 #else
172 @@ -156,10 +156,10 @@
173 #endif
174
175 /* GCC mlocked data and data section attribute */
176 -#if ((defined(HAVE_COMPILER_GCC) && NEED_GNUC(4, 6, 0) || \
177 - (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0)))) && \
178 - !defined(__sun__) && \
179 - !defined(__APPLE__) && \
180 +#if ((defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(4, 6, 0) || \
181 + (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0)))) && \
182 + !defined(__sun__) && \
183 + !defined(__APPLE__) && \
184 !defined(BUILD_STATIC)
185 #define MLOCKED_TEXT __attribute__((__section__("mlocked_text")))
186 #define MLOCKED_SECTION (1)
187 @@ -168,7 +168,7 @@
188 #endif
189
190 /* print format attribute */
191 -#if ((defined(HAVE_COMPILER_GCC) && NEED_GNUC(3, 2, 0)) || \
192 +#if ((defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(3, 2, 0)) || \
193 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(3, 0, 0)))
194 #define FORMAT(func, a, b) __attribute__((format(func, a, b)))
195 #else
196 --- a/core-helper.c
197 +++ b/core-helper.c
198 @@ -3486,8 +3486,8 @@ void NORETURN MLOCKED_TEXT stress_sig_ha
199 * __stack_chk_fail()
200 * override stack smashing callback
201 */
202 -#if defined(HAVE_COMPILER_GCC) && \
203 - !defined(HAVE_COMPILER_CLANG) && \
204 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
205 + !defined(HAVE_COMPILER_CLANG) && \
206 defined(HAVE_WEAK_ATTRIBUTE)
207 extern void __stack_chk_fail(void);
208
209 --- a/core-pragma.h
210 +++ b/core-pragma.h
211 @@ -22,8 +22,8 @@
212 #define STRESS_PRAGMA_(x) _Pragma (#x)
213 #define STRESS_PRAGMA(x) STRESS_PRAGMA_(x)
214
215 -#if defined(HAVE_PRAGMA_NO_HARD_DFP) && \
216 - defined(HAVE_COMPILER_GCC) && \
217 +#if defined(HAVE_PRAGMA_NO_HARD_DFP) && \
218 + defined(HAVE_COMPILER_GCC_OR_MUSL) && \
219 defined(HAVE_PRAGMA)
220 #define STRESS_PRAGMA_NO_HARD_DFP _Pragma("GCC target (\"no-hard-dfp\")")
221 #endif
222 @@ -34,8 +34,8 @@
223 #define STRESS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
224 #define STRESS_PRAGMA_POP _Pragma("GCC diagnostic pop")
225 #define STRESS_PRAGMA_WARN_OFF _Pragma("GCC diagnostic ignored \"-Weverything\"")
226 -#elif defined(HAVE_COMPILER_GCC) && \
227 - defined(HAVE_PRAGMA) && \
228 +#elif defined(HAVE_COMPILER_GCC_OR_MUSL) && \
229 + defined(HAVE_PRAGMA) && \
230 NEED_GNUC(7, 5, 0)
231 #define STRESS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
232 #define STRESS_PRAGMA_POP _Pragma("GCC diagnostic pop")
233 @@ -45,8 +45,8 @@
234 _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") \
235 _Pragma("GCC diagnostic ignored \"-Wnonnull\"") \
236 _Pragma("GCC diagnostic ignored \"-Wstringop-overflow\"")
237 -#elif defined(HAVE_COMPILER_GCC) && \
238 - defined(HAVE_PRAGMA) && \
239 +#elif defined(HAVE_COMPILER_GCC_OR_MUSL) && \
240 + defined(HAVE_PRAGMA) && \
241 NEED_GNUC(4, 6, 0)
242 #define STRESS_PRAGMA_PUSH _Pragma("GCC diagnostic push")
243 #define STRESS_PRAGMA_POP _Pragma("GCC diagnostic pop")
244 @@ -65,8 +65,8 @@
245 NEED_CLANG(8, 0, 0) && \
246 defined(HAVE_PRAGMA)
247 #define STRESS_PRAGMA_WARN_CPP_OFF _Pragma("GCC diagnostic ignored \"-Wcpp\"")
248 -#elif defined(HAVE_COMPILER_GCC) && \
249 - defined(HAVE_PRAGMA) && \
250 +#elif defined(HAVE_COMPILER_GCC_OR_MUSL) && \
251 + defined(HAVE_PRAGMA) && \
252 NEED_GNUC(10, 0, 0)
253 #define STRESS_PRAGMA_WARN_CPP_OFF _Pragma("GCC diagnostic ignored \"-Wcpp\"")
254 #else
255 @@ -80,7 +80,7 @@
256 NEED_CLANG(9, 0, 0)
257 #define PRAGMA_UNROLL_N(n) STRESS_PRAGMA(unroll n)
258 #define PRAGMA_UNROLL STRESS_PRAGMA(unroll)
259 -#elif defined(HAVE_COMPILER_GCC) && \
260 +#elif defined(HAVE_COMPILER_GCC_OR_MUSL) && \
261 NEED_GNUC(10, 0, 0)
262 #define PRAGMA_UNROLL_N(n) STRESS_PRAGMA(GCC unroll n)
263 #define PRAGMA_UNROLL STRESS_PRAGMA(GCC unroll 8)
264 --- a/core-shim.c
265 +++ b/core-shim.c
266 @@ -494,7 +494,7 @@ int shim_getrandom(void *buff, size_t bu
267 */
268 void shim_flush_icache(void *begin, void *end)
269 {
270 -#if defined(HAVE_COMPILER_GCC) && \
271 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
272 defined(STRESS_ARCH_ARM)
273 __clear_cache(begin, end);
274 #elif defined(STRESS_ARCH_RISCV) && \
275 --- a/core-target-clones.h
276 +++ b/core-target-clones.h
277 @@ -138,7 +138,7 @@
278 #endif
279
280 #if defined(HAVE_TARGET_CLONES_GRANITERAPIDS) && \
281 - defined(HAVE_COMPILER_GCC)
282 + defined(HAVE_COMPILER_GCC_OR_MUSL)
283 #define TARGET_CLONE_GRANITERAPIDS "arch=graniterapids",
284 #define TARGET_CLONE_USE
285 #else
286 --- a/core-vecmath.h
287 +++ b/core-vecmath.h
288 @@ -38,8 +38,8 @@
289 * PPC64 for some reason with some flavours of the toolchain
290 * so disable this test for now
291 */
292 -#if defined(STRESS_ARCH_PPC64) && \
293 - defined(HAVE_COMPILER_GCC) && \
294 +#if defined(STRESS_ARCH_PPC64) && \
295 + defined(HAVE_COMPILER_GCC_OR_MUSL) && \
296 __GNUC__ < 6
297 #undef HAVE_VECMATH
298 #endif
299 --- a/stress-atomic.c
300 +++ b/stress-atomic.c
301 @@ -71,7 +71,7 @@ typedef int (*atomic_func_t)(const stres
302
303 #if defined(HAVE_ATOMIC_FETCH_NAND)
304 #define HAVE_ATOMIC_OPS
305 -#if defined(HAVE_COMPILER_GCC) && __GNUC__ != 11
306 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && __GNUC__ != 11
307 #define SHIM_ATOMIC_FETCH_NAND(ptr, val, memorder) \
308 do { __atomic_fetch_nand(ptr, val, memorder); } while (0)
309 #else
310 @@ -121,7 +121,7 @@ typedef int (*atomic_func_t)(const stres
311
312 #if defined(HAVE_ATOMIC_NAND_FETCH)
313 #define HAVE_ATOMIC_OPS
314 -#if defined(HAVE_COMPILER_GCC) && __GNUC__ != 11
315 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && __GNUC__ != 11
316 #define SHIM_ATOMIC_NAND_FETCH(ptr, val, memorder) \
317 do { __atomic_nand_fetch(ptr, val, memorder); } while (0)
318 #else
319 --- a/stress-flushcache.c
320 +++ b/stress-flushcache.c
321 @@ -37,7 +37,7 @@ static const stress_help_t help[] = {
322 defined(STRESS_ARCH_S390) || \
323 defined(STRESS_ARCH_PPC64)) && \
324 defined(HAVE_MPROTECT) && \
325 - ((defined(HAVE_COMPILER_GCC) && NEED_GNUC(4,6,0)) || \
326 + ((defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(4,6,0)) || \
327 (defined(HAVE_COMPILER_CLANG) && NEED_CLANG(9,0,0)) || \
328 (defined(HAVE_COMPILER_ICX) && NEED_ICX(2023,2,0)) || \
329 (defined(HAVE_COMPILER_ICC) && NEED_ICC(2021,0,0)))
330 --- a/stress-lockbus.c
331 +++ b/stress-lockbus.c
332 @@ -37,14 +37,14 @@ static const stress_opt_set_func_t opt_s
333 { 0, NULL },
334 };
335
336 -#if (((defined(HAVE_COMPILER_GCC) || \
337 +#if (((defined(HAVE_COMPILER_GCC_OR_MUSL) || \
338 defined(HAVE_COMPILER_CLANG) || \
339 defined(HAVE_COMPILER_ICC) || \
340 defined(HAVE_COMPILER_ICX) || \
341 defined(HAVE_COMPILER_TCC) || \
342 defined(HAVE_COMPILER_PCC)) && \
343 defined(STRESS_ARCH_X86)) || \
344 - (defined(HAVE_COMPILER_GCC) && \
345 + (defined(HAVE_COMPILER_GCC_OR_MUSL) && \
346 (defined(HAVE_ATOMIC_ADD_FETCH) || \
347 defined(HAVE_ATOMIC_FETCH_ADD)) && \
348 defined(__ATOMIC_SEQ_CST) && \
349 --- a/stress-malloc.c
350 +++ b/stress-malloc.c
351 @@ -453,8 +453,8 @@ static int stress_malloc(const stress_ar
352 malloc_max = MIN_MALLOC_MAX;
353 }
354
355 -#if defined(HAVE_COMPILER_GCC) && \
356 - defined(HAVE_MALLOPT) && \
357 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
358 + defined(HAVE_MALLOPT) && \
359 defined(M_MMAP_THRESHOLD)
360 {
361 size_t malloc_threshold = DEFAULT_MALLOC_THRESHOLD;
362 --- a/stress-memthrash.c
363 +++ b/stress-memthrash.c
364 @@ -94,12 +94,12 @@ static sigset_t set;
365
366 static stress_memthrash_primes_t stress_memthrash_primes[MEM_SIZE_PRIMES];
367
368 -#if (((defined(HAVE_COMPILER_GCC) || defined(HAVE_COMPILER_CLANG)) && \
369 - defined(STRESS_ARCH_X86)) || \
370 - (defined(HAVE_COMPILER_GCC) && \
371 - defined(HAVE_ATOMIC_ADD_FETCH) && \
372 - defined(__ATOMIC_SEQ_CST) && \
373 - NEED_GNUC(4,7,0) && \
374 +#if (((defined(HAVE_COMPILER_GCC_OR_MUSL) || defined(HAVE_COMPILER_CLANG)) && \
375 + defined(STRESS_ARCH_X86)) || \
376 + (defined(HAVE_COMPILER_GCC_OR_MUSL) && \
377 + defined(HAVE_ATOMIC_ADD_FETCH) && \
378 + defined(__ATOMIC_SEQ_CST) && \
379 + NEED_GNUC(4,7,0) && \
380 defined(STRESS_ARCH_ARM)))
381 #if defined(HAVE_ATOMIC_ADD_FETCH)
382 #define MEM_LOCK(ptr, inc) __atomic_add_fetch(ptr, inc, __ATOMIC_SEQ_CST)
383 --- a/stress-ng.h
384 +++ b/stress-ng.h
385 @@ -22,6 +22,14 @@
386
387 #include "config.h"
388
389 +#ifndef _GNU_SOURCE
390 +#define _GNU_SOURCE
391 +#endif
392 +
393 +#if defined(HAVE_FEATURES_H)
394 +#include <features.h>
395 +#endif
396 +
397 #if defined(__ICC) && \
398 defined(__INTEL_COMPILER)
399 /* Intel ICC compiler */
400 @@ -41,15 +49,20 @@
401 #elif defined(__clang__)
402 /* clang */
403 #define HAVE_COMPILER_CLANG
404 +#elif defined(__GNUC__) && \
405 + !defined(__USE_GNU)
406 +/* musl gcc */
407 +#define HAVE_COMPILER_MUSL
408 +#define HAVE_COMPILER_GCC_OR_MUSL
409 #elif defined(__GNUC__)
410 /* GNU C compiler */
411 #define HAVE_COMPILER_GCC
412 +#define HAVE_COMPILER_GCC_OR_MUSL
413 #endif
414
415 -#ifndef _GNU_SOURCE
416 -#define _GNU_SOURCE
417 -#endif
418 +#ifndef _ATFILE_SOURCE
419 #define _ATFILE_SOURCE
420 +#endif
421 #ifndef _LARGEFILE_SOURCE
422 #define _LARGEFILE_SOURCE
423 #endif
424 @@ -101,9 +114,6 @@
425 #include <string.h>
426 #include <time.h>
427 #include <unistd.h>
428 -#if defined(HAVE_FEATURES_H)
429 -#include <features.h>
430 -#endif
431 #if defined(HAVE_LIB_PTHREAD)
432 #include <pthread.h>
433 #endif
434 @@ -144,7 +154,7 @@
435 #endif
436 #if defined(HAVE_SYS_SYSINFO_H)
437 #include <sys/sysinfo.h>
438 -#if defined(HAVE_COMPILER_GCC) && \
439 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
440 !defined(__GLIBC__)
441 /* Suppress kernel sysinfo to avoid collision with musl */
442 #define _LINUX_SYSINFO_H
443 @@ -237,7 +247,7 @@ typedef struct stress_stressor_info {
444
445 #if defined(CHECK_UNEXPECTED) && \
446 defined(HAVE_PRAGMA) && \
447 - defined(HAVE_COMPILER_GCC)
448 + defined(HAVE_COMPILER_GCC_OR_MUSL)
449 #define UNEXPECTED_PRAGMA(x) _Pragma (#x)
450 #define UNEXPECTED_XSTR(x) UNEXPECTED_STR(x)
451 #define UNEXPECTED_STR(x) # x
452 @@ -427,7 +437,7 @@ typedef struct stressor_info {
453 } stressor_info_t;
454
455 /* gcc 4.7 and later support vector ops */
456 -#if defined(HAVE_COMPILER_GCC) && \
457 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) && \
458 NEED_GNUC(4, 7, 0)
459 #define STRESS_VECTOR (1)
460 #endif
461 @@ -508,7 +518,7 @@ extern const char stress_config[];
462 #define PAGE_MAPPED (0x01)
463 #define PAGE_MAPPED_FAIL (0x02)
464
465 -#if defined(HAVE_COMPILER_GCC) || defined(HAVE_COMPILER_CLANG)
466 +#if defined(HAVE_COMPILER_GCC_OR_MUSL) || defined(HAVE_COMPILER_CLANG)
467 #define TYPEOF_CAST(a) (typeof(a))
468 #else
469 #define TYPEOF_CAST(a)
470 @@ -839,7 +849,7 @@ extern void stress_metrics_set_const_che
471
472 #if !defined(STRESS_CORE_SHIM) && \
473 !defined(HAVE_PEDANTIC) && \
474 - (defined(HAVE_COMPILER_GCC) && defined(HAVE_COMPILER_CLANG))
475 + (defined(HAVE_COMPILER_GCC_OR_MUSL) && defined(HAVE_COMPILER_CLANG))
476 int unlink(const char *pathname) __attribute__((deprecated("use shim_unlink")));
477 int unlinkat(int dirfd, const char *pathname, int flags) __attribute__((deprecated("use shim_unlinkat")));
478 int rmdir(const char *pathname) __attribute__((deprecated("use shim_rmdir")));
479 --- a/stress-regs.c
480 +++ b/stress-regs.c
481 @@ -33,10 +33,10 @@ static const stress_help_t help[] = {
482 { NULL, NULL, NULL }
483 };
484
485 -#if (defined(HAVE_COMPILER_GCC) && NEED_GNUC(8, 0, 0)) && \
486 - !defined(HAVE_COMPILER_CLANG) && \
487 - !defined(HAVE_COMPILER_ICC) && \
488 - !defined(HAVE_COMPILER_PCC) && \
489 +#if (defined(HAVE_COMPILER_GCC_OR_MUSL) && NEED_GNUC(8, 0, 0)) && \
490 + !defined(HAVE_COMPILER_CLANG) && \
491 + !defined(HAVE_COMPILER_ICC) && \
492 + !defined(HAVE_COMPILER_PCC) && \
493 !defined(HAVE_COMPILER_TCC)
494
495 static volatile uint32_t stash32;
496 --- a/stress-rseq.c
497 +++ b/stress-rseq.c
498 @@ -32,13 +32,13 @@ static const stress_help_t help[] = {
499 { NULL, NULL, NULL }
500 };
501
502 -#if defined(HAVE_LINUX_RSEQ_H) && \
503 - defined(HAVE_ASM_NOP) && \
504 - defined(__NR_rseq) && \
505 - defined(HAVE_SYSCALL) && \
506 - defined(HAVE_COMPILER_GCC) && \
507 - !defined(HAVE_COMPILER_CLANG) && \
508 - !defined(HAVE_COMPILER_ICC) && \
509 +#if defined(HAVE_LINUX_RSEQ_H) && \
510 + defined(HAVE_ASM_NOP) && \
511 + defined(__NR_rseq) && \
512 + defined(HAVE_SYSCALL) && \
513 + defined(HAVE_COMPILER_GCC_OR_MUSL) && \
514 + !defined(HAVE_COMPILER_CLANG) && \
515 + !defined(HAVE_COMPILER_ICC) && \
516 !defined(HAVE_COMPILER_ICX)
517
518 #define STRESS_ACCESS_ONCE(x) (*(__volatile__ __typeof__(x) *)&(x))
519 --- a/stress-vnni.c
520 +++ b/stress-vnni.c
521 @@ -25,6 +25,10 @@
522 #include "core-pragma.h"
523 #include "core-target-clones.h"
524
525 +#if defined(HAVE_COMPILER_MUSL)
526 +#undef HAVE_IMMINTRIN_H
527 +#endif
528 +
529 #if defined(HAVE_IMMINTRIN_H)
530 #include <immintrin.h>
531 #endif