# Compiling for atom/amd64 on Raspberry Pi



## Eponymous (Apr 14, 2016)

Hi,

I have a Raspberry Pi B and the prebuilt FreeBSD image on it.

I was wanting to build one port, statically, for two different architectures: native (arm6) to run on the Pi and one for an Intel Atom processor (amd64?).

I've looking into using poudriere but this seems overkill for the sake of one package. 

I tried just running a make from the directory:

```
# make TARGET=amd64 TARGET_ARCH=amd64 LDFLAGS+="-static"
```
However while this built a static binary it didn't build it for the amd64; it seemed to just ignore those options.

Is this the correct method?

Also am I right in thinking that an amd64 binary will run fine on an Intel Atom C2358 or do I need to specify the target and target_arch as "atom"?

Thanks.


----------



## SirDice (Apr 14, 2016)

You really don't want to do this on a Raspberry. It's already dead slow to build ARM native ports, it's going to be excruciatingly slow when cross-compiling. If you can get it to work at all.


----------



## Eponymous (Apr 14, 2016)

Hmm, well this would only be a one-off build - not something I'm likely to repeat. But you're saying it's difficult to set this up?

I'm not entirely sure about the architecture of the Intel Atom C2358, but would another alternative be to compile what I need in a FreeBSD (amd64) environment running in say a virtual machine and then copy the binary across or do I need to build explicitly for the "atom" architecture?


----------



## kpa (Apr 14, 2016)

You can't cross-compile ports unless you have a separate jail(8) or chroot(8) environment for that purpose. In case the jail/chroot architecture can not be directly run on top of the host you'll also need an emulator such as emulators/qemu. The reason is that ports have to be built in their native environment as close as possible because ports will link against the base system libraries at the linking phase and using libraries of the wrong architecture is not going to work. Poudriere is capable of building amd64 ports on ARM at least on paper but I have no idea that would work in practice.


----------

