Cross-compilation

Ralf Friedl Ralf.Friedl at online.de
Tue Jun 4 10:48:55 UTC 2013


Laurent Bercot wrote:
>> Autotools-based can be good or bad for cross-compiling. The biggest
>> issue is that lots of people write broken tests that need to run test
>> programs to get the results they want.
>   As long as there are differences between systems, build-time tests
> will be necessary to check for what the system provides and what
> needs working around.
>   This is the main problem with cross-compilation: build-time tests
> only work in the native case. When cross-compiling, there is no way to
> automatically figure out what the target flags are.
>
>   The best solution would be to have a centralized, worldwide database
> of system-dependent flags and options that any cross-compilation process
> could search and extract target information from. Until we have that,
> the only clean way to cross-compile is to have the user provide target
> sysdeps *by hand*.
>
>   As far as I am aware, autotools do not make that easy. This essential
> part of the cross-compilation process is not integrated into the
> autotools architecture, which is why I do not consider them a reliable
> system.
Actually it is very easy:
You just need a file that contains the answers to the questions that 
configure can't figure out itself. Then you either export all these 
values before running configure, or you export CONFIG_SITE=/path/to/file 
and configure will read the file.
The file contains lines like
ac_cv_epoll_works=yes
ac_cv_c_littleendian=yes
ac_cv_c_bigendian=no
ac_cv_type_pid_t=yes
ac_cv_type_ptrdiff_t=yes
ac_cv_type_struct_sockaddr_storage=yes
ac_cv_sizeof_char=1
ac_cv_sizeof_short=2
ac_cv_sizeof_int=4
ac_cv_sizeof_long=4
ac_cv_sizeof_long_long=8
ac_cv_sizeof_void_p=4
ac_cv_sizeof_pid_t=4
ac_cv_sizeof_ptrdiff_t=4
ac_cv_sizeof_size_t=4
ac_cv_sizeof_ssize_t=4
ac_cv_sizeof_socklen_t=4

configure will then not run the tests, but use these answers you 
provided. As this worldwide database you mention is also created *by 
hand*, just by someone else, I consider that essentially the same. 
Depending on the target, it may be possible to run the configure scripts 
on the target to find out the correct answers, although it may not be 
feasible to run the whole compilation on the target.
Note that some of the entries above can and will be detected 
automatically by configure just by calling the cross compiler without 
running the actual binary.

That covers the tests that come with the autotools. It may be 
problematic when people add other tests that don't follow these rules, 
but that can't be blamed on autotools.

Ralf


More information about the busybox mailing list