From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-16 14:15:11
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 in the powerpc
tree.
Patch 4 takes advatage of a new feature of the kconfig-shell work to
improve powerpc kconfig, so that should instead be merged with the
kbuild tree with an ack from powerpc, after patches 1-3 are merged.
v4 just brings some build fixes to patch 3 (including a change from
patch 4 that belonged in patch 3), and improvemets to changelogs.
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 | 12 +++--
scripts/recordmcount.pl | 18 +++++++-
6 files changed, 67 insertions(+), 55 deletions(-)
--
2.17.0
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-16 14:15:14
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.
Cc: Segher Boessenkool <redacted>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
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-16 14:15:18
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-16 14:15:22
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 these flags
works for this purpose.
Unfortunately that is not compatible with the way the proposed new
Kconfig macro language implementation, which gets confused by the
the $(CC) environment variable changing.
After previous patches in this series, these flags can be carefully
passed in using the usual kbuild flags variables instead.
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Since v3:
- Added 32/64 flags to recordmcount.pl invocation of the toolchain,
similarly to BE/LE. This fixes problems with toolchain default
target bitness != kernel target bitness. I kept Steven's ack
because it's much the same powerpc specific change, okay?
- Added a similar fix for mismatched toolchain default endianness
or bitness to the gcc-check-mprofile-kernel.sh script. This was
pulled in from patch 4 and improved (added comment and endianness
flags).
arch/powerpc/Makefile | 16 +++++++++-------
.../powerpc/tools/gcc-check-mprofile-kernel.sh | 12 ++++++++----
scripts/recordmcount.pl | 18 +++++++++++++++++-
3 files changed, 34 insertions(+), 12 deletions(-)
@@ -7,17 +7,21 @@ set -o pipefail# To debug, uncomment the following line# set -x+# -mprofile-kernel is only supported on 64le, so this should not be invoked+# for other targets. Therefore we can pass in -m64 and -mlittle-endian+# explicitly, to take care of toolchains defaulting to other targets.+# 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|\-grep-q"_mcount"+$*-m64-mlittle-endian-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|\-grep-q"_mcount"&&\+$*-m64-mlittle-endian-S-xc-O2-p-mprofile-kernel--o-\+2>/dev/null|grep-q"_mcount"&&\exit1echo"OK"
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-16 14:15:26
This 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 ]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Since v3:
- Moved a stray hunk back to patch 3 where it belongs.
arch/powerpc/Kconfig | 16 +---------------
arch/powerpc/Makefile | 14 ++------------
2 files changed, 3 insertions(+), 27 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)
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
4421b963 Nicholas Piggin 2018-05-17 @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
2018-05-16 23:14 GMT+09:00 Nicholas Piggin [off-list ref]:
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.
Cc: Segher Boessenkool <redacted>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Can you please remove the noise changes?
1/4 adds some blank lines, then 2/4 removes them.
This blank line will be removed by the next patch.
+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
+
This blank line will be removed by the next patch.
endif
endif
+
This blank line will be removed by the next patch.
export CROSS32CC CROSS32AR
ifeq ($(CROSS_COMPILE),)
--
2.17.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
2018-05-16 23:14 GMT+09:00 Nicholas Piggin [off-list ref]:
quoted hunk
This 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 ]
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Since v3:
- Moved a stray hunk back to patch 3 where it belongs.
arch/powerpc/Kconfig | 16 +---------------
arch/powerpc/Makefile | 14 ++------------
2 files changed, 3 insertions(+), 27 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__)
Your fix-up patch is good,
but could you check my comments below please?
You do not need to compare the returned string with "OK" any more.
Please remove the
echo "OK"
line from the shell script.
- 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
Now, CONFIG_MPROFILE_KERNEL is equivalent to CC_USING_MPROFILE_KERNEL.
If you replace #ifdef CC_USING_MPROFILE_KERNEL
with #ifdef CONFIG_MPROFILE_KERNEL,
you can remove CC_USING_MRPROFILE_KERNEL entirely, right?
endif
CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)
--
2.17.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-30 10:43:57
On Tue, 29 May 2018 22:39:48 +0900
Masahiro Yamada [off-list ref] wrote:
2018-05-16 23:14 GMT+09:00 Nicholas Piggin [off-list ref]:
quoted
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.
Cc: Segher Boessenkool <redacted>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Can you please remove the noise changes?
1/4 adds some blank lines, then 2/4 removes them.