ar71xx: fix legacy image build error
[openwrt/staging/yousong.git] / target / linux / generic / patches-4.1 / 133-MIPS-UAPI-Ignore-__arch_swab-16-32-64-when-using-MIP.patch
1 From 71a0a72456b48de972d7ed613b06a22a3aa9057f Mon Sep 17 00:00:00 2001
2 From: Yousong Zhou <yszhou4tech@gmail.com>
3 Date: Sat, 26 Sep 2015 13:41:43 +0800
4 Subject: [PATCH] MIPS: UAPI: Ignore __arch_swab{16,32,64} when using MIPS16
5
6 Some GCC versions (e.g. 4.8.3) can incorrectly inline a function with
7 MIPS32 instructions into another function with MIPS16 code [1], causing
8 the assembler to genereate incorrect binary code or fail right away
9 complaining about unrecognized opcode.
10
11 In the case of __arch_swab{16,32}, when inlined by the compiler with
12 flags `-mips32r2 -mips16 -Os', the assembler can fail with the following
13 error.
14
15 {standard input}:79: Error: unrecognized opcode `wsbh $2,$2'
16
17 For performance concerns and to workaround the issue already existing in
18 older compilers, just ignore these 2 functions when compiling with
19 mips16 enabled.
20
21 [1] Inlining nomips16 function into mips16 function can result in
22 undefined builtins, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55777
23
24 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
25 Cc: Maciej W. Rozycki <macro@linux-mips.org>
26 Cc: linux-mips@linux-mips.org
27 Patchwork: https://patchwork.linux-mips.org/patch/11241/
28 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
29 ---
30 arch/mips/include/uapi/asm/swab.h | 7 ++++---
31 1 file changed, 4 insertions(+), 3 deletions(-)
32
33 --- a/arch/mips/include/uapi/asm/swab.h
34 +++ b/arch/mips/include/uapi/asm/swab.h
35 @@ -13,8 +13,9 @@
36
37 #define __SWAB_64_THRU_32__
38
39 -#if (defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
40 - defined(_MIPS_ARCH_LOONGSON3A)
41 +#if !defined(__mips16) && \
42 + ((defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
43 + defined(_MIPS_ARCH_LOONGSON3A))
44
45 static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
46 {
47 @@ -65,5 +66,5 @@ static inline __attribute_const__ __u64
48 }
49 #define __arch_swab64 __arch_swab64
50 #endif /* __mips64 */
51 -#endif /* MIPS R2 or newer or Loongson 3A */
52 +#endif /* (not __mips16) and (MIPS R2 or newer or Loongson 3A) */
53 #endif /* _ASM_SWAB_H */