Cross compiling KDE / Nokia N900

Alexander Neundorf neundorf at kde.org
Wed Dec 23 15:01:43 CET 2009


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.

> 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

> 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. This proposal would also avoid the "template cmake script with the
> expected values" and using CMAKE_CROSSCOMPILING in such situations.
>
> Would it feasible to do?

No, I don't think so. It must be done with the target compiler.

Something what might be feasible would be to add special support for executing 
executables via some wrapper (e.g. upload it to the target, execute it and 
return results, run it via wine, etc.).

Alex


More information about the Kde-buildsystem mailing list