* [PATCH v2] powerpc/32: Avoid unsupported flags with clang
@ 2018-11-12 5:28 Joel Stanley
2018-11-12 18:59 ` Nick Desaulniers
2018-12-22 9:55 ` [v2] " Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Joel Stanley @ 2018-11-12 5:28 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Nick Desaulniers
When building for ppc32 with clang these flags are unsupported:
-ffixed-r2 and -mmultiple
llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on
when building for SVR4ABI and !ppc64:
// The SVR4 ABI reserves r2 and r13
if (Subtarget.isSVR4ABI()) {
// We only reserve r2 if we need to use the TOC pointer. If we have no
// explicit uses of the TOC pointer (meaning we're a leaf function with
// no constant-pool loads, etc.) and we have no potential uses inside an
// inline asm block, then we can treat r2 has an ordinary callee-saved
// register.
const PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
markSuperRegs(Reserved, PPC::R2); // System-reserved register
markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
}
This means we can safely omit -ffixed-r2 when building for 32-bit
targets.
The -mmultiple/-mno-multiple flags are not supported by clang, so
platforms that might support multiple miss out on using multiple word
instructions.
We wrap these flags in cc-option so that when Clang gains support the
kernel will be able use these flags.
Clang 8 can then build a ppc44x_defconfig which boots in Qemu:
make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- ppc44x_defconfig
./scripts/config -e CONFIG_DEVTMPFS -d DEVTMPFS_MOUNT
make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
qemu-system-ppc -M bamboo \
-kernel arch/powerpc/boot/zImage \
-dtb arch/powerpc/boot/dts/bamboo.dtb \
-initrd ~/ppc32-440-rootfs.cpio \
-nographic -serial stdio -monitor pty -append "console=ttyS0"
Link: https://github.com/ClangBuiltLinux/linux/issues/261
Link: https://bugs.llvm.org/show_bug.cgi?id=39556
Link: https://bugs.llvm.org/show_bug.cgi?id=39555
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
arch/powerpc/Makefile | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 8a2ce14d68d0..4685671dfb4f 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -152,7 +152,14 @@ endif
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
-CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
+# Clang unconditionally reserves r2 on ppc32 and does not support the flag
+# https://bugs.llvm.org/show_bug.cgi?id=39555
+CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2)
+
+# Clang doesn't support -mmultiple / -mno-multiple
+# https://bugs.llvm.org/show_bug.cgi?id=39556
+CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
+
CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
ifdef CONFIG_PPC_BOOK3S_64
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] powerpc/32: Avoid unsupported flags with clang
2018-11-12 5:28 [PATCH v2] powerpc/32: Avoid unsupported flags with clang Joel Stanley
@ 2018-11-12 18:59 ` Nick Desaulniers
2018-12-22 9:55 ` [v2] " Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2018-11-12 18:59 UTC (permalink / raw)
To: joel; +Cc: linuxppc-dev
On Sun, Nov 11, 2018 at 9:28 PM Joel Stanley <joel@jms.id.au> wrote:
>
> When building for ppc32 with clang these flags are unsupported:
>
> -ffixed-r2 and -mmultiple
>
> llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on
> when building for SVR4ABI and !ppc64:
>
> // The SVR4 ABI reserves r2 and r13
> if (Subtarget.isSVR4ABI()) {
> // We only reserve r2 if we need to use the TOC pointer. If we have no
> // explicit uses of the TOC pointer (meaning we're a leaf function with
> // no constant-pool loads, etc.) and we have no potential uses inside an
> // inline asm block, then we can treat r2 has an ordinary callee-saved
> // register.
> const PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
> if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
> markSuperRegs(Reserved, PPC::R2); // System-reserved register
> markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
> }
>
> This means we can safely omit -ffixed-r2 when building for 32-bit
> targets.
>
> The -mmultiple/-mno-multiple flags are not supported by clang, so
> platforms that might support multiple miss out on using multiple word
> instructions.
>
> We wrap these flags in cc-option so that when Clang gains support the
> kernel will be able use these flags.
>
> Clang 8 can then build a ppc44x_defconfig which boots in Qemu:
>
> make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- ppc44x_defconfig
> ./scripts/config -e CONFIG_DEVTMPFS -d DEVTMPFS_MOUNT
> make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
>
> qemu-system-ppc -M bamboo \
> -kernel arch/powerpc/boot/zImage \
> -dtb arch/powerpc/boot/dts/bamboo.dtb \
> -initrd ~/ppc32-440-rootfs.cpio \
> -nographic -serial stdio -monitor pty -append "console=ttyS0"
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/261
> Link: https://bugs.llvm.org/show_bug.cgi?id=39556
> Link: https://bugs.llvm.org/show_bug.cgi?id=39555
> Signed-off-by: Joel Stanley <joel@jms.id.au>
Hopefully we can get these fixed up soon for you, thanks Joel!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> arch/powerpc/Makefile | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 8a2ce14d68d0..4685671dfb4f 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -152,7 +152,14 @@ endif
> CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
> CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
>
> -CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
> +# Clang unconditionally reserves r2 on ppc32 and does not support the flag
> +# https://bugs.llvm.org/show_bug.cgi?id=39555
> +CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2)
> +
> +# Clang doesn't support -mmultiple / -mno-multiple
> +# https://bugs.llvm.org/show_bug.cgi?id=39556
> +CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
> +
> CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
>
> ifdef CONFIG_PPC_BOOK3S_64
> --
> 2.19.1
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [v2] powerpc/32: Avoid unsupported flags with clang
2018-11-12 5:28 [PATCH v2] powerpc/32: Avoid unsupported flags with clang Joel Stanley
2018-11-12 18:59 ` Nick Desaulniers
@ 2018-12-22 9:55 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2018-12-22 9:55 UTC (permalink / raw)
To: Joel Stanley, linuxppc-dev; +Cc: Nick Desaulniers
On Mon, 2018-11-12 at 05:28:06 UTC, Joel Stanley wrote:
> When building for ppc32 with clang these flags are unsupported:
>
> -ffixed-r2 and -mmultiple
>
> llvm's lib/Target/PowerPC/PPCRegisterInfo.cpp marks r2 as reserved on
> when building for SVR4ABI and !ppc64:
>
> // The SVR4 ABI reserves r2 and r13
> if (Subtarget.isSVR4ABI()) {
> // We only reserve r2 if we need to use the TOC pointer. If we have no
> // explicit uses of the TOC pointer (meaning we're a leaf function with
> // no constant-pool loads, etc.) and we have no potential uses inside an
> // inline asm block, then we can treat r2 has an ordinary callee-saved
> // register.
> const PPCFunctionInfo *FuncInfo = MF.getInfo<PPCFunctionInfo>();
> if (!TM.isPPC64() || FuncInfo->usesTOCBasePtr() || MF.hasInlineAsm())
> markSuperRegs(Reserved, PPC::R2); // System-reserved register
> markSuperRegs(Reserved, PPC::R13); // Small Data Area pointer register
> }
>
> This means we can safely omit -ffixed-r2 when building for 32-bit
> targets.
>
> The -mmultiple/-mno-multiple flags are not supported by clang, so
> platforms that might support multiple miss out on using multiple word
> instructions.
>
> We wrap these flags in cc-option so that when Clang gains support the
> kernel will be able use these flags.
>
> Clang 8 can then build a ppc44x_defconfig which boots in Qemu:
>
> make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- ppc44x_defconfig
> ./scripts/config -e CONFIG_DEVTMPFS -d DEVTMPFS_MOUNT
> make CC=clang-8 ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
>
> qemu-system-ppc -M bamboo \
> -kernel arch/powerpc/boot/zImage \
> -dtb arch/powerpc/boot/dts/bamboo.dtb \
> -initrd ~/ppc32-440-rootfs.cpio \
> -nographic -serial stdio -monitor pty -append "console=ttyS0"
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/261
> Link: https://bugs.llvm.org/show_bug.cgi?id=39556
> Link: https://bugs.llvm.org/show_bug.cgi?id=39555
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/72e7bcc2cdf82bf03caaa5e6c9b013
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-22 11:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-12 5:28 [PATCH v2] powerpc/32: Avoid unsupported flags with clang Joel Stanley
2018-11-12 18:59 ` Nick Desaulniers
2018-12-22 9:55 ` [v2] " Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).