All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] m68k: Add -ffreestanding to CFLAGS
@ 2019-01-16  5:23 Finn Thain
       [not found] ` <20190118150139.EF5542087E@mail.kernel.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Finn Thain @ 2019-01-16  5:23 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: stable, linux-m68k, linux-kernel

This patch fixes a build failure when using GCC 8.1:

/usr/bin/ld: block/partitions/ldm.o: in function `ldm_parse_tocblock':
block/partitions/ldm.c:153: undefined reference to `strcmp'

This is caused by a new optimization which effectively replaces a
strncmp() call with a strcmp() call. This affects a number of strncmp()
call sites in the kernel.

The entire class of optimizations is avoided with -fno-builtin, which
gets enabled by -ffreestanding. This may avoid possible future build
failures in case new optimizations appear in future compilers.

I haven't done any performance measurements with this patch but I did
count the function calls in a defconfig build. For example, there are now
23 more sprintf() calls and 39 fewer strcpy() calls. The effect on the
other libc functions is smaller.

If this harms performance we can tackle that regression by optimizing
the call sites, ideally using semantic patches. That way, clang and ICC
builds might benfit too.

Cc: stable@vger.kernel.org
Reference: https://marc.info/?l=linux-m68k&m=154514816222244&w=2
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
 arch/m68k/Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 997c9f20ea0f..0a99c276d9a4 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -58,7 +58,8 @@ cpuflags-$(CONFIG_M5206e)	:= $(call cc-option,-mcpu=5206e,-m5200)
 cpuflags-$(CONFIG_M5206)	:= $(call cc-option,-mcpu=5206,-m5200)
 
 KBUILD_AFLAGS += $(cpuflags-y)
-KBUILD_CFLAGS += $(cpuflags-y) -pipe
+KBUILD_CFLAGS += $(cpuflags-y)
+
 ifdef CONFIG_MMU
 # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
 KBUILD_CFLAGS += -fno-strength-reduce -ffixed-a2
@@ -69,6 +70,8 @@ KBUILD_CFLAGS += -D__uClinux__
 KBUILD_AFLAGS += -D__uClinux__
 endif
 
+KBUILD_CFLAGS += -pipe -ffreestanding
+
 KBUILD_LDFLAGS := -m m68kelf
 KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
 
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] m68k: Add -ffreestanding to CFLAGS
       [not found] ` <20190118150139.EF5542087E@mail.kernel.org>
@ 2019-01-18 22:12   ` Finn Thain
  2019-01-20  9:52     ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Finn Thain @ 2019-01-18 22:12 UTC (permalink / raw)
  To: Sasha Levin, Geert Uytterhoeven; +Cc: stable

On Fri, 18 Jan 2019, Sasha Levin wrote:

> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a -stable tag.
> The stable tag indicates that it's relevant for the following trees: all
> 
> The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150, v4.4.170, v3.18.132.
> 
> v4.20.2: Build OK!
> v4.19.15: Build OK!
> v4.14.93: Failed to apply! ...
> v4.9.150: Failed to apply! ...
> v4.4.170: Failed to apply! ...
> v3.18.132: Failed to apply! ...
> 
> How should we proceed with this patch?
> 

Maybe we should ask Geert to drop the v1 patch?

I think this should work on every branch --

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 0b29dcfef69f..0c736ed58abd 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -59,7 +59,10 @@ cpuflags-$(CONFIG_M5206e)	:= $(call cc-option,-mcpu=5206e,-m5200)
 cpuflags-$(CONFIG_M5206)	:= $(call cc-option,-mcpu=5206,-m5200)
 
 KBUILD_AFLAGS += $(cpuflags-y)
-KBUILD_CFLAGS += $(cpuflags-y) -pipe
+KBUILD_CFLAGS += $(cpuflags-y)
+
+KBUILD_CFLAGS += -pipe -ffreestanding
+
 ifdef CONFIG_MMU
 # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
 KBUILD_CFLAGS += -fno-strength-reduce -ffixed-a2

Shall I send v2?

-- 

> --
> Thanks,
> Sasha
> 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] m68k: Add -ffreestanding to CFLAGS
  2019-01-18 22:12   ` Finn Thain
@ 2019-01-20  9:52     ` Geert Uytterhoeven
  2019-01-21  9:43       ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2019-01-20  9:52 UTC (permalink / raw)
  To: Finn Thain; +Cc: Sasha Levin, stable

Hi Finn,

On Fri, Jan 18, 2019 at 11:11 PM Finn Thain <fthain@telegraphics.com.au> wrote:
> On Fri, 18 Jan 2019, Sasha Levin wrote:
> > [This is an automated email]
> >
> > This commit has been processed because it contains a -stable tag.
> > The stable tag indicates that it's relevant for the following trees: all
> >
> > The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150, v4.4.170, v3.18.132.
> >
> > v4.20.2: Build OK!
> > v4.19.15: Build OK!
> > v4.14.93: Failed to apply! ...
> > v4.9.150: Failed to apply! ...
> > v4.4.170: Failed to apply! ...
> > v3.18.132: Failed to apply! ...
> >
> > How should we proceed with this patch?
> >
>
> Maybe we should ask Geert to drop the v1 patch?
>
> I think this should work on every branch --
>
> diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
> index 0b29dcfef69f..0c736ed58abd 100644
> --- a/arch/m68k/Makefile
> +++ b/arch/m68k/Makefile
> @@ -59,7 +59,10 @@ cpuflags-$(CONFIG_M5206e)    := $(call cc-option,-mcpu=5206e,-m5200)
>  cpuflags-$(CONFIG_M5206)       := $(call cc-option,-mcpu=5206,-m5200)
>
>  KBUILD_AFLAGS += $(cpuflags-y)
> -KBUILD_CFLAGS += $(cpuflags-y) -pipe
> +KBUILD_CFLAGS += $(cpuflags-y)
> +
> +KBUILD_CFLAGS += -pipe -ffreestanding
> +
>  ifdef CONFIG_MMU
>  # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
>  KBUILD_CFLAGS += -fno-strength-reduce -ffixed-a2
>
> Shall I send v2?

That's not needed. I replaced your v1, and pushed it to kernel.org branch
test-freestanding for the autobuilders.

Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] m68k: Add -ffreestanding to CFLAGS
  2019-01-20  9:52     ` Geert Uytterhoeven
@ 2019-01-21  9:43       ` Geert Uytterhoeven
  0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2019-01-21  9:43 UTC (permalink / raw)
  To: Finn Thain; +Cc: Sasha Levin, stable

On Sun, Jan 20, 2019 at 10:52 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Jan 18, 2019 at 11:11 PM Finn Thain <fthain@telegraphics.com.au> wrote:
> > On Fri, 18 Jan 2019, Sasha Levin wrote:
> > > [This is an automated email]
> > >
> > > This commit has been processed because it contains a -stable tag.
> > > The stable tag indicates that it's relevant for the following trees: all
> > >
> > > The bot has tested the following trees: v4.20.2, v4.19.15, v4.14.93, v4.9.150, v4.4.170, v3.18.132.
> > >
> > > v4.20.2: Build OK!
> > > v4.19.15: Build OK!
> > > v4.14.93: Failed to apply! ...
> > > v4.9.150: Failed to apply! ...
> > > v4.4.170: Failed to apply! ...
> > > v3.18.132: Failed to apply! ...
> > >
> > > How should we proceed with this patch?
> > >
> >
> > Maybe we should ask Geert to drop the v1 patch?
> >
> > I think this should work on every branch --
> >
> > diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
> > index 0b29dcfef69f..0c736ed58abd 100644
> > --- a/arch/m68k/Makefile
> > +++ b/arch/m68k/Makefile
> > @@ -59,7 +59,10 @@ cpuflags-$(CONFIG_M5206e)    := $(call cc-option,-mcpu=5206e,-m5200)
> >  cpuflags-$(CONFIG_M5206)       := $(call cc-option,-mcpu=5206,-m5200)
> >
> >  KBUILD_AFLAGS += $(cpuflags-y)
> > -KBUILD_CFLAGS += $(cpuflags-y) -pipe
> > +KBUILD_CFLAGS += $(cpuflags-y)
> > +
> > +KBUILD_CFLAGS += -pipe -ffreestanding
> > +
> >  ifdef CONFIG_MMU
> >  # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
> >  KBUILD_CFLAGS += -fno-strength-reduce -ffixed-a2
> >
> > Shall I send v2?
>
> That's not needed. I replaced your v1, and pushed it to kernel.org branch
> test-freestanding for the autobuilders.

Thanks, applied and queued for v5.1.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-21  9:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16  5:23 [PATCH] m68k: Add -ffreestanding to CFLAGS Finn Thain
     [not found] ` <20190118150139.EF5542087E@mail.kernel.org>
2019-01-18 22:12   ` Finn Thain
2019-01-20  9:52     ` Geert Uytterhoeven
2019-01-21  9:43       ` Geert Uytterhoeven

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.