Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
RK3288 gcc -mcpu optimization conflict
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM
View previous topic :: View next topic  
Author Message
M95D
n00b
n00b


Joined: 03 Jan 2020
Posts: 52

PostPosted: Mon Jan 09, 2023 7:50 pm    Post subject: RK3288 gcc -mcpu optimization conflict Reply with quote

Hi.

Hardware is Asus TinkerBoard S, with RK3288 (armv7-a with vfpv3 and NEON). Specs here.
I'm trying to cross-compile a kernel for it. I used the official linux (git clone from torvalds repo) and crossdev -t arm-unknown-linux-gnueabihf to generate a toolchain.
Now I'm trying to build the kernel with these options:
Code:

export ARCH=arm
export CROSS_COMPILE="arm-unknown-linux-gnueabihf-"
export KCFLAGS="-O2 -pipe -mcpu=cortex-a17 -mfpu=neon-vfpv3"
export KCPPFLAGS=$KCFLAGS
make

...and I get this warning:
Code:
cc1: warning: switch '-mcpu=cortex-a17' conflicts with switch '-march=armv7-a'


I didn't set any -march switch. Where does that come from?
And why is there a conflict? Isn't cortex-a17 an armv7-a CPU?

Thanks.

PS:
I also tried:
Code:
KCFLAGS="-O2 -pipe -mfloat-abi=hard -march=armv7ve+neon-vfpv3 -mcpu=cortex-a17 -mfpu=neon-vfpv3"

... and I got:
Code:

...
  AR      init/built-in.a
  AR      usr/built-in.a
  CC      arch/arm/vfp/vfpmodule.o
{standard input}: Assembler messages:
{standard input}:687: Error: D register out of range for selected VFP version -- `vldr d16,.L113'
{standard input}:691: Error: D register out of range for selected VFP version -- `vstr d16,[r2]'
{standard input}:791: Error: D register out of range for selected VFP version -- `vldr d16,.L113'
{standard input}:1198: Error: D register out of range for selected VFP version -- `vldr d16,.L176'
{standard input}:1201: Error: D register out of range for selected VFP version -- `vstr d16,[r4,#496]'
make[3]: *** [scripts/Makefile.build:252: arch/arm/vfp/vfpmodule.o] Error 1


Last edited by M95D on Tue Jan 10, 2023 8:52 am; edited 1 time in total
Back to top
View user's profile Send private message
rab0171610
Guru
Guru


Joined: 24 Dec 2022
Posts: 330

PostPosted: Tue Jan 10, 2023 7:58 am    Post subject: Reply with quote

Until someone with more experience in this area chimes in . . .
Quote:
Prior to ARMv8, the ARM architecture distinguished between VFP and NEON floating-point support. NEON was not fully IEEE 754 compliant, and there were instructions that VFP supported which NEON did not. These issues have been resolved with ARMv8.

https://embeddedartistry.com/blog/2017/10/11/demystifying-arm-floating-point-compiler-options/

Have you thoroughly read:
https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
If you have studied it then you can ignore the suggestion.
However, a note from this (GCC) link:
Quote:
If the selected floating-point hardware includes the NEON extension (e.g. -mfpu=neon), note that floating-point operations are not generated by GCC’s auto-vectorization pass unless -funsafe-math-optimizations is also specified. This is because NEON hardware does not fully implement the IEEE 754 standard for floating-point arithmetic (in particular denormal values are treated as zero), so the use of NEON instructions may lead to a loss of precision.


That may have been fixed with ARMv8?

Also, from the GCC link , I think it is possible you are somehow inadvertently setting -march (as a default or implied setting):
Quote:
-mcpu=name+extension…
This specifies the name of the target ARM processor. GCC uses this name to derive the name of the target ARM architecture (as if specified by -march)



The the following link is old and not 100% relevant, but it may give you some info that might help explain what the significance of the conflicting -march switches:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58869

Lastly, instead of:
Code:
-march=armv7ve+neon-vfpv3

Is it possible, considering the errors about vldr d16 being out of range for the VFP version, that you might need to use:
Code:
-march=armv7ve+neon-fp16

That will include the 16D FPU registers:
Quote:
+neon-fp16
The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with the half-precision floating-point conversion operations.

That is if the cortex-a17 supports this.
Back to top
View user's profile Send private message
M95D
n00b
n00b


Joined: 03 Jan 2020
Posts: 52

PostPosted: Tue Jan 10, 2023 9:24 am    Post subject: Reply with quote

I know that -mcpu should select -march and -mtune automatically and I really didn't specify any -march, but somehow a conflicting -march is automatically selected. I don't understand where that came from. Does crossdev somehow set a default -march in the generated toolchains? If so, how do I remove that?

RK3288 specs say it supports vfpv3:
Quote:
Include VFP v3 hardware to support single and double-precision add, subtract, divide, multiply and accumulate, and square root operations

I couldn't find any info about how many registers it has, but it's clearly not half-precision, so xxx-fp16 would be wrong.
I read the gcc manual and I can't find any neon-vfpv3-d16, not in -mcpu and not in -mfpu. I think neon implies 32 registers.

Somehow I missed that note about gcc not using neon due to loss of precision. I'll try without -neon, with -vfpv3 only.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54422
Location: 56N 3W

PostPosted: Tue Jan 10, 2023 10:09 am    Post subject: Reply with quote

M95D,


Set up the default .config file to your likeing
Code:
ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabihf- make <your_defconfig>


Tweak the cofig. Including setting the build options.
Code:
ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabihf- make menuconfig


Build almost normally
Code:
ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabihf- make -jX
where X suits the build host.

Now you have the kernel binary, the matching *dtb and kernel modules ready to install. Copy them.

Intsall your arm kernel modules to INSTALL_MOD_PATH=
Code:
ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabihf- modules_install INSTALL_MOD_PATH=/mnt/gentoo


Do not pass
Code:
export KCFLAGS="-O2 -pipe -mcpu=cortex-a17 -mfpu=neon-vfpv3"
export KCPPFLAGS=$KCFLAGS
Trust the kernel build system

The -march switch will come from the kernel .config file.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54422
Location: 56N 3W

PostPosted: Tue Jan 10, 2023 10:10 am    Post subject: Reply with quote

Moved from Portage & Programming to Gentoo on ARM.

It an ARM thing
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
M95D
n00b
n00b


Joined: 03 Jan 2020
Posts: 52

PostPosted: Tue Jan 10, 2023 1:56 pm    Post subject: Reply with quote

NeddySeagoon wrote:

Do not pass [code]export KCFLAGS="-O2 -pipe -mcpu=cortex-a17 -mfpu=neon
The -march switch will come from the kernel .config file.

I didn't know that. Thanks!
Back to top
View user's profile Send private message
M95D
n00b
n00b


Joined: 03 Jan 2020
Posts: 52

PostPosted: Fri Jan 13, 2023 7:59 am    Post subject: Reply with quote

It does work with latest git master, but there is problem booting that kernel. The board turns itself off while booting the kernel, without any error, it just powers off without even finishing the current debug line on the serial port.
So I tried kernel v5.15 and it does't work.
Code:

$ git checkout v5.15
$ ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabihf- make clean
$ ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabihf- make -j1

...

  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/main.o
/tmp/ccswHRub.s: Assembler messages:
/tmp/ccswHRub.s:1378: Error: selected processor does not support `cpsid i' in ARM mode
/tmp/ccswHRub.s:1627: Error: selected processor does not support `cpsid i' in ARM mode
/tmp/ccswHRub.s:1689: Error: selected processor does not support `cpsie i' in ARM mode
/tmp/ccswHRub.s:1732: Error: selected processor does not support `dsb ' in ARM mode
/tmp/ccswHRub.s:1921: Error: selected processor does not support `cpsie i' in ARM mode
/tmp/ccswHRub.s:2066: Error: architectural extension `mp' is not allowed for the current base architecture
/tmp/ccswHRub.s:2067: Error: selected processor does not support `pldw [r4]' in ARM mode
/tmp/ccswHRub.s:2070: Error: selected processor does not support `pld [r4]' in ARM mode
/tmp/ccswHRub.s:2076: Error: selected processor does not support `ldrex r3,[r4]' in ARM mode
/tmp/ccswHRub.s:2078: Error: selected processor does not support `strex r1,r2,[r4]' in ARM mode
make[1]: *** [scripts/Makefile.build:277: init/main.o] Error 1
make: *** [Makefile:1868: init] Error 2
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum