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