Bug #2706 mysql not ready for cross-compilation
Submitted: 11 Feb 2004 10:21 Modified: 13 Jun 2013 19:51
Reporter: Dmitrii Tisnek Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Compiling Severity:S4 (Feature request)
Version:4.0.17 OS:Linux (linux/linux)
Assigned to: Kent Boortz CPU Architecture:Any

[11 Feb 2004 10:21] Dmitrii Tisnek
Description:
mysql build system is not ready for cross-compilation.

1) there are several places where configure barfes with "configure: error: cannot run test program while cross compiling"
1.1) when checking the return type of sprintf
1.2) when checking for compress in zlib
1.3) two occurances when checking for atomic operations
1.4) when checking for restartable system calls
1.5) when checking if conversion of long long to float works
1.6) when checking for int8

there are a couple more places where similar error might occur but since it didn't for me, I can't claim it happens at all.

2) there are several places in Makefiles where $(CC) is used instead of $(HOST_CC)
2.1) libmysql_r/Makefile when making conf_to_crc
2.2) libmysql/Makefile when making conf_to_crc
2.3) strings/Makefile when making conf_to_crc
2.4) sql/Makefile when making gen_lex_hash

How to repeat:
set up a cross-compilation toolchain (in my case i386-uclibc-linux), try to configure and compile mysql for that target.

Suggested fix:
whoever wrote configure.* and Makefile.* gets to fix it
[27 Apr 2004 13:36] Sergei Golubchik
Tim, if you are fixing it, note that it's WL#1151 (assign it to yourself, etc)
[4 May 2004 0:54] Timothy Smith
This requested feature (to make MySQL capable of being cross-compiled) is on our project TODO list.  We hope to have this added in version 4.1.

Thank you for your report.
[7 Dec 2005 21:40] Hien Nguyen
is there any update on this bug yet?
[17 Dec 2005 17:33] Massimiliano Pirani
Are there any news about that ? I'm currently trying with source version 5.0.16 and it seems as nothing's changed. I think it is a very important feature for such a good release.
[29 Jan 2009 21:36] Kent Boortz
The problem with cross compilation of the sources today are

  - Configure is not adapted enough to cross compilation. Recent
     patches to 6.0 has partly addressed this already.

  - The distributed source TAR lacks some source files that are
     to be generated by executables build during the build. They
     could have been included and make files changed to avoid
     triggering rebuild of these executables during build or the
     pregenerated files.

  - The missing generated source files can't be created during
     the cross compilation, as there is no support in configure
     or make files to use the host compiler to build those, but
     the cross compiler to build the rest.

There are two routes, one is to make sure the source files generated
during build are always pregenerated by "make dist", i.e. in the source
packages, and that the cross build will not depend on them being
regenerated. Makes building directly from the source repository a bit
harder. You need to do "BUILD/compile-dist && make dist", unpack
the source TAR created and build there.

The other route is to change the build itself to use the system compiler
to create the tools generating the source files, but the cross compiler
to compile the actual binaries for the target.

There is no conflict between these routes, initial work to make
"comp_err.c" and "gen_lex_hash.c" independent of the rest of
the build will benefit both. If option two is to be used they need
to be rewritten this way. If route one is to be used, rewriting them
to be independent of the rest of the build makes "make dist" 
very fast compared to now when "libmystrings", "libmysys" and
other parts have to be built to build and run them.
[13 Jun 2013 19:51] Matthew Lord
Thank you for the feature request, and for your help in making MySQL even better!

The GNU autoconf toolset is no longer used, and we instead use CMake. If you 
still have any cross compilation issues with the CMake based builds, please 
open a new Feature Request and we can deal with the new and specific problems 
that you may encounter there: 
  http://www.cmake.org/Wiki/CMake_Cross_Compiling 

Thank you again for the feature request, and for your interest in MySQL!