[yocto] Native yocto compile in docker container without cross compile

Fabian Sturm f at rtfs.org
Tue Sep 18 14:00:23 PDT 2018


Hi, 

I am wondering, there does not seem to be any information about native
compile of projects in a Yocto docker container. It seems that most of
the people use cross compile even though that imho is not necessary if
your target is x86 too. So here is what I want to do:

- Create a docker container with Yocto Linux, possibly same as the
target image
- Install gcc, cmake, autotools etc. in the docker container
- Run the docker container on a vanilla Ubuntu Linux
- Run build jobs in this docker container directly

Rational. I have several projects with fully functioning build systems,
e.g. make, cmake or autotools which I need to compile for different
platforms, e.g. Windows, Ubuntu Linux and Yocto Linux. I now don't want
to write recipes just for the Yocto cross compile which I need to
additionally maintain and I also don't want to make the original build
systems cross compile aware. This can soon get really hard if the build
system generates intermediate binaries that are called in the build
itself and if it is not prepared for this.
Since my target and host platform are both x86 I do not see the need
for a cross compile anyways. Usually it is necessary since the target
platform might be a very slow ARM system that can't handle all the
builds itself. But I do not have this limitation.

With such a solution my original build systems should still be able to
run unmodified. Within the docker container the environment would be
almost the same as in an Ubuntu Linux. The compiler can be accessed
without any cross compile settings and any intermediate binaries can
also be directly executed etc.

If there are some fundamental reasons why this is a bad idea, I would
like to know. I also would appreciate any tips on how to create such a
docker image. Usually my Yocto image for the target would not contain a
compiler or make tool. So I need a way to add those after the fact.


Thanks a lot!
Fabian



More information about the yocto mailing list