kernel: fix tools build breakage on macos with x86
[openwrt/staging/pepe2k.git] / target / linux / generic / hack-6.6 / 200-tools_portability.patch
1 --- a/tools/scripts/Makefile.include
2 +++ b/tools/scripts/Makefile.include
3 @@ -72,8 +72,6 @@ $(call allow-override,CXX,$(CROSS_COMPIL
4 $(call allow-override,STRIP,$(CROSS_COMPILE)strip)
5 endif
6
7 -CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
8 -
9 ifneq ($(LLVM),)
10 HOSTAR ?= $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)
11 HOSTCC ?= $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
12 @@ -84,6 +82,9 @@ HOSTCC ?= gcc
13 HOSTLD ?= ld
14 endif
15
16 +CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
17 +HOSTCC_NO_CLANG := $(shell $(HOSTCC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
18 +
19 # Some tools require Clang, LLC and/or LLVM utils
20 CLANG ?= clang
21 LLC ?= llc
22 @@ -92,8 +93,9 @@ LLVM_OBJCOPY ?= llvm-objcopy
23 LLVM_STRIP ?= llvm-strip
24
25 ifeq ($(CC_NO_CLANG), 1)
26 -EXTRA_WARNINGS += -Wstrict-aliasing=3
27 -
28 + ifeq ($(HOSTCC_NO_CLANG), 1)
29 + EXTRA_WARNINGS += -Wstrict-aliasing=3
30 + endif
31 else ifneq ($(CROSS_COMPILE),)
32 # Allow userspace to override CLANG_CROSS_FLAGS to specify their own
33 # sysroots and flags or to avoid the GCC call in pure Clang builds.
34 --- a/tools/include/linux/types.h
35 +++ b/tools/include/linux/types.h
36 @@ -56,6 +56,7 @@ typedef __s8 s8;
37 #define __user
38 #endif
39 #define __must_check
40 +#undef __cold
41 #define __cold
42
43 typedef __u16 __bitwise __le16;
44 --- a/tools/objtool/include/objtool/objtool.h
45 +++ b/tools/objtool/include/objtool/objtool.h
46 @@ -12,6 +12,7 @@
47
48 #include <objtool/elf.h>
49
50 +#undef __weak
51 #define __weak __attribute__((weak))
52
53 struct pv_state {
54 --- a/tools/include/asm-generic/bitops/fls.h
55 +++ b/tools/include/asm-generic/bitops/fls.h
56 @@ -2,6 +2,8 @@
57 #ifndef _ASM_GENERIC_BITOPS_FLS_H_
58 #define _ASM_GENERIC_BITOPS_FLS_H_
59
60 +#include <string.h>
61 +
62 /**
63 * fls - find last (most-significant) bit set
64 * @x: the word to search
65 @@ -10,6 +12,7 @@
66 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
67 */
68
69 +#define fls __linux_fls
70 static __always_inline int fls(unsigned int x)
71 {
72 int r = 32;
73 --- a/tools/lib/string.c
74 +++ b/tools/lib/string.c
75 @@ -96,6 +96,7 @@ int strtobool(const char *s, bool *res)
76 * If libc has strlcpy() then that version will override this
77 * implementation:
78 */
79 +#ifndef __APPLE__
80 #ifdef __clang__
81 #pragma clang diagnostic push
82 #pragma clang diagnostic ignored "-Wignored-attributes"
83 @@ -114,6 +115,7 @@ size_t __weak strlcpy(char *dest, const
84 #ifdef __clang__
85 #pragma clang diagnostic pop
86 #endif
87 +#endif
88
89 /**
90 * skip_spaces - Removes leading whitespace from @str.