# i386 try on amd64 system



## YuryG (May 9, 2018)

I've got some idea of trying (for example, for strange testing) to build and run some ports as i386, but do that and run them on an amd64 machine. Is is possible in reality?
Say, I want to try www/firefox in both variants: amd64 (native) and i386 (not so native) on the same machine. I could guess that I need to build also all the dependencies (all?) in i386 mode for that. But is it somehow explained somewhere?

UPD. May be that is not clear enough, I want two browsers, i386 and amd64, on one desktop side-by-side, say in MATE desktop, to compare.


----------



## SirDice (May 9, 2018)

YuryG said:


> I've got some idea of trying (for example, for strange testing) to build and run some ports as i386, but do that and run them on an amd64 machine. Is is possible in reality?


You can run a 32 bit jail on a 64 bit system without problems.


----------



## YuryG (May 9, 2018)

Oh, thanks! And how is that can be done? Could you point me to some tutorial, please?


----------



## SirDice (May 9, 2018)

https://gundersen.net/32bit-jail-on-64bit-freebsd/


----------



## YuryG (May 9, 2018)

I am afraid there's no way to make it as simple as just running 32bit binaries on amd64 system (just like on Win), is there? I mean to build them possible running without jails?


----------



## PMc (May 10, 2018)

There is no need for a jail. chroot() suffices. `make installword` and `make distribution` into some DESTDIR, copy resolv.conf into it and mount /dev into it.


----------



## YuryG (May 11, 2018)

Thank you for the reply. May be there's more detailed examples?


----------



## PMc (May 11, 2018)

Okay. 

This assumes that one has the srctree installed under /usr/src, and the portstree on a separate filesystem that can be unmounted from /usr/ports and mounted somewhere else where needed (symlinking will not do). This is how I do build my ports for other machines.

Designate a working directory with enough space, Lets call it `/build` for this example. Then:


```
cd /usr/src
make buildworld TARGET=i386 TARGET_ARCH=i386 # if not yet done
make installworld TARGET=i386 TARGET_ARCH=i386 DESTDIR=/build
make distribution TARGET=i386 TARGET_ARCH=i386 DESTDIR=/build
cp /etc/resolv.conf /build/etc  # so that fetch can work
mount -t devfs devfs /build/dev   # some make commands need this
umount /usr/ports; mount <your portstree filesystem> /build/usr/ports
chroot /build sh -c 'cd /usr/ports/www/firefox; make install'
```

Ports built this way will run within the chroot, that is, when invoked via `chroot /build /path/to/whatever-command` - if the kernel is configured to do so (`options COMPAT_FREEBSD32`). They _should_ as well run when installing them to the amd64 base system , _but _you will have to figure out the name-clashes (the newly built things will in most cases have the same filenames as the same ports installed in amd64 version) not only for the program itself, but also for all the shared libs it may require (There may be some switches in the makefiles to help with that, but I never looked into that more closely). This might be a little bit of work, especially for such a fat beast as firefox is.


----------

