When cross-compiling Apache httpd 2.2.19 "make" fails with the following error: ./dftables: ./dftables: cannot execute binary file According to the README file in /srclib/pcre it should be possible to specify CC_FOR_BUILD when calling the "configure" command, but even when doing so "make" fails. A known workaround is to first build Apache httpd for local host and then copy the dftables binary to the other host build folder and run "make" again. However, since I would like to automate the build process the workaround is not sufficient for me. Also, the same type of error exists with the gen_test_char binary: /bin/sh: ./gen_test_char: cannot execute binary file
The build problem with gen_test_char still exists on Apache HTTP Server 2.4.1
Created attachment 28632 [details] Simple patch for defining the C compiler command to be used for compilation of programs that run on BUILD during cross-compiling, e.g. gen_test_char. Verified on httpd_2.4.1
Created attachment 28633 [details] Same patch as previous file but for httpd_trunk.
Hi Henrik, (In reply to comment #3) > Created attachment 28633 [details] > Same patch as previous file but for httpd_trunk. I've just commited a slightly modified patch to trunk: http://svn.apache.org/viewvc?rev=1327907&view=rev this should work same way as with your patch provided that you export CC_FOR_BUILD=gcc. I hope that we can finally figure out how we can configure teach to set CC_FOR_BUILD automatically in case of detecting cross-compilation so that the export is then not needed. The CC_FOR_BUILD should appear in build/config_vars.mk because then server/Makefile can access it. For 2.2.x you will then need in addition: --- srclib/pcre/Makefile.in.orig 2005-02-11 13:00:41.000000000 +0100 +++ srclib/pcre/Makefile.in 2012-04-19 13:29:06.000000000 +0200 @@ -11,8 +11,13 @@ $(LTLIBRARY_OBJECTS) dftables.lo: config.h +ifdef CC_FOR_BUILD +dftables: dftables.c + $(CC_FOR_BUILD) -o $@ $< +else dftables: dftables.lo $(LINK) $(EXTRA_LDFLAGS) dftables.lo $(EXTRA_LIBS) +endif $(srcdir)/chartables.c: dftables ./dftables $@
I've just committed a follow-up patch: http://svn.apache.org/viewvc?view=revision&revision=1328390 it is *required* that you re-run buildconf so that configure gets re-created! After you've run configure with f.e.: CC_FOR_BUILD=gcc ./configure --host=... you can check ./build/config_vars.mk where CC_FOR_BUILD should appear now and ./server/Makefile should now see the var ...
Here's the summarize of all patches: * cross-compile: allow to provide CC_FOR_BUILD so that gen_test_char will be compiled by the build compiler instead of the host compiler. Also set CC_FOR_BUILD to 'cc' when cross-compilation is detected. Trunk patches: http://svn.apache.org/viewvc?view=revision&revision=1327907 http://svn.apache.org/viewvc?view=revision&revision=1328390 http://svn.apache.org/viewvc?view=revision&revision=1328714 Backport proposal added for 2.4.x patch: http://people.apache.org/~fuankg/diffs/httpd-2.4.x-cross_compile.diff Backport proposal added for 2.2.x patch: http://people.apache.org/~fuankg/diffs/httpd-2.2.x-cross_compile.diff Since PCRE is included with 2.2.x this patch also takes care for dftables. please test both with and without providing CC_FOR_BUILD - if not set and cross-compilation is detected then CC_FOR_BUILD defaults to 'cc'.
Created attachment 28680 [details] Updated document patch.
Created attachment 28681 [details] Updated document patch.
Created attachment 28682 [details] Updated document patch.