Skip to content

Commit b40b238

Browse files
committed
powerpc/Makefile: Fix ld version check with 64-bit LE-only toolchain
In commit efe0160 ("powerpc/64: Linker on-demand sfpr functions for modules"), we added an ld version check early in the powerpc top-level Makefile. Because the Makefile runs before the kernel config is setup, the checks for CONFIG_CPU_LITTLE_ENDIAN etc. all take the default case. So we end up configuring ld for 32-bit big endian. That would be OK, except that for historical (or perhaps no) reason, we use 'override LD' to add the endian flags to the LD variable itself, rather than the normal approach of adding them to LDFLAGS. The end result is that when we check the ld version we run it as: $(CROSS_COMPILE)ld -EB -m elf32ppc --version This often works, unless you are using a 64-bit only and/or little endian only, toolchain. In which case you see something like: $ make defconfig powerpc64le-linux-ld: unrecognised emulation mode: elf32ppc Supported emulations: elf64lppc elf32lppc elf32lppclinux elf32lppcsim /bin/sh: 1: [: -ge: unexpected operator The proper fix is to stop using 'override LD', but that will require a fair bit of testing. Instead we can fix it for now just by reordering the Makefile to do the version check earlier. Fixes: efe0160 ("powerpc/64: Linker on-demand sfpr functions for modules") Signed-off-by: Michael Ellerman <[email protected]>
1 parent 4fd1bd4 commit b40b238

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

arch/powerpc/Makefile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ machine-$(CONFIG_PPC64) += 64
5959
machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
6060
UTS_MACHINE := $(subst $(space),,$(machine-y))
6161

62+
# XXX This needs to be before we override LD below
63+
ifdef CONFIG_PPC32
64+
KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
65+
else
66+
ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
67+
# Have the linker provide sfpr if possible.
68+
# There is a corresponding test in arch/powerpc/lib/Makefile
69+
KBUILD_LDFLAGS_MODULE += --save-restore-funcs
70+
else
71+
KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
72+
endif
73+
endif
74+
6275
ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
6376
override LD += -EL
6477
LDEMULATION := lppc
@@ -190,18 +203,6 @@ else
190203
CHECKFLAGS += -D__LITTLE_ENDIAN__
191204
endif
192205

193-
ifdef CONFIG_PPC32
194-
KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
195-
else
196-
ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
197-
# Have the linker provide sfpr if possible.
198-
# There is a corresponding test in arch/powerpc/lib/Makefile
199-
KBUILD_LDFLAGS_MODULE += --save-restore-funcs
200-
else
201-
KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
202-
endif
203-
endif
204-
205206
ifeq ($(CONFIG_476FPE_ERR46),y)
206207
KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
207208
-T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds

0 commit comments

Comments
 (0)