From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-10 05:17:12
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(-)
--
2.17.0
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-10 05:17:15
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.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Makefile | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -27,6 +27,14 @@ KBUILD_ARFLAGS += --target=elf32-powerpcendifendif+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+exportCROSS32CCCROSS32ARifeq ($(CROSS_COMPILE),)
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-10 05:17: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 | 12 ------------
arch/powerpc/boot/Makefile | 16 +++++++++++-----
arch/powerpc/kernel/vdso32/Makefile | 15 +++++++++++----
3 files changed, 22 insertions(+), 21 deletions(-)
@@ -17,16 +17,6 @@ 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-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
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-10 05:17:21
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.
Passing in KBUILD_CFLAGS to cc-option allows an architecture to
set such basic machine types at the beginning, rather than override
CC itself.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
scripts/Kbuild.include | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-10 05:17:24
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>
---
arch/powerpc/Makefile | 16 +++++++++-------
scripts/recordmcount.pl | 8 ++++++++
2 files changed, 17 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
@@ -156,18 +156,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
2018-05-10 14:16 GMT+09:00 Nicholas Piggin [off-list ref]:
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?
Passing in KBUILD_CFLAGS to 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?
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-10 06:09:49
On Thu, 10 May 2018 14:29:49 +0900
Masahiro Yamada [off-list ref] wrote:
2018-05-10 14:16 GMT+09:00 Nicholas Piggin [off-list ref]:
quoted
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
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2018-05-10 13:03:13
Nicholas Piggin [off-list ref] writes:
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>
---
arch/powerpc/Makefile | 16 +++++++++-------
scripts/recordmcount.pl | 8 ++++++++
We should probably at least Cc Rostedt on the recordmcount.pl change.
On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
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
+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
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-10 13:11:51
On Thu, 10 May 2018 23:03:08 +1000
Michael Ellerman [off-list ref] wrote:
Nicholas Piggin [off-list ref] writes:
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
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>
---
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.
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?
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
From: Nicholas Piggin <npiggin@gmail.com> Date: 2018-05-10 13:24:57
On Thu, 10 May 2018 08:10:03 -0500
Segher Boessenkool [off-list ref] wrote:
On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
quoted
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?
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
On Thu, May 10, 2018 at 11:24:40PM +1000, Nicholas Piggin wrote:
On Thu, 10 May 2018 08:10:03 -0500
Segher Boessenkool [off-list ref] wrote:
quoted
On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
quoted
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?
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
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.
64-bit toolchains
arch/powerpc/mm/hash_low_32.S:353: Error: missing operand
Which 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
On Thu, May 10, 2018 at 03:16:55PM +1000, Nicholas Piggin wrote:
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