]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/m68k-add-ffreestanding-to-cflags.patch
Linux 4.14.108
[thirdparty/kernel/stable-queue.git] / queue-4.19 / m68k-add-ffreestanding-to-cflags.patch
1 From 28713169d879b67be2ef2f84dcf54905de238294 Mon Sep 17 00:00:00 2001
2 From: Finn Thain <fthain@telegraphics.com.au>
3 Date: Wed, 16 Jan 2019 16:23:24 +1100
4 Subject: m68k: Add -ffreestanding to CFLAGS
5
6 From: Finn Thain <fthain@telegraphics.com.au>
7
8 commit 28713169d879b67be2ef2f84dcf54905de238294 upstream.
9
10 This patch fixes a build failure when using GCC 8.1:
11
12 /usr/bin/ld: block/partitions/ldm.o: in function `ldm_parse_tocblock':
13 block/partitions/ldm.c:153: undefined reference to `strcmp'
14
15 This is caused by a new optimization which effectively replaces a
16 strncmp() call with a strcmp() call. This affects a number of strncmp()
17 call sites in the kernel.
18
19 The entire class of optimizations is avoided with -fno-builtin, which
20 gets enabled by -ffreestanding. This may avoid possible future build
21 failures in case new optimizations appear in future compilers.
22
23 I haven't done any performance measurements with this patch but I did
24 count the function calls in a defconfig build. For example, there are now
25 23 more sprintf() calls and 39 fewer strcpy() calls. The effect on the
26 other libc functions is smaller.
27
28 If this harms performance we can tackle that regression by optimizing
29 the call sites, ideally using semantic patches. That way, clang and ICC
30 builds might benfit too.
31
32 Cc: stable@vger.kernel.org
33 Reference: https://marc.info/?l=linux-m68k&m=154514816222244&w=2
34 Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
35 Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
36 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37
38 ---
39 arch/m68k/Makefile | 5 ++++-
40 1 file changed, 4 insertions(+), 1 deletion(-)
41
42 --- a/arch/m68k/Makefile
43 +++ b/arch/m68k/Makefile
44 @@ -58,7 +58,10 @@ cpuflags-$(CONFIG_M5206e) := $(call cc-o
45 cpuflags-$(CONFIG_M5206) := $(call cc-option,-mcpu=5206,-m5200)
46
47 KBUILD_AFLAGS += $(cpuflags-y)
48 -KBUILD_CFLAGS += $(cpuflags-y) -pipe
49 +KBUILD_CFLAGS += $(cpuflags-y)
50 +
51 +KBUILD_CFLAGS += -pipe -ffreestanding
52 +
53 ifdef CONFIG_MMU
54 # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
55 KBUILD_CFLAGS += -fno-strength-reduce -ffixed-a2