Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved]libffi build fails for target armv7l-unknown-linu...
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
Zeault
n00b
n00b


Joined: 03 Aug 2019
Posts: 23
Location: New England, United States

PostPosted: Mon Feb 19, 2024 7:23 pm    Post subject: [Solved]libffi build fails for target armv7l-unknown-linu... Reply with quote

I have some packages cross built for armv7l-unknown-linux-musleabi running on my home router. They have been working quite well so far and I am try to test the boundaries to see what else I can build and get running on the system. My current roadblock is that libffi fails to build. It configures without any major errors and then tries to compile the sysv.S assembly source file. Inside the file there is a directive ".arm" which triggers the assembler "Error: selected processor does not support ARM opcodes"

This is obviously bogus as the cross toolchain has been building arm instructions this whole time. The actual error is caused by a libtool compile command which invokes armv7l-unknown-linux-musleabi-gcc on the file. If I run the same command outside of libtool I get the same error. If I try to run the assembler (armv7l-unknown-linux-musleabi-as) directly on the file it of course complains a lot about not understanding the #include directives but there is no error about the current cpu not supporting arm opcodes. In fact it appears as though it correctly recognizes the target cpu is ARM because it emits messages like "Error: selected processor does not support `vldrle d0,[r0]' in ARM mode."

I have looked around a bit and it seems there are existing bugs of mentioning how gcc does not correctly autodetect the cpu when the target arch is armv7.
GCC Bug 70210
GCC Bug 83206

This got me thinking maybe I should be explicitly stating the mcpu in make.conf. However, in the discussion for bug 70210, a developer says "armv7l is not a valid argument to -mcpu by design." If that's not a valid argument for mcpu, then I have no idea what I should set it to. /proc/cpuinfo just says it is an "ARMv7 Processor rev 5 (v7l)". GCC says these are the only valid arguments to mcpu:

Code:
arm8 arm810 strongarm strongarm110 fa526 fa626 arm7tdmi arm7tdmi-s arm710t arm720t arm740t arm9 arm9tdmi arm920t arm920 arm922t arm940t ep9312 arm10tdmi arm1020t arm9e arm946e-s arm966e-s arm968e-s arm10e arm1020e arm1022e xscale iwmmxt iwmmxt2 fa606te fa626te fmp626 fa726te arm926ej-s arm1026ej-s arm1136j-s arm1136jf-s arm1176jz-s arm1176jzf-s mpcorenovfp mpcore arm1156t2-s arm1156t2f-s cortex-m1 cortex-m0 cortex-m0plus cortex-m1.small-multiply cortex-m0.small-multiply cortex-m0plus.small-multiply generic-armv7-a cortex-a5 cortex-a7 cortex-a8 cortex-a9 cortex-a12 cortex-a15 cortex-a17 cortex-r4 cortex-r4f cortex-r5 cortex-r7 cortex-r8 cortex-m7 cortex-m4 cortex-m3 marvell-pj4 cortex-a15.cortex-a7 cortex-a17.cortex-a7 cortex-a32 cortex-a35 cortex-a53 cortex-a57 cortex-a72 cortex-a73 exynos-m1 xgene1 cortex-a57.cortex-a53 cortex-a72.cortex-a53 cortex-a73.cortex-a35 cortex-a73.cortex-a53 cortex-a55 cortex-a75 cortex-a76 cortex-a76ae cortex-a77 cortex-a78 cortex-a78ae cortex-a78c cortex-a710 cortex-x1 cortex-x1c neoverse-n1 cortex-a75.cortex-a55 cortex-a76.cortex-a55 neoverse-v1 neoverse-n2 cortex-m23 cortex-m33 cortex-m35p cortex-m55 star-mc1 cortex-m85 cortex-r52 cortex-r52plus


I am still trying to figure this one out on my own but I think I'm stuck and need a little help. Can anyone tell my how I can definitively determine the mcpu value of my arm system without having gcc installed on that system? I know the processor is a Broadcom BCM47189 so if there is a chart someone has come across which has mcpu values, that could also be of use.

OR Maybe I am chasing down completely wrong leads here. Any suggestions are welcome. Thank you.


Last edited by Zeault on Tue Feb 20, 2024 1:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zeault
n00b
n00b


Joined: 03 Aug 2019
Posts: 23
Location: New England, United States

PostPosted: Tue Feb 20, 2024 10:58 am    Post subject: Reply with quote

Okay so I was able to solve the problem and build libffi!

I did not realize that there was a simple utility packaged with util-linux called "lscpu" which I already had installed on the target system. I ran it and it told me that the processor was a cortex-A7 which is in that list of valid arguments to -mcpu. I added the mcpu option to the make.conf file inside the portage prefix and the libffi package immediately built without errors.

I am happy this was so easy to solve! I hope this post helps someone else. In summary here is what I learned:

Apparently there is enough variation in the arm architecture that telling gcc your chip is an "armv7" isn't good enough to narrow down the target in all situations. Some packages may build, but others that have hand-written assembly routines like libffi will not. For those packages you need to actually specify the processor on the command line using the mcpu option. An easy way to find out which mcpu value you should use is to compile and run the lscpu command on the target system. lscpu is part of the util-linux package and can be built without the mcpu option specified.
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5036
Location: Bavaria

PostPosted: Tue Feb 20, 2024 2:03 pm    Post subject: Reply with quote

If you want learn more about your CPU then you might emerge the package "cpuid" and run it ;-)
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
Back to top
View user's profile Send private message
Zeault
n00b
n00b


Joined: 03 Aug 2019
Posts: 23
Location: New England, United States

PostPosted: Tue Feb 20, 2024 5:32 pm    Post subject: Reply with quote

Quote:
If you want learn more about your CPU then you might emerge the package "cpuid" and run it ;-)


Thank you for the suggestion pietinger but that package only supports x86 and derivative processors. The creator has a separate project called armcpu but that isn't packaged for Gentoo. I was looking for an arm alternative that was packaged when I stumbled upon lscpu. I would have tried resolve-march-native but that indirectly depends on libffi.
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5036
Location: Bavaria

PostPosted: Tue Feb 20, 2024 7:01 pm    Post subject: Reply with quote

Zeault wrote:
Thank you for the suggestion pietinger but that package only supports x86 and derivative processors. [...]

I didn't know that - thank you very much for this information (learnt something again) ! :D
_________________
https://wiki.gentoo.org/wiki/User:Pietinger
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