kbuild and powerpc patches for new Kconfig language
Nicholas Piggin
reviewerv2 cover kbuild and powerpc patches for new Kconfig language
I came back to these patches and I think I have solved the remaining problems -- it now builds with 64-bit big and little endian (using a le toolchain), and also 32-bit big using 64le toolchain. There might be some build failures still left, but it seems to be in much better shape now.
Reviews would be welcome. I don't quite know how it should be merged, maybe via the kbuild tree after acks from powerpc maintainer. We can decide that after it gets more testing and review.
Thanks,
Nick
Nicholas Piggin (5):
powerpc/kbuild: set default generic machine type for 32-bit compile powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile
kbuild: call cc-option with the current set of KBUILD_CFLAGS powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS powerpc/kbuild: move -mprofile-kernel check to Kconfig
arch/powerpc/Kconfig | 16 +------ arch/powerpc/Makefile | 46 +++++++------------ arch/powerpc/boot/Makefile | 16 +++++-- arch/powerpc/kernel/vdso32/Makefile | 15 ++++-- .../tools/gcc-check-mprofile-kernel.sh | 4 +- scripts/Kbuild.include | 8 ++-- scripts/recordmcount.pl | 8 ++++ 7 files changed, 54 insertions(+), 59 deletions(-)
Signature · 1 line
2.17.0
Nicholas Piggin
reviewerPATCH v2 1/5 powerpc/kbuild: set default generic machine type for 32-bit compile
The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit powerpc machine type and scheduling model. 32-bit platforms and CPUs can override this with -mcpu= options that come later on the command line.
This fixes a lot of build failures due to incompatible assembly when compiling 32-bit kernel with 64-bit toolchain.
--- arch/powerpc/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/Makefile +8 -0
@@ -27,6 +27,14 @@ KBUILD_ARFLAGS += --target=elf32-powerpc endif endif +ifdef CONFIG_PPC32 +# These options will be overridden by any -mcpu option that comes +# later on the command line, but they are needed to set a sane +# 32-bit cpu target for the 64-bit cross compiler. +KBUILD_CFLAGS += -mcpu=powerpc +KBUILD_AFLAGS += -mcpu=powerpc +endif + export CROSS32CC CROSS32AR ifeq ($(CROSS_COMPILE),)
Signature · 1 line
2.17.0
Re: [PATCH v2 1/5] powerpc/kbuild: set default generic machine type for 32-bit compile
Quoted 8 lines · Nicholas Piggin
The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit powerpc machine type and scheduling model. 32-bit platforms and CPUs can override this with -mcpu= options that come later on the command line.
This fixes a lot of build failures due to incompatible assembly when compiling 32-bit kernel with 64-bit toolchain.
So what ISA is set for gas without this patch? With what GCC version? And, why is that wrong?
Segher
Quoted 7 lines
arch/powerpc/Makefile +7
-0+ifdef CONFIG_PPC32 +# These options will be overridden by any -mcpu option that comes +# later on the command line, but they are needed to set a sane +# 32-bit cpu target for the 64-bit cross compiler. +KBUILD_CFLAGS += -mcpu=powerpc +KBUILD_AFLAGS += -mcpu=powerpc +endif
Nicholas Piggin
reviewerRe: [PATCH v2 1/5] powerpc/kbuild: set default generic machine type for 32-bit compile
Quoted 11 lines · On Thu, 10 May 2018 08:10:03 -0500 Segher Boessenkool…
Quoted 8 lines · Nicholas Piggin
The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit powerpc machine type and scheduling model. 32-bit platforms and CPUs can override this with -mcpu= options that come later on the command line.
This fixes a lot of build failures due to incompatible assembly when compiling 32-bit kernel with 64-bit toolchain.
So what ISA is set for gas without this patch? With what GCC version?
I'm not sure, how do I find that out?
Quoted 1 line
And, why is that wrong?
Some 32-bit platforms and CPU types do not provide -mcpu, so I assume for 32-bit toolchains that must result in the "powerpc" machine. With 64-bit toolchains
arch/powerpc/mm/hash_low_32.S:353: Error: missing operand
Which is,
tlbie r4
Is that v2.06?
Thanks,
Nick
Re: [PATCH v2 1/5] powerpc/kbuild: set default generic machine type for 32-bit compile
Quoted 9 lines · Nicholas Piggin
Quoted 7 lines · On Thu, 10 May 2018 08:10:03 -0500 Segher Boessenkool…
Quoted 6 lines · Nicholas Piggin
The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit powerpc machine type and scheduling model. 32-bit platforms and CPUs can override this with -mcpu= options that come later on the command line.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
This fixes a lot of build failures due to incompatible assembly when compiling 32-bit kernel with 64-bit toolchain.
So what ISA is set for gas without this patch? With what GCC version?
I'm not sure, how do I find that out?
gcc --version
gcc -v <rest of command>, look at the command line options passed to as make something.s, look at what .machine is set (if any).
Quoted 4 lines
Quoted 1 line
And, why is that wrong?
Some 32-bit platforms and CPU types do not provide -mcpu, so I assume for 32-bit toolchains that must result in the "powerpc" machine. With
It results in whatever is the default for that toolchain. Depends on many things.
Quoted 9 lines
64-bit toolchains
arch/powerpc/mm/hash_low_32.S:353: Error: missing operandWhich is,
tlbie r4
Is that v2.06?
The original ISA did not have the L field, 2.xx does, for any xx even I think.
Segher
Re: [PATCH v2 1/5] powerpc/kbuild: set default generic machine type for 32-bit compile
In reply to Nicholas PigginQuoted 5 lines · Nicholas Piggin
The 64-bit toolchain uses the wrong ISA variant for compiling 32-bit kernels, eve with -m32. Set -mcpu=powerpc which is the generic 32-bit powerpc machine type and scheduling model. 32-bit platforms and CPUs can override this with -mcpu= options that come later on the command line.
So it turns out your compiler was configured with --with-cpu=power8; it's not that GCC defaults are bad, but who built your compiler overrode the defaults.
If the problem only happens in .S files, it might be better to put .machine directives in those. But your patch should work too, yes.
Segher
Nicholas Piggin
reviewerPATCH v2 2/5 powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile
In reply to Nicholas PigginSwitch VDSO32 build over to use CROSS32_COMPILE directly, and have it pass in -m32 after the standard c_flags. This allows endianness overrides to be removed and the endian and bitness flags moved into standard flags variables.
--- arch/powerpc/Makefile | 12 ------------ arch/powerpc/boot/Makefile | 16 +++++++++++----- arch/powerpc/kernel/vdso32/Makefile | 15 +++++++++++---- 3 files changed, 22 insertions(+), 21 deletions(-)
arch/powerpc/Makefile +0 -12
@@ -17,16 +17,6 @@ HAS_BIARCH := $(call cc-option-yn, -m32) # Set default 32 bits cross compilers for vdso and boot wrapper CROSS32_COMPILE ?= -CROSS32CC := $(CROSS32_COMPILE)gcc -CROSS32AR := $(CROSS32_COMPILE)ar - -ifeq ($(HAS_BIARCH),y) -ifeq ($(CROSS32_COMPILE),) -CROSS32CC := $(CC) -m32 -KBUILD_ARFLAGS += --target=elf32-powerpc -endif -endif - ifdef CONFIG_PPC32 # These options will be overridden by any -mcpu option that comes # later on the command line, but they are needed to set a sane
@@ -35,8 +25,6 @@ KBUILD_CFLAGS += -mcpu=powerpc KBUILD_AFLAGS += -mcpu=powerpc endif -export CROSS32CC CROSS32AR - ifeq ($(CROSS_COMPILE),) KBUILD_DEFCONFIG := $(shell uname -m)_defconfig else
arch/powerpc/boot/Makefile +11 -5
@@ -23,19 +23,23 @@ all: $(obj)/zImage compress-$(CONFIG_KERNEL_GZIP) := CONFIG_KERNEL_GZIP compress-$(CONFIG_KERNEL_XZ) := CONFIG_KERNEL_XZ +ifdef CROSS32_COMPILE + BOOTCC := $(CROSS32_COMPILE)gcc + BOOTAR := $(CROSS32_COMPILE)ar +else + BOOTCC := $(CC) + BOOTAR := $(AR) +endif + BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -Os -msoft-float -pipe \ -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ -D$(compress-y) -BOOTCC := $(CC) ifdef CONFIG_PPC64_BOOT_WRAPPER BOOTCFLAGS += -m64 else BOOTCFLAGS += -m32 -ifdef CROSS32_COMPILE - BOOTCC := $(CROSS32_COMPILE)gcc -endif endif BOOTCFLAGS += -isystem $(shell $(BOOTCC) -print-file-name=include)
@@ -49,6 +53,8 @@ endif BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc +BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) + ifdef CONFIG_DEBUG_INFO BOOTCFLAGS += -g endif
@@ -202,7 +208,7 @@ quiet_cmd_bootas = BOOTAS $@ cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< quiet_cmd_bootar = BOOTAR $@ - cmd_bootar = $(CROSS32AR) -cr$(KBUILD_ARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ + cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ $(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE $(call if_changed_dep,bootcc)
arch/powerpc/kernel/vdso32/Makefile +11 -4
@@ -8,8 +8,15 @@ obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o \ # Build rules -ifeq ($(CONFIG_PPC32),y) -CROSS32CC := $(CC) +ifdef CROSS32_COMPILE + VDSOCC := $(CROSS32_COMPILE)gcc +else + VDSOCC := $(CC) +endif + +CC32FLAGS := +ifdef CONFIG_PPC64 +CC32FLAGS += -m32 endif targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
@@ -45,9 +52,9 @@ $(obj-vdso32): %.o: %.S FORCE # actual build commands quiet_cmd_vdso32ld = VDSO32L $@ - cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) + cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) quiet_cmd_vdso32as = VDSO32A $@ - cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $< + cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< # install commands for the unstripped file quiet_cmd_vdso_install = INSTALL $@
Signature · 1 line
2.17.0
Nicholas Piggin
reviewerPATCH v2 3/5 kbuild: call cc-option with the current set of KBUILD_CFLAGS
In reply to Nicholas PigginIn some cases, the options that gcc will accept depend on options it has already been given. For example -m32 / -m64 and -mbig-endian / -mlittle-endian can have this affect.
Passing in KBUILD_CFLAGS to cc-option allows an architecture to set such basic machine types at the beginning, rather than override CC itself.
--- scripts/Kbuild.include | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/Kbuild.include +4 -4
@@ -121,7 +121,7 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) cc-option = $(call __cc-option, $(CC),\ - $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) + $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) # hostcc-option # Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)
@@ -131,12 +131,12 @@ hostcc-option = $(call __cc-option, $(HOSTCC),\ # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) # cc-disable-warning # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) cc-disable-warning = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) + $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) # cc-name # Expands to either gcc or clang
@@ -160,7 +160,7 @@ cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo # cc-ldoption # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) cc-ldoption = $(call try-run,\ - $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) + $(CC) $(1) $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) # ld-option # Usage: LDFLAGS += $(call ld-option, -X)
Signature · 1 line
2.17.0
Re: [PATCH v2 3/5] kbuild: call cc-option with the current set of KBUILD_CFLAGS
2018-05-10 14:16 GMT+09:00 Nicholas Piggin <[email protected]>:
Quoted 3 lines
In some cases, the options that gcc will accept depend on options it has already been given. For example -m32 / -m64 and -mbig-endian / -mlittle-endian can have this affect.
Is cc-option not working for you?
Quoted 3 lines
Passing in
KBUILD_CFLAGSto cc-option allows an architecture to set such basic machine types at the beginning, rather than override CC itself.
KBUILD_CFLAGS is passed to cc-option already
because CC_OPTION_CFLAGS includes it:
CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
This patch drops KBUILD_CPPFLAGS,
and adds KBUILD_CFLAGS twice, doesn't it?
Quoted 49 lines
Signed-off-by Nicholas Piggin <[email protected]>--- scripts/Kbuild.include | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)scripts/Kbuild.include +4
-5@@ -121,7 +121,7 @@ CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) cc-option = $(call __cc-option, $(CC),\ - $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) + $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) # hostcc-option # Usage: cflags-y += $(call hostcc-option,-march=winchip-c6,-march=i586)@@ -131,12 +131,12 @@ hostcc-option = $(call __cc-option, $(HOSTCC),\ # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) # cc-disable-warning # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) cc-disable-warning = $(call try-run,\ - $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) + $(CC) -Werror $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) # cc-name # Expands to either gcc or clang@@ -160,7 +160,7 @@ cc-if-fullversion = $(shell [ $(cc-fullversion) $(1) $(2) ] && echo $(3) || echo # cc-ldoption # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) cc-ldoption = $(call try-run,\ - $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) + $(CC) $(1) $(KBUILD_CFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2)) # ld-option # Usage: LDFLAGS += $(call ld-option, -X) --2.17.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Best Regards Masahiro Yamada
Nicholas Piggin
reviewerRe: [PATCH v2 3/5] kbuild: call cc-option with the current set of KBUILD_CFLAGS
Quoted 6 lines · On Thu, 10 May 2018 14:29:49 +0900 Masahiro Yamada…
2018-05-10 14:16 GMT+09:00 Nicholas Piggin <[email protected]>:
Quoted 3 lines
In some cases, the options that gcc will accept depend on options it has already been given. For example -m32 / -m64 and -mbig-endian / -mlittle-endian can have this affect.
Is cc-option not working for you?
I thought it wasn't, but now I try again and it does work, sorry for the noise. The bug must have been something in my previous series. This series seems to work just as well after I remove this patch.
Thanks,
Nick
Nicholas Piggin
reviewerPATCH v2 4/5 powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
In reply to Nicholas PigginThe powerpc toolchain can compile combinations of 32/64 bit and big/little endian, so it's convenient to consider, e.g.,
CC -m64 -mbig-endian
To be the C compiler for the purpose of invoking it to build target artifacts. So overriding the the CC variable to include thse flags works for this purpose.
Unfortunately that is not compatible with the way the proposed new Kconfig macro language will work.
After previous patches in this series, these flags can be carefully passed in using flags instead.
--- arch/powerpc/Makefile | 16 +++++++++------- scripts/recordmcount.pl | 8 ++++++++ 2 files changed, 17 insertions(+), 7 deletions(-)
arch/powerpc/Makefile +9 -7
@@ -70,13 +70,15 @@ endif endif ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) -override LD += -EL +KBUILD_CFLAGS += -mlittle-endian +LDFLAGS += -EL LDEMULATION := lppc GNUTARGET := powerpcle MULTIPLEWORD := -mno-multiple KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) else -override LD += -EB +KBUILD_CFLAGS += $(call cc-option,-mbig-endian) +LDFLAGS += -EB LDEMULATION := ppc GNUTARGET := powerpc MULTIPLEWORD := -mmultiple
@@ -89,19 +91,19 @@ aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 endif -cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian -cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) ifneq ($(cc-name),clang) cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align endif +cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) +cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ifeq ($(HAS_BIARCH),y) -override AS += -a$(BITS) -override LD += -m elf$(BITS)$(LDEMULATION) -override CC += -m$(BITS) +KBUILD_CFLAGS += -m$(BITS) +KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) +LDFLAGS += -m elf$(BITS)$(LDEMULATION) KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) endif
scripts/recordmcount.pl +8 -0
@@ -274,6 +274,14 @@ if ($arch eq "x86_64") { if ($bits == 64) { $type = ".quad"; } + $ld .= " -EB "; + if ($endian eq "big") { + $cc .= " -mbig-endian "; + $ld .= " -EB "; + } else { + $cc .= " -mlittle-endian "; + $ld .= " -EL "; + } } elsif ($arch eq "arm") { $alignment = 2;
Signature · 1 line
2.17.0
Michael Ellerman
reviewerRe: [PATCH v2 4/5] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
Quoted 12 lines · Nicholas Piggin
The powerpc toolchain can compile combinations of 32/64 bit and big/little endian, so it's convenient to consider, e.g.,
CC -m64 -mbig-endianTo be the C compiler for the purpose of invoking it to build target artifacts. So overriding the the CC variable to include thse flags works for this purpose.
Unfortunately that is not compatible with the way the proposed new
Kconfigmacro language will work.
Quoted 7 lines
After previous patches in this series, these flags can be carefully passed in using flags instead.
Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Makefile | 16 +++++++++------- scripts/recordmcount.pl | 8 ++++++++
We should probably at least Cc Rostedt on the recordmcount.pl change.
scripts/recordmcount.pl if ($arch eq "x86_64") {
Quoted 5 lines
scripts/recordmcount.pl +0
-0@@ -274,6 +274,14 @@ if ($arch eq "x86_64") {
Despite what the above says you're patching the powerpc entry AFAICS, so I guess that's pretty harmless.
scripts/recordmcount.pl if ($arch eq "x86_64") { · line 280
Quoted 7 lines
scripts/recordmcount.pl +4
-0if ($bits == 64) { $type = ".quad"; } + $ld .= " -EB "; + if ($endian eq "big") { + $cc .= " -mbig-endian "; + $ld .= " -EB ";
Don't we end up with two "-EB"s for the big endian case?
Or do I understand perl even less than I thought I did?
scripts/recordmcount.pl if ($arch eq "x86_64") { · line 287
Quoted 7 lines
scripts/recordmcount.pl +4
-0+ } else { + $cc .= " -mlittle-endian "; + $ld .= " -EL "; + } } elsif ($arch eq "arm") { $alignment = 2;
cheers
Nicholas Piggin
reviewerRe: [PATCH v2 4/5] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
Quoted 17 lines · On Thu, 10 May 2018 23:03:08 +1000 Michael Ellerman <[email protected]> wrote:
Quoted 15 lines · Nicholas Piggin
The powerpc toolchain can compile combinations of 32/64 bit and big/little endian, so it's convenient to consider, e.g.,
CC -m64 -mbig-endianTo be the C compiler for the purpose of invoking it to build target artifacts. So overriding the the CC variable to include thse flags works for this purpose.
Unfortunately that is not compatible with the way the proposed new
Kconfigmacro language will work.After previous patches in this series, these flags can be carefully passed in using flags instead.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Makefile | 16 +++++++++------- scripts/recordmcount.pl | 8 ++++++++We should probably at least Cc Rostedt on the recordmcount.pl change.
Sure I'll send another iteration after some more time for reviews and cc him on it.
Quoted 9 lines
scripts/recordmcount.pl if ($arch eq "x86_64") {
Quoted 6 lines
scripts/recordmcount.pl +0
-0@@ -274,6 +274,14 @@ if ($arch eq "x86_64") {Despite what the above says you're patching the powerpc entry AFAICS, so I guess that's pretty harmless.
Yeah I didn't think it was worth a separate patch.
Quoted 11 lines
scripts/recordmcount.pl if ($arch eq "x86_64") { · line 280
Quoted 8 lines
scripts/recordmcount.pl +4
-0if ($bits == 64) { $type = ".quad"; } + $ld .= " -EB "; + if ($endian eq "big") { + $cc .= " -mbig-endian "; + $ld .= " -EB ";Don't we end up with two "-EB"s for the big endian case?
Quoted 1 line
Or do I understand perl even less than I thought I did?
No I was testing things and that's leaked into the commit. Good eye. I think it worked for le because the next -EL will override the first -EB, but I'll take that out.
Thanks,
Nick
Nicholas Piggin
reviewerPATCH v2 5/5 powerpc/kbuild: move -mprofile-kernel check to Kconfig
In reply to Nicholas PigginThis eliminates the workaround that requires disabling -mprofile-kernel by default in Kconfig.
[ Note: this depends on https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git kconfig-shell-v3 ]
--- arch/powerpc/Kconfig | 16 +--------------- arch/powerpc/Makefile | 14 ++------------ arch/powerpc/tools/gcc-check-mprofile-kernel.sh | 4 ++-- 3 files changed, 5 insertions(+), 29 deletions(-)
arch/powerpc/Kconfig +1 -15
@@ -460,23 +460,9 @@ config LD_HEAD_STUB_CATCH If unsure, say "N". -config DISABLE_MPROFILE_KERNEL - bool "Disable use of mprofile-kernel for kernel tracing" - depends on PPC64 && CPU_LITTLE_ENDIAN - default y - help - Selecting this options disables use of the mprofile-kernel ABI for - kernel tracing. That will cause options such as live patching - (CONFIG_LIVEPATCH) which depend on CONFIG_DYNAMIC_FTRACE_WITH_REGS to - be disabled also. - - If you have a toolchain which supports mprofile-kernel, then you can - disable this. Otherwise leave it enabled. If you're not sure, say - "Y". - config MPROFILE_KERNEL depends on PPC64 && CPU_LITTLE_ENDIAN - def_bool !DISABLE_MPROFILE_KERNEL + def_bool $(success $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__) config IOMMU_HELPER def_bool PPC64
arch/powerpc/Makefile +2 -12
@@ -156,18 +156,8 @@ CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64 endif ifdef CONFIG_MPROFILE_KERNEL - ifeq ($(shell $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__),OK) - CC_FLAGS_FTRACE := -pg -mprofile-kernel - KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL - else - # If the user asked for mprofile-kernel but the toolchain doesn't - # support it, emit a warning and deliberately break the build later - # with mprofile-kernel-not-supported. We would prefer to make this an - # error right here, but then the user would never be able to run - # oldconfig to change their configuration. - $(warning Compiler does not support mprofile-kernel, set CONFIG_DISABLE_MPROFILE_KERNEL) - CC_FLAGS_FTRACE := -mprofile-kernel-not-supported - endif + CC_FLAGS_FTRACE := -pg -mprofile-kernel + KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL endif CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)
arch/powerpc/tools/gcc-check-mprofile-kernel.sh +2 -2
@@ -10,13 +10,13 @@ set -o pipefail # Test whether the compile option -mprofile-kernel exists and generates # profiling code (ie. a call to _mcount()). echo "int func() { return 0; }" | \ - $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ + $* -m64 -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ grep -q "_mcount" # Test whether the notrace attribute correctly suppresses calls to _mcount(). echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \ - $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ + $* -m64 -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \ grep -q "_mcount" && \ exit 1
Signature · 1 line
2.17.0