05be099ca5e4e77efd5fe1fa05ddb03a5279c3e2
[openwrt/openwrt.git] / package / devel / valgrind / patches / 130-mips_fix_soft_float.patch
1 Disable the valgrind helpers which use MIPS floating point operations
2 when floating point support is deactivated in the toolchain.
3
4 The fix from this commit is not sufficient any more:
5 https://sourceware.org/git/?p=valgrind.git;a=commitdiff;h=869fcf2f6739f17b4eff36ec68f8dca826c8afeb
6
7 This fixes the following error message when compiling with a GCC 10 MIPS BE 32:
8 ---------------------------------------------------------
9 ../VEX/priv/guest_mips_helpers.c: In function 'mips_dirtyhelper_calculate_FCSR_fp32':
10 ../VEX/priv/guest_mips_helpers.c:640:10: error: the register '$f21' cannot be clobbered in 'asm' for the current target
11 640 | ASM_VOLATILE_UNARY32_DOUBLE(round.w.d)
12 | ^
13 ---------------------------------------------------------
14
15 --- a/VEX/priv/guest_mips_helpers.c
16 +++ b/VEX/priv/guest_mips_helpers.c
17 @@ -617,6 +617,7 @@ extern UInt mips_dirtyhelper_calculate_F
18 flt_op inst )
19 {
20 UInt ret = 0;
21 +#ifndef __mips_soft_float
22 #if defined(__mips__)
23 VexGuestMIPS32State* guest_state = (VexGuestMIPS32State*)gs;
24 UInt loFsVal, hiFsVal, loFtVal, hiFtVal;
25 @@ -699,6 +700,7 @@ extern UInt mips_dirtyhelper_calculate_F
26 break;
27 }
28 #endif
29 +#endif
30 return ret;
31 }
32
33 @@ -708,6 +710,7 @@ extern UInt mips_dirtyhelper_calculate_F
34 flt_op inst )
35 {
36 UInt ret = 0;
37 +#ifndef __mips_soft_float
38 #if defined(__mips__) && ((__mips == 64) || \
39 (defined(__mips_isa_rev) && (__mips_isa_rev >= 2)))
40 #if defined(VGA_mips32)
41 @@ -860,6 +863,7 @@ extern UInt mips_dirtyhelper_calculate_F
42 break;
43 }
44 #endif
45 +#endif
46 return ret;
47 }
48
49 --- a/coregrind/m_machine.c
50 +++ b/coregrind/m_machine.c
51 @@ -1828,6 +1828,7 @@ Bool VG_(machine_get_hwcaps)( void )
52 we are using alternative way to determine FP mode */
53 ULong result = 0;
54
55 +#ifndef __mips_soft_float
56 if (!VG_MINIMAL_SETJMP(env_unsup_insn)) {
57 __asm__ volatile (
58 ".set push\n\t"
59 @@ -1845,6 +1846,9 @@ Bool VG_(machine_get_hwcaps)( void )
60
61 fpmode = (result != 0x3FF0000000000000ull);
62 }
63 +#else
64 + fpmode = 0;
65 +#endif
66 }
67
68 if (fpmode != 0)