]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
m68k: Optimize cc-option calls for cpuflags-y
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 26 May 2020 12:38:09 +0000 (21:38 +0900)
committerGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 13 Jul 2020 09:39:13 +0000 (11:39 +0200)
arch/m68k/Makefile computes lots of unneeded cc-option calls.

For example, if CONFIG_M5441x is not defined, there is not point in
evaluating the following compiler flag.

 cpuflags-$(CONFIG_M5441x)      := $(call cc-option,-mcpu=54455,-mcfv4e)

The result is set to cpuflags-, then thrown away.

The right hand side of ':=' is immediately expanded. Hence, all of the
16 calls for cc-option are evaluated. This is expensive since cc-option
invokes the compiler. This occurs even if you are not attempting to
build anything, like 'make ARCH=m68k help'.

Use '=' to expand the value _lazily_. The evaluation for cc-option is
delayed until $(cpuflags-y) is expanded. So, the cc-option test happens
just once at most.

This commit mimics tune-y of arch/arm/Makefile.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Greg Ungerer <gerg@linux-m68k.org>
Link: https://lore.kernel.org/r/20200526123810.301667-3-masahiroy@kernel.org
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
arch/m68k/Makefile

index e431015f5cc9ef6c830bf4db27fce91fd7288d07..0507bf297727ed92b4a352bc274c95a01b8084e5 100644 (file)
@@ -32,30 +32,33 @@ endif
 #      compiler cpu type flag.
 #
 ifndef CONFIG_M68040
-cpuflags-$(CONFIG_M68060)      := -m68060
+cpuflags-$(CONFIG_M68060)      = -m68060
 endif
 ifndef CONFIG_M68060
-cpuflags-$(CONFIG_M68040)      := -m68040
+cpuflags-$(CONFIG_M68040)      = -m68040
 endif
-cpuflags-$(CONFIG_M68030)      :=
-cpuflags-$(CONFIG_M68020)      :=
-cpuflags-$(CONFIG_M68000)      := -m68000
-cpuflags-$(CONFIG_M5441x)      := $(call cc-option,-mcpu=54455,-mcfv4e)
-cpuflags-$(CONFIG_M54xx)       := $(call cc-option,-mcpu=5475,-m5200)
-cpuflags-$(CONFIG_M5407)       := $(call cc-option,-mcpu=5407,-m5200)
-cpuflags-$(CONFIG_M532x)       := $(call cc-option,-mcpu=532x,-m5307)
-cpuflags-$(CONFIG_M537x)       := $(call cc-option,-mcpu=537x,-m5307)
-cpuflags-$(CONFIG_M5307)       := $(call cc-option,-mcpu=5307,-m5200)
-cpuflags-$(CONFIG_M528x)       := $(call cc-option,-mcpu=528x,-m5307)
-cpuflags-$(CONFIG_M5275)       := $(call cc-option,-mcpu=5275,-m5307)
-cpuflags-$(CONFIG_M5272)       := $(call cc-option,-mcpu=5272,-m5307)
-cpuflags-$(CONFIG_M5271)       := $(call cc-option,-mcpu=5271,-m5307)
-cpuflags-$(CONFIG_M523x)       := $(call cc-option,-mcpu=523x,-m5307)
-cpuflags-$(CONFIG_M525x)       := $(call cc-option,-mcpu=5253,-m5200)
-cpuflags-$(CONFIG_M5249)       := $(call cc-option,-mcpu=5249,-m5200)
-cpuflags-$(CONFIG_M520x)       := $(call cc-option,-mcpu=5208,-m5200)
-cpuflags-$(CONFIG_M5206e)      := $(call cc-option,-mcpu=5206e,-m5200)
-cpuflags-$(CONFIG_M5206)       := $(call cc-option,-mcpu=5206,-m5200)
+cpuflags-$(CONFIG_M68030)      =
+cpuflags-$(CONFIG_M68020)      =
+cpuflags-$(CONFIG_M68000)      = -m68000
+cpuflags-$(CONFIG_M5441x)      = $(call cc-option,-mcpu=54455,-mcfv4e)
+cpuflags-$(CONFIG_M54xx)       = $(call cc-option,-mcpu=5475,-m5200)
+cpuflags-$(CONFIG_M5407)       = $(call cc-option,-mcpu=5407,-m5200)
+cpuflags-$(CONFIG_M532x)       = $(call cc-option,-mcpu=532x,-m5307)
+cpuflags-$(CONFIG_M537x)       = $(call cc-option,-mcpu=537x,-m5307)
+cpuflags-$(CONFIG_M5307)       = $(call cc-option,-mcpu=5307,-m5200)
+cpuflags-$(CONFIG_M528x)       = $(call cc-option,-mcpu=528x,-m5307)
+cpuflags-$(CONFIG_M5275)       = $(call cc-option,-mcpu=5275,-m5307)
+cpuflags-$(CONFIG_M5272)       = $(call cc-option,-mcpu=5272,-m5307)
+cpuflags-$(CONFIG_M5271)       = $(call cc-option,-mcpu=5271,-m5307)
+cpuflags-$(CONFIG_M523x)       = $(call cc-option,-mcpu=523x,-m5307)
+cpuflags-$(CONFIG_M525x)       = $(call cc-option,-mcpu=5253,-m5200)
+cpuflags-$(CONFIG_M5249)       = $(call cc-option,-mcpu=5249,-m5200)
+cpuflags-$(CONFIG_M520x)       = $(call cc-option,-mcpu=5208,-m5200)
+cpuflags-$(CONFIG_M5206e)      = $(call cc-option,-mcpu=5206e,-m5200)
+cpuflags-$(CONFIG_M5206)       = $(call cc-option,-mcpu=5206,-m5200)
+
+# Evaluate tune cc-option calls now
+cpuflags-y := $(cpuflags-y)
 
 KBUILD_AFLAGS += $(cpuflags-y)
 KBUILD_CFLAGS += $(cpuflags-y)