freebsd / crochet

Build FreeBSD images for RaspberryPi, BeagleBone, PandaBoard, and others.
BSD 2-Clause "Simplified" License
611 stars 187 forks source link

Use armv6hf target arch by defaut for the raspberry Pi #140

Closed iyedb closed 8 years ago

iyedb commented 8 years ago

According to this page https://wiki.freebsd.org/FreeBSD/arm/crossbuild armv6hf is one the targets archs available to cross-compile FreeBSD: ARMv6 and ARMv7 systems with native hardware floating point. The raspberry Pi model A, B, B+ has a hardware FPU.

kientzle commented 8 years ago

This looks good. Before I merge it, can you confirm that you've tested it by doing a full complete clean build from scratch?

kientzle commented 8 years ago

Hmmm.... One possible concern: Does this work with FreeBSD 10?

A lot of folks use Crochet with FreeBSD 10 sources and I've never checked to see if armv6hf is supported there.

iyedb commented 8 years ago

This is confirmed to work on a FreeBSD 11 source tree. I generated an image using crochet and it boots and works perfectly. And it actually builds for the arm hard fp abi for my raspberry pi B+ %readelf -a /sbin/init: here is no dynamic section in this file. Attribute Section: aeabi File Attributes Tag_CPU_name: arm1176jzf-s Tag_CPU_arch: ARM v6 Tag_ARM_ISA_use: Yes Tag_FP_arch: VFPv2 Tag_ABI_PCS_GOT_use: direct Tag_ABI_PCS_wchar_t: wchar_t size 4 Tag_ABI_FP_denormal: Needed Tag_ABI_FP_exceptions: Needed Tag_ABI_FP_number_model: IEEE 754 Tag_ABI_align_needed: 8-byte align Tag_ABI_align_preserved: 8-byte align Tag_ABI_enum_size: 32-bit Tag_ABI_VFP_args: AAPCS (VFP variant) Tag_ABI_FP_16bit_format: IEEE 754 Tag_conformance: 2.09

I am not aware if it does not cause any issue on FreeBSD-10.x and I did not test it. What can be done is testing if we are building a 10 source tree or a 11 source tree using some top level variable set by crochet main script. If you agree with the approach I can go ahead make the necessary changes. The same applies for the pi 2. For raspberry PI really the default should be armv6hf. This is for example how Raspbian differs from Debian. They "just" recompiled all of Debian to target the hard float abi. One down side though: there is no armv6hf pkg repo: running pkg for the first time gives this: pkg: Error fetching http://pkg.FreeBSD.org/FreeBSD:11:armv6hf/latest/Latest/pkg.txz: Not Found I am going to build the packages I need my self. but now I can do it on the host since I have the cross tool chain :) (building on the PI is desperately slow as you can imagine) My build environment is FreeBSD-11 current on VirtualBox on OS X. Works flawlessly.

kientzle commented 8 years ago

FREEBSD_MAJOR_VERSION is set during the check phase. It should be "10" or "11" accordingly after that point.

zxombie commented 8 years ago

armv6 is already hard float, all armv6hf gives you is it will pass floating-point data to functions in floating-point registers. I also expect that armv6 will be using the hard float ABI soon (within a month) an at this time armv6hf will be removed.

iyedb commented 8 years ago

Can you please expand on that? According to this wiki page https://wiki.freebsd.org/FreeBSD/arm/crossbuild, armv6 is to be deprecated in favor of armv6h. I am little confused I guess I am missing something. You said that armv6 is already hard float And that it will using the hf ABI soon? What I understand is that armv6 already generates VFPv2 instructions for floating point operations but does not pass float arguments in the float registers (the ABI). How is this going to happen? Is there a way to track the progress. Thanks.

zxombie commented 8 years ago

That page is a few months old, since then it has been decided to move the armv6 ABI to hard-float. The start of this work has been committed in https://svnweb.freebsd.org/changeset/base/293069. This will allow us to change the ABI while allowing existing applications to still run.

iyedb commented 8 years ago

Ok great. For reference here are the compiler default options when building an elf on an armv6hf FreeBSD build: -target-cpu arm1176jzf-s -target-abi aapcs-linux -mfloat-abi hard an armv6 FreeBSD build: -target-cpu arm1176jzf-s -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-feature -crypto -target-abi aapcs-linux -msoft-float -mfloat-abi soft I am going to close the pull request. One question though, does this mean the packages from http://pkg.FreeBSD.org/FreeBSD:11:armv6/latest/Latest/pkg.txz need not be rebuilt?

kientzle commented 8 years ago

Follow-up note: armv6 now uses hard-float, so "armv6hf" as a build type has been deprecated.