]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.31/m68k-add-ffreestanding-to-cflags.patch
Linux 4.19.31
[thirdparty/kernel/stable-queue.git] / releases / 4.19.31 / m68k-add-ffreestanding-to-cflags.patch
CommitLineData
df1bfe5f
GKH
1From 28713169d879b67be2ef2f84dcf54905de238294 Mon Sep 17 00:00:00 2001
2From: Finn Thain <fthain@telegraphics.com.au>
3Date: Wed, 16 Jan 2019 16:23:24 +1100
4Subject: m68k: Add -ffreestanding to CFLAGS
5
6From: Finn Thain <fthain@telegraphics.com.au>
7
8commit 28713169d879b67be2ef2f84dcf54905de238294 upstream.
9
10This patch fixes a build failure when using GCC 8.1:
11
12/usr/bin/ld: block/partitions/ldm.o: in function `ldm_parse_tocblock':
13block/partitions/ldm.c:153: undefined reference to `strcmp'
14
15This is caused by a new optimization which effectively replaces a
16strncmp() call with a strcmp() call. This affects a number of strncmp()
17call sites in the kernel.
18
19The entire class of optimizations is avoided with -fno-builtin, which
20gets enabled by -ffreestanding. This may avoid possible future build
21failures in case new optimizations appear in future compilers.
22
23I haven't done any performance measurements with this patch but I did
24count the function calls in a defconfig build. For example, there are now
2523 more sprintf() calls and 39 fewer strcpy() calls. The effect on the
26other libc functions is smaller.
27
28If this harms performance we can tackle that regression by optimizing
29the call sites, ideally using semantic patches. That way, clang and ICC
30builds might benfit too.
31
32Cc: stable@vger.kernel.org
33Reference: https://marc.info/?l=linux-m68k&m=154514816222244&w=2
34Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
35Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
36Signed-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