Re: Cross compiling user applications for armv7

From: Warner Losh <imp_at_bsdimp.com>
Date: Sat, 13 Sep 2025 16:08:47 UTC
On Sat, Sep 13, 2025 at 9:50 AM Michał Kruszewski <mkru@protonmail.com>
wrote:

> It is more about how hard it is to setup an environment for cross
> compiling your own kernel modules or applications for armv7.
> I don't really care whether I use Buildroot way of doing things or FreeBSD
> way.
> The difference is that with Buildroot it takes 10 minutes to setup such
> environment.
> With FreeBSD I am struggling for two days.
> And the only advice I get is to use arm64 machine.
> Well, I don't have any.
> And even if I had, I wouldn't use it, because I find this concept deeply
> "misengineered".
>

And it is bad engineering. Mark sometimes gives bad advice that's based on
his experience where it was "easier" to do it this way. I just wish I'd
replied more quickly.


> I know that you want to help, and I appreciate it.
> I just feel frustrated with the complexity of this conceptually trivial
> task.
>

No. I get it. I'm frustrated too since I've been working for years to make
it better, and there's still these rough edges that turn people off.

Warner


> Regards,
> Michał Kruszewski
>
>
> Sent with Proton Mail secure email.
>
> On Saturday, September 13th, 2025 at 4:29 PM, Mark Millard <
> marklmi@yahoo.com> wrote:
>
> >
> > On Sep 13, 2025, at 00:20, Michał Kruszewski mkru@protonmail.com wrote:
> >
> > > Basically you are saying that I should have a separate physical arm64
> machine for doing embedded armv7 development on FreeBSD.
> > > If I understand this correctly, I just can't understand how can people
> say that FreeBSD is embedded friendly.
> > > This is so much complex and convoluted compared to just using, for
> example, Buildroot on Linux.
> > > This also doesn't feel like a *nix way of solving things.
> > > I thought that after cross compiling world and kernel, there is some
> shell script that I can simply source to start cross-development for target
> platform.
> >
> >
> > I found this AI based note about Buildroot's way of
> > putting cross-build toolchains to use:
> >
> > QUOTE
> > Buildroot pre-configures and compiles all necessarily
> > packages during the build process to create a custom
> > root filesystem.
> > . . .
> > Buildroot focuses on static builds, meaing all selected
> > packages are compiled and integrated into the final root
> > filesystem image during the build process. There is no
> > concept of installing or updating packages on the target
> > after the initial build.
> > END QUOTE
> >
> > This is certainly not what the FreeBSD ports tree is
> > set up for. Buildroot or analogous does not exist for
> > FreeBSD --or most *BSD or Unix-- to my knowledge.
> >
> > May be NetBSD's pkgsrc cross build support:
> >
> >
> https://cdn.netbsd.org/pub/pkgsrc/current/pkgsrc/doc/HOWTO-use-crosscompile
> >
> > would be closer to how you like to work? (I've never
> > used such.)
> >
> > > Regards,
> > > Michał Kruszewski
> > >
> > > Sent with Proton Mail secure email.
> > >
> > > On Saturday, September 13th, 2025 at 12:23 AM, Mark Millard
> marklmi@yahoo.com wrote:
> > >
> > > > On Sep 12, 2025, at 14:10, Michał Kruszewski mkru@protonmail.com
> wrote:
> > > >
> > > > > A simple way is to set up an armv7 chroot / jail on an arm64 host
> such as a Raspberry Pi (Apple devices don't work!).
> > > > > Then it's just like a native environment, but usually much faster.
> > > >
> > > > > I don't have physical arm64 host.
> > > > > I also don't want to create a VM.
> > > > > The whole idea seems weird and unnatural.
> > > >
> > > > Ignoring the RPi4B detail:
> > > >
> > > > FreeBSD official armv7 port-packages are built this way
> > > > on arm64 hardware that natively supports user-space
> > > > armv7 code. (ampere* systems are used.)
> > > >
> > > > FreeBSD official i386 port-packages are built this way
> > > > on amd64 hardware that natively supports user-space
> > > > i386 code.
> > > >
> > > > No use of qemu variants of any kind: no attempt at
> > > > non-native-capable host environments.
> > > >
> > > > (Back when amd64 and qemu was used for the likes
> > > > of armv7, lots of stuff failed to build mcuh of
> > > > the time over the years --stuff that builds
> > > > just fine now. This was abandoned after native
> > > > became available. armv6 was always qemu based
> > > > on amd64 and could not build much as of the last
> > > > time a build was run.)
> > > >
> > > > > It sounds more like an exotic workaround.
> > > >
> > > > It is the official technique used for what FreeBSD
> > > > distributes for armv7 port-packages.
> > > >
> > > > > Regards,
> > > > > Michał Kruszewski
> > > > >
> > > > > Sent with Proton Mail secure email.
> > > > >
> > > > > On Friday, September 12th, 2025 at 10:46 PM, Robert Clausecker
> fuz@fuz.su wrote:
> > > > >
> > > > > > Hi Michał,
> > > > > >
> > > > > > A simple way is to set up an armv7 chroot / jail on an arm64
> host such as
> > > > > > a Raspberry Pi (Apple devices don't work!). Then it's just like
> a native
> > > > > > environment, but usually much faster.
> > > > > >
> > > > > > Yours,
> > > > > > Robert Clausecker
> > > > > >
> > > > > > Am Fri, Sep 12, 2025 at 04:19:42PM +0000 schrieb Michał
> Kruszewski:
> > > > > >
> > > > > > > Is there any tutorial on how to cross compile custom user
> application for armv7?
> > > > > > > I struggle t find any.
> > > > > > > Cross compiling the system is pretty easy.
> > > > > > > However, how can one cross compile custom user application or
> kernel drivers.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Michał Kruszewski
> > > > > > >
> > > > > > > Sent with Proton Mail secure email.
> > > > > >
> > > > > > --
> > > > > > () ascii ribbon campaign - for an encoding-agnostic world
> > > > > > /\ - against html email - against proprietary attachments
> > > >
> > > > ===
> > > > Mark Millard
> > > > marklmi at yahoo.com
> >
> >
> > ===
> > Mark Millard
> > marklmi at yahoo.com
>
>