]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/arc-explicitly-add-mmedium-calls-to-cflags.patch
3dd2a43c903cc24397a2984ad4a476ed44f99d80
[thirdparty/kernel/stable-queue.git] / queue-4.4 / arc-explicitly-add-mmedium-calls-to-cflags.patch
1 From foo@baz Wed Aug 22 10:28:26 CEST 2018
2 From: Alexey Brodkin <abrodkin@synopsys.com>
3 Date: Fri, 1 Jun 2018 14:34:33 +0300
4 Subject: ARC: Explicitly add -mmedium-calls to CFLAGS
5
6 From: Alexey Brodkin <abrodkin@synopsys.com>
7
8 [ Upstream commit 74c11e300c103af47db5b658fdcf28002421e250 ]
9
10 GCC built for arc*-*-linux has "-mmedium-calls" implicitly enabled by default
11 thus we don't see any problems during Linux kernel compilation.
12 ----------------------------->8------------------------
13 arc-linux-gcc -mcpu=arc700 -Q --help=target | grep calls
14 -mlong-calls [disabled]
15 -mmedium-calls [enabled]
16 ----------------------------->8------------------------
17
18 But if we try to use so-called Elf32 toolchain with GCC configured for
19 arc*-*-elf* then we'd see the following failure:
20 ----------------------------->8------------------------
21 init/do_mounts.o: In function 'init_rootfs':
22 do_mounts.c:(.init.text+0x108): relocation truncated to fit: R_ARC_S21W_PCREL
23 against symbol 'unregister_filesystem' defined in .text section in fs/filesystems.o
24
25 arc-elf32-ld: final link failed: Symbol needs debug section which does not exist
26 make: *** [vmlinux] Error 1
27 ----------------------------->8------------------------
28
29 That happens because neither "-mmedium-calls" nor "-mlong-calls" are enabled in
30 Elf32 GCC:
31 ----------------------------->8------------------------
32 arc-elf32-gcc -mcpu=arc700 -Q --help=target | grep calls
33 -mlong-calls [disabled]
34 -mmedium-calls [disabled]
35 ----------------------------->8------------------------
36
37 Now to make it possible to use Elf32 toolchain for building Linux kernel
38 we're explicitly add "-mmedium-calls" to CFLAGS.
39
40 And since we add "-mmedium-calls" to the global CFLAGS there's no point in
41 having per-file copies thus removing them.
42
43 Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
44 Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
45
46 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
47 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
48 ---
49 arch/arc/Makefile | 15 +--------------
50 1 file changed, 1 insertion(+), 14 deletions(-)
51
52 --- a/arch/arc/Makefile
53 +++ b/arch/arc/Makefile
54 @@ -14,7 +14,7 @@ endif
55
56 KBUILD_DEFCONFIG := nsim_700_defconfig
57
58 -cflags-y += -fno-common -pipe -fno-builtin -D__linux__
59 +cflags-y += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
60 cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
61 cflags-$(CONFIG_ISA_ARCV2) += -mcpu=archs
62
63 @@ -137,16 +137,3 @@ dtbs: scripts
64
65 archclean:
66 $(Q)$(MAKE) $(clean)=$(boot)
67 -
68 -# Hacks to enable final link due to absence of link-time branch relexation
69 -# and gcc choosing optimal(shorter) branches at -O3
70 -#
71 -# vineetg Feb 2010: -mlong-calls switched off for overall kernel build
72 -# However lib/decompress_inflate.o (.init.text) calls
73 -# zlib_inflate_workspacesize (.text) causing relocation errors.
74 -# Thus forcing all exten calls in this file to be long calls
75 -export CFLAGS_decompress_inflate.o = -mmedium-calls
76 -export CFLAGS_initramfs.o = -mmedium-calls
77 -ifdef CONFIG_SMP
78 -export CFLAGS_core.o = -mmedium-calls
79 -endif