From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-14 03:52:45
This series of patches improves th powerpc kbuild system. The
motivation was to to be compatible with the new Kconfig scripting
language that Yamada-san has proposed here:
https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/?h=kconfig-shell-v3
I have tested on top of that tree and powerpc now builds there.
I think patches 1-3 are improvements to the build system even before
kconfig-shell, so they could be merged ahead of it.
Patch 4 actually takes advatage of a new feature of the kconfig-shell
changes to improve powerpc kconfig, so that should rather be merged
with the kbuild tree with an ack from powerpc. Yamada-san are you
planning to merge kconfig-shell for 4.17?
Thanks,
Nick
Nicholas Piggin (4):
powerpc/kbuild: set default generic machine type for 32-bit compile
powerpc/kbuild: remove CROSS32 defines from top level powerpc Makefile
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 | 45 ++++++++-----------
arch/powerpc/boot/Makefile | 16 ++++---
arch/powerpc/kernel/vdso32/Makefile | 15 +++++--
.../tools/gcc-check-mprofile-kernel.sh | 4 +-
scripts/recordmcount.pl | 7 +++
6 files changed, 51 insertions(+), 52 deletions(-)
--
2.17.0
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-14 03:52:48
Some 64-bit toolchains uses the wrong ISA variant for compiling 32-bit
kernels, even with -m32. Debian's powerpc64le is one such case, and
that is because it is built with --with-cpu=power8.
So when cross compiling a 32-bit kernel with a 64-bit toolchain, set
-mcpu=powerpc initially, which is the generic 32-bit powerpc machine
type and scheduling model. CPU and platform code can override this
with subsequent -mcpu flags if necessary.
This is not done for 32-bit toolchains otherwise it would override
their defaults, which are presumably set appropriately for the
environment (moreso than a 64-bit cross compiler).
This fixes a lot of build failures due to incompatible assembly when
compiling 32-bit kernel with th Debian powerpc64le 64-bit toolchain.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Since v2:
- reworded changelog to explain the cause of the problem,
(thanks Segher).
- moved the flags into the 64-32 cross compile case so as not to
disturb native 32-bit builds.
arch/powerpc/Makefile | 11 +++++++++++
1 file changed, 11 insertions(+)
@@ -24,9 +24,20 @@ ifeq ($(HAS_BIARCH),y)ifeq ($(CROSS32_COMPILE),)CROSS32CC:=$(CC)-m32KBUILD_ARFLAGS+=--target=elf32-powerpc++ifdef CONFIG_PPC32+# These options will be overridden by any -mcpu option that the CPU+# or platform code sets later on the command line, but they are needed+# to set a sane 32-bit cpu target for the 64-bit cross compiler which+# may default to the wrong ISA.+KBUILD_CFLAGS+=-mcpu=powerpc+KBUILD_AFLAGS+=-mcpu=powerpc+endif+endifendif+exportCROSS32CCCROSS32ARifeq ($(CROSS_COMPILE),)
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-14 03:52:52
Switch 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.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Makefile | 10 ----------
arch/powerpc/boot/Makefile | 16 +++++++++++-----
arch/powerpc/kernel/vdso32/Makefile | 15 +++++++++++----
3 files changed, 22 insertions(+), 19 deletions(-)
@@ -17,14 +17,8 @@ HAS_BIARCH := $(call cc-option-yn, -m32)# Set default 32 bits cross compilers for vdso and boot wrapperCROSS32_COMPILE?=-CROSS32CC:=$(CROSS32_COMPILE)gcc-CROSS32AR:=$(CROSS32_COMPILE)ar-ifeq ($(HAS_BIARCH),y)ifeq ($(CROSS32_COMPILE),)-CROSS32CC:=$(CC)-m32-KBUILD_ARFLAGS+=--target=elf32-powerpc-ifdef CONFIG_PPC32# These options will be overridden by any -mcpu option that the CPU# or platform code sets later on the command line, but they are needed
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-14 03:52:56
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-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.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Since v2:
- removed extra -EB in the recordmcount script (thanks mpe)
arch/powerpc/Makefile | 16 +++++++++-------
scripts/recordmcount.pl | 7 +++++++
2 files changed, 16 insertions(+), 7 deletions(-)
@@ -460,23 +460,9 @@ config LD_HEAD_STUB_CATCHIfunsure,say"N".-configDISABLE_MPROFILE_KERNEL-bool"Disable use of mprofile-kernel for kernel tracing"-depends onPPC64&&CPU_LITTLE_ENDIAN-defaulty-help-Selectingthisoptionsdisablesuseofthemprofile-kernelABIfor-kerneltracing.Thatwillcauseoptionssuchaslivepatching-(CONFIG_LIVEPATCH)whichdependonCONFIG_DYNAMIC_FTRACE_WITH_REGSto-bedisabledalso.--Ifyouhaveatoolchainwhichsupportsmprofile-kernel,thenyoucan-disablethis.Otherwiseleaveitenabled.Ifyou'renotsure,say-"Y".-configMPROFILE_KERNELdepends onPPC64&&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__)configIOMMU_HELPERdef_boolPPC64
@@ -161,18 +161,8 @@ CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64endififdef 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.-$(warningCompilerdoesnotsupportmprofile-kernel,setCONFIG_DISABLE_MPROFILE_KERNEL)-CC_FLAGS_FTRACE:=-mprofile-kernel-not-supported- endif+CC_FLAGS_FTRACE:=-pg-mprofile-kernel+KBUILD_CPPFLAGS+=-DCC_USING_MPROFILE_KERNELendifCFLAGS-$(CONFIG_CELL_CPU)+=$(callcc-option,-mcpu=cell)
@@ -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-xc-O2-p-mprofile-kernel--o-2>/dev/null|\+$*-m64-S-xc-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-xc-O2-p-mprofile-kernel--o-2>/dev/null|\+$*-m64-S-xc-O2-p-mprofile-kernel--o-2>/dev/null|\grep-q"_mcount"&&\exit1
arch/powerpc/Kconfig:467:warning: ignoring unsupported character '$'
arch/powerpc/Kconfig:467:warning: ignoring unsupported character '$'
quoted
arch/powerpc/Kconfig:467: invalid option
make[2]: *** [olddefconfig] Error 1
make[2]: Target 'oldnoconfig' not remade because of errors.
make[1]: *** [oldnoconfig] Error 2
make: *** [sub-make] Error 2
vim +468 arch/powerpc/Kconfig
e05c0e81 Kevin Hao 2013-07-16 443
3d72bbc4 Michael Neuling 2013-02-13 444 config PPC_TRANSACTIONAL_MEM
3d72bbc4 Michael Neuling 2013-02-13 445 bool "Transactional Memory support for POWERPC"
3d72bbc4 Michael Neuling 2013-02-13 446 depends on PPC_BOOK3S_64
3d72bbc4 Michael Neuling 2013-02-13 447 depends on SMP
7b37a123 Michael Neuling 2014-01-08 448 select ALTIVEC
7b37a123 Michael Neuling 2014-01-08 449 select VSX
3d72bbc4 Michael Neuling 2013-02-13 450 default n
3d72bbc4 Michael Neuling 2013-02-13 451 ---help---
3d72bbc4 Michael Neuling 2013-02-13 452 Support user-mode Transactional Memory on POWERPC.
3d72bbc4 Michael Neuling 2013-02-13 453
951eedeb Nicholas Piggin 2017-05-29 454 config LD_HEAD_STUB_CATCH
951eedeb Nicholas Piggin 2017-05-29 455 bool "Reserve 256 bytes to cope with linker stubs in HEAD text" if EXPERT
951eedeb Nicholas Piggin 2017-05-29 456 depends on PPC64
951eedeb Nicholas Piggin 2017-05-29 457 default n
951eedeb Nicholas Piggin 2017-05-29 458 help
951eedeb Nicholas Piggin 2017-05-29 459 Very large kernels can cause linker branch stubs to be generated by
951eedeb Nicholas Piggin 2017-05-29 460 code in head_64.S, which moves the head text sections out of their
951eedeb Nicholas Piggin 2017-05-29 461 specified location. This option can work around the problem.
951eedeb Nicholas Piggin 2017-05-29 462
951eedeb Nicholas Piggin 2017-05-29 463 If unsure, say "N".
951eedeb Nicholas Piggin 2017-05-29 464
8c50b72a Torsten Duwe 2016-03-03 465 config MPROFILE_KERNEL
8c50b72a Torsten Duwe 2016-03-03 466 depends on PPC64 && CPU_LITTLE_ENDIAN
53561d2c Nicholas Piggin 2018-05-14 @467 def_bool $(success $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
8c50b72a Torsten Duwe 2016-03-03 @468
:::::: The code at line 468 was first introduced by commit
:::::: 8c50b72a3b4f1f7cdfdfebd233b1cbd121262e65 powerpc/ftrace: Add Kconfig & Make glue for mprofile-kernel
:::::: TO: Torsten Duwe [off-list ref]
:::::: CC: Michael Ellerman [off-list ref]
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
From: Steven Rostedt <rostedt@goodmis.org> Date: 2018-05-14 15:28:30
On Mon, 14 May 2018 13:52:27 +1000
Nicholas Piggin [off-list ref] wrote:
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-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
the these
quoted hunk
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.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Since v2:
- removed extra -EB in the recordmcount script (thanks mpe)
arch/powerpc/Makefile | 16 +++++++++-------
scripts/recordmcount.pl | 7 +++++++
2 files changed, 16 insertions(+), 7 deletions(-)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-15 05:24:21
Steven Rostedt [off-list ref] writes:
On Mon, 14 May 2018 13:52:27 +1000
Nicholas Piggin [off-list ref] wrote:
quoted
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-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
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-15 06:16:37
On Tue, 15 May 2018 15:24:21 +1000
Michael Ellerman [off-list ref] wrote:
Steven Rostedt [off-list ref] writes:
quoted
On Mon, 14 May 2018 13:52:27 +1000
Nicholas Piggin [off-list ref] wrote:
quoted
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-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
From: Steven Rostedt <rostedt@goodmis.org> Date: 2018-05-15 14:43:28
On Tue, 15 May 2018 15:24:21 +1000
Michael Ellerman [off-list ref] wrote:
quoted
Have you tried building all current archs with function tracing enabled
to make sure this doesn't break any of them? I can do it if you want.
We shouldn't need to should we? This is only touching powerpc specific
code (if I understand perl that is).
eg:
$ git diff -U9 scripts/recordmcount.pl
Thanks for the added context!
Yeah, I don't look at that code much anymore since I mainly deal with
recordmcount.c now-a-days. I wonder if someone should port ppc to that.
It is also no my todo list to merge that with objtool.
Anyway,
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-- Steve
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-16 02:38:03
Steven Rostedt [off-list ref] writes:
On Tue, 15 May 2018 15:24:21 +1000
Michael Ellerman [off-list ref] wrote:
quoted
quoted
Have you tried building all current archs with function tracing enabled
to make sure this doesn't break any of them? I can do it if you want.
We shouldn't need to should we? This is only touching powerpc specific
code (if I understand perl that is).
eg:
$ git diff -U9 scripts/recordmcount.pl
Thanks for the added context!
Yeah, I don't look at that code much anymore since I mainly deal with
recordmcount.c now-a-days. I wonder if someone should port ppc to that.
Ah right. I didn't realise they were mutually exclusive. I'll add a TODO
for us to port over to the C version.
It is also no my todo list to merge that with objtool.
Anyway,
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>