Build of arm32_v6 kernel with integrated-as enabled failing:
clang: warning: argument unused during compilation: '-mfpu=vfp' [-Wunused-command-line-argument]
clang: error: the clang compiler does not support '-Wa,-mfpu=softvfp+vfp'
cc @jcai19 . I wonder what softvfp vs vfp is? Does Clang support either in isolation? (Maybe one is missing, or the + syntax is unsupported?
-Wa,-mfpu=softvfp+vfp is appended to AFLAGS here:
https://github.com/ClangBuiltLinux/linux/blob/9c7db5004280767566e91a33445bf93aa479ef02/arch/arm/vfp/Makefile#L11
That should use += rather than :=$(KBUILD_AFLAGS:.
The softvfp+vfp argument is reminiscent of Arm's old proprietary compiler armcc I'll double check tomorrow but I'm pretty sure it will be the equivalent of the compiler option -mfloat-abi=softfp in other words permit use of floating point, but use integer registers to pass floating point parameters. For the assembler this doesn't mean a lot as it is up to the programmer to conform to the procedure call standard, what this might do is set the appropriate build attribute which declares that the file is softfp.
The manual page for armcc on the meaning of softvfp+vfp http://infocenter.arm.com/help/topic/com.arm.doc.dui0472m/chr1359124920656.html
The softvfp+vfp argument is reminiscent of Arm's old proprietary compiler armcc I'll double check tomorrow but I'm pretty sure it will be the equivalent of the compiler option -mfloat-abi=softfp in other words permit use of floating point, but use integer registers to pass floating point parameters. For the assembler this doesn't mean a lot as it is up to the programmer to conform to the procedure call standard, what this might do is set the appropriate build attribute which declares that the file is softfp.
The manual page for armcc on the meaning of softvfp+vfp http://infocenter.arm.com/help/topic/com.arm.doc.dui0472m/chr1359124920656.html
Thanks a lot for the clarification! Some follow-up questions I have:
Does that mean we could replace this option in the kernel with -Wa,-mfloat-abi=softfp? We do need to add its support in LLVM as the integrated assembler does not support this option either.
Do we need a flag for the vfp part?
The build log (attached below) showed the failure contains both --target=arm-linux-gnueabihf and -Wa,-mfpu=softvfp+vfp -mfloat-abi=soft, which seem to contradict each other. Should the ABI be soft or hard?
llvm-project/build/release/bin/clang -Wp,-MD,arch/arm/vfp/.entry.o.d -nostdinc -isystem llvm-project/build/release/lib/clang/10.0.0/include -I./arch/arm/include -I./arch/arm/include/generated -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Qunused-arguments -D__ASSEMBLY__ -fno-PIE --target=arm-linux-gnueabihf --prefix=/usr/bin/ --gcc-toolchain=/usr -Werror=unknown-warning-option -mabi=aapcs-linux -mfpu=vfp -funwind-tables -meabi gnu -marm -Wa,-W -D__LINUX_ARM_ARCH__=7 -march=armv7-a -include asm/unified.h -Wa,-mfpu=softvfp+vfp -mfloat-abi=soft -c -o arch/arm/vfp/entry.o arch/arm/vfp/entry.S
Looking at binutils-gdb/gas/config the softvfp+vfp option is described in arm_option_fpu_value_table. An extract:
{"softvfp", FPU_ARCH_VFP},
{"softvfp+vfp", FPU_ARCH_VFP_V2},
{"vfp", FPU_ARCH_VFP_V2},
...
{"vfpv2", FPU_ARCH_VFP_V2},
So it looks like the only effect it has is to enable vfpv2. It doesn't have anything to do with the float-abi, which is reasonable as that isn't something that the assembler can validate anyway. It doesn't set any float-abi build attribute either.
Looking at the table I'd say softvfp+vfp is synonymous with vfpv2 which is supported by both clang and gas.
For your specific questions:
With the answer to 3 in mind it will be worth checking with people familiar with that part of Linux, what that code is doing. It looks like it is emulation code, the original vfp had some functionality that was implemented in software by a support library. This support code may not necessarily need to use floating point instructions.
To summarise I think -mfpu=vfpv2 is an option that would work for both clang and gas, but you may be able to get rid of -mfpu if no floating point instructions are expected to be used.
One other thing I've just realised is that since clang has switching to github and I changed my email address to my linaro account, gmail, or most likely a rogue filter, has been burying emails in the middle of cfe-commits and llvm-commits so I've probably missed a few conversations. My apologies if I've been cc:ed and not responded, filter is now fixed.
Looking at binutils-gdb/gas/config the softvfp+vfp option is described in arm_option_fpu_value_table. An extract:
{"softvfp", FPU_ARCH_VFP},
{"softvfp+vfp", FPU_ARCH_VFP_V2},
{"vfp", FPU_ARCH_VFP_V2},
...
{"vfpv2", FPU_ARCH_VFP_V2},So it looks like the only effect it has is to enable vfpv2. It doesn't have anything to do with the float-abi, which is reasonable as that isn't something that the assembler can validate anyway. It doesn't set any float-abi build attribute either.
Looking at the table I'd say softvfp+vfp is synonymous with vfpv2 which is supported by both clang and gas.
For your specific questions:
- No it doesn't look it. After looking at the source, I think it is best to think of softvfp+vfp in the assembler as just -mfpu=vfpv2 , its effect is independent of mfloat-abi
- I think all you should need is -mfpu=vfpv2 here to replicate the original behaviour.
- Yes -mfloat-abi=soft does contradict -Wa,-mfpu=softvfp+vfp. IIRC -mfloat-abi=soft disables the use of floating point instructions, or at least would in the integrated assembler. Looking at the file in question, it doesn't look like it uses any floating point instructions anyway.
With the answer to 3 in mind it will be worth checking with people familiar with that part of Linux, what that code is doing. It looks like it is emulation code, the original vfp had some functionality that was implemented in software by a support library. This support code may not necessarily need to use floating point instructions.
To summarise I think -mfpu=vfpv2 is an option that would work for both clang and gas, but you may be able to get rid of -mfpu if no floating point instructions are expected to be used.
Thanks for the summary! So it seems the change should be done on Linux. Will defer to the experts. @nickdesaulniers anyone we should talk to regarding this change? Thanks.
One other thing I've just realised is that since clang has switching to github and I changed my email address to my linaro account, gmail, or most likely a rogue filter, has been burying emails in the middle of cfe-commits and llvm-commits so I've probably missed a few conversations. My apologies if I've been cc:ed and not responded, filter is now fixed.
Glad you sort it out! Can't speak for the others but at least for me it's all good :)
STR:
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make CC=clang AS=clang -j71 aspeed_g5_defconfig
$ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make CC=clang AS=clang -j71 arch/arm/vfp/entry.o
patch:
From 49f0b8d8eafe7fbd79af332060410235f9dce92b Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <[email protected]>
Date: Thu, 5 Dec 2019 17:18:44 -0800
Subject: [PATCH] arm: vfp: prefer vfpv2 to softvfp+vfp
The assembler option -mfpu=softvfp+vfp isn't recognized by Clang's
integrated assembler. GNU AS aliases `softvfp+vfp` to `vfpv2` which
clang does understand.
This also reverts
commit 82b9c18dc0ee ("ARM: vfp: use -mfloat-abi=soft to build vfp")
since the error reported cannot be reproduced with
CROSS_COMPILE=arm-linux-gnueabihf- and AS=as (ie. binutils, not clang).
Link: https://github.com/ClangBuiltLinux/linux/issues/762
Reported-by: Dmitry Golovin <[email protected]>
Suggested-by: Jian Cai <[email protected]>
Suggested-by: Peter Smith <[email protected]>
Signed-off-by: Nick Desaulniers <[email protected]>
---
arch/arm/vfp/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/vfp/Makefile b/arch/arm/vfp/Makefile
index 9975b63ac3b0..5a36b8c4b4db 100644
--- a/arch/arm/vfp/Makefile
+++ b/arch/arm/vfp/Makefile
@@ -8,6 +8,6 @@
# ccflags-y := -DDEBUG
# asflags-y := -DDEBUG
-KBUILD_AFLAGS :=$(KBUILD_AFLAGS:-msoft-float=-Wa,-mfpu=softvfp+vfp -mfloat-abi=soft)
+KBUILD_AFLAGS += -Wa,-mfpu=vfpv2
obj-y += vfpmodule.o entry.o vfphw.o vfpsingle.o vfpdouble.o
--
2.24.0.393.g34dc348eaf-goog
Yes -mfloat-abi=soft does contradict -Wa,-mfpu=softvfp+vfp. IIRC -mfloat-abi=soft disables the use of floating point instructions, or at least would in the integrated assembler. Looking at the file in question, it doesn't look like it uses any floating point instructions anyway.
With the answer to 3 in mind it will be worth checking with people familiar with that part of Linux, what that code is doing. It looks like it is emulation code, the original vfp had some functionality that was implemented in software by a support library. This support code may not necessarily need to use floating point instructions.
Conviently, @arndb wrote that in commit 82b9c18dc0ee ("ARM: vfp: use -mfloat-abi=soft to build vfp"):
ARM: vfp: use -mfloat-abi=soft to build vfp
Distros are starting to ship with toolchains defaulting to
hardfloat. Using such a compiler to build the kernel fails
in the VFP directory with
arch/arm/vfp/entry.S:1:0: sorry, unimplemented: -mfloat-abi=hard and VFP
Adding -mfloat-abi=soft to the gcc command line fixes this.
That should use
+=rather than:=$(KBUILD_AFLAGS:.
I don't think that does what you think it does. AFAICT, this replaces '-msoft-float' with the string after the 'equals' sign, which you cannot achieve with +=
Just realized that this is taken care of by this patch:
https://lore.kernel.org/lkml/4165f81a1f1fdc53fe273307d1accb40f8663e01.1583360296.git.stefan@agner.ch/
It is related to #905. The approach to fix #905 I took uses assembler directives to select architecture/floating point units which makes the command line arguments superfluous.
Most helpful comment
STR:
patch:
Conviently, @arndb wrote that in commit 82b9c18dc0ee ("ARM: vfp: use -mfloat-abi=soft to build vfp"):