Cross compiling KDE / Nokia N900

Pino Toscano toscano.pino at tiscali.it
Wed Dec 23 15:17:31 CET 2009


Alle mercoledì 23 dicembre 2009, Alexander Neundorf ha scritto:
> On Wednesday 23 December 2009, Pino Toscano wrote:
> > Hi,
> >
> > Alle mercoledì 23 dicembre 2009, Alexander Neundorf ha scritto:
> > > Yes, it's also on my todo, but it would be really nice if somebody else
> > >  could actually do the work and I would just "guide" throught the
> > > necessary steps.
> > >
> > > There are mainly three things which lead to problems when cross
> > > compiling: 1) try to build and run executable during the configure
> > > check [...]
> > >
> > > 1) is the hardest one. If somebody does a try_run
> > > (check_c_source_runs()) in a cross compile, it will build the
> > > executable, but it will not try to run it (since it can't, in general).
> > > Instead cmake will provide a template cmake script file prepared so
> > > that the expected values from the try_run() can be entered there
> > > manually. Also the compiled executable is made available, so that the
> > > developer can take it, run it on the target and in this way figure out
> > > the result which have to go into the prepared cmake script file. This
> > > file than has to be preloaded into cmake using -C on the next cmake
> > > run. Doing this for all try_run()s is actual work.
> >
> > I think this point could be solved if cmake would have the distinction
> > between "host" (the platform it is building for) and "build" (the
> > platform it is building on) compilers (of course, in case of no
> > crosscompilation, host and build stuff would be the same).
> 
> This is the case since cmake 2.6.0 :-)
> You can check
> if (CMAKE_CROSSCOMPILING)
>  ...
> 
> and you have CMAKE_SYSTEM_NAME (target host) and CMAKE_HOST_SYSTEM_NAME
>  (build host), if not cross compiling both are the same.

I know cmake can do cross compiling this way (I do that at work), but it's far 
from being pain-free.

> > For example, take the check_c_source_runs() example, and assume I'm
> > crosscompiling on i386 (build gcc: cc) for arm (host cc: arm-linux-cc):
> > check_c_source_runs() would be compiled using the build compiler (cc), so
> > it can be run later.
> 
> Do you mean that even when cross compiling the i386 gcc should be used for
> check_c_source_runs() ?
> This wouldn't make sense. The sources must be built using the target
>  compiler (arm_linux-cc), since
> -host and target compiler may be completely different compilers (think gcc
>  and sdcc, or msvc and gcc)
> -being able to compile and link the source with the host (i386) compiler
> doesn't tell you anything about whether it would also link on the target
> system
> -running it in the build host environment doesn't tell you anything about
>  the target environment

Those points are valid, although there cold be situations where you want to do 
that anyway: for example, a small program that #include some version.h-like 
header, and outputs different stuff depending on different #if VERSION_MAJOR > 
4 ... #elif VERSION_MAJOR > 2 ... etc. This is so simple no compiler/toolchain 
could get it wrong.

Furthermore, there's still the other case of usefulness for having build and 
host compilers separated:

> > This would have the advantage I could force the use of the build compiler
> > for intermediate build steps, for example a custom target which has to
> > compile some executable and run it to get the input files for other
> > targets.

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kde-buildsystem/attachments/20091223/28fe3ad8/attachment.sig 


More information about the Kde-buildsystem mailing list