Dovetail-Automata / docker-cross-builder

Cross-build Debian packages in Docker for `i386` and `armhf` using `gcc --sysroot`
2 stars 2 forks source link

Unable to get anything other than AMD64 to build #1

Closed timwhite closed 7 years ago

timwhite commented 7 years ago

I'm trying to use this awesome docker image to build Debian packages for the Grase Hotspot project. I've previously done all building by hand in dchroot's and on actual arm hardware for the arm builds. Hoping to use this instead. I understand it probably "just works" for your builds, and not expecting total support from you. Just hoping you might have some insights into getting it to work, from getting it to work for your builds.

Thanks

Firstly, I had to install a few more dependencies (project specific), and also create /home/travis/.ccache

apt-get -y install gengetopt libssl-dev libjson0-dev
mkdir -p /home/travis/.ccache

AMD64 builds work at this stage.

i386 gives the following issues

checking for g++... g++
configure: WARNING: using cross tools not prefixed with host triplet
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking for gawk... (cached) mawk
checking for i586-linux-gnu-gcc... no
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... unsupported
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking for gcc option to accept ISO C99... unsupported
checking how to run the C preprocessor... /lib/cpp
configure: error: in `/opt/coova-chilli':
configure: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
debian/rules:19: recipe for target 'config.status' failed
make: *** [config.status] Error 1
dpkg-buildpackage: error: debian/rules build gave error exit status 2

Some relevant sections from config.log

configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "coova-chilli"
| #define PACKAGE_TARNAME "coova-chilli"
| #define PACKAGE_VERSION "1.3.2"
| #define PACKAGE_STRING "coova-chilli 1.3.2"
| #define PACKAGE_BUGREPORT "support@coova.com"
| #define PACKAGE_URL ""
| #define PACKAGE "coova-chilli"
| #define VERSION "1.3.2"
| /* end confdefs.h.  */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|            Syntax error
configure:5297: /lib/cpp -m32 --sysroot=/sysroot/i386 conftest.c
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed/syslimits.h:7:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed/limits.h:34,
                 from conftest.c:12:
/usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed/limits.h:168:61: error: no include path in which to search for limits.h
 #include_next <limits.h>  /* recurse down to the real one */
                                                             ^
configure:5297: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "coova-chilli"
| #define PACKAGE_TARNAME "coova-chilli"
| #define PACKAGE_VERSION "1.3.2"
| #define PACKAGE_STRING "coova-chilli 1.3.2"
| #define PACKAGE_BUGREPORT "support@coova.com"
| #define PACKAGE_URL ""
| #define PACKAGE "coova-chilli"
| #define VERSION "1.3.2"
| /* end confdefs.h.  */
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|            Syntax error
configure:5327: error: in `/opt/coova-chilli':
configure:5329: error: C preprocessor "/lib/cpp" fails sanity check

armhf appears to be even worse

checking whether build environment is sane... yes
checking for arm-linux-gnueabihf-strip... arm-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-linux-gnueabihf-g++... arm-linux-gnueabihf-g++
checking whether the C++ compiler works... no
configure: error: in `/opt/coova-chilli':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
debian/rules:19: recipe for target 'config.status' failed
make: *** [config.status] Error 77
dpkg-buildpackage: error: debian/rules build gave error exit status 2

Relevant section from config.log

configure:3600: checking whether the C++ compiler works
configure:3622: arm-linux-gnueabihf-g++  --sysroot=/sysroot/armhf --sysroot=/sysroot/armhf conftest.cpp  >&5
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
collect2: error: ld returned 1 exit status
configure:3626: $? = 1
configure:3664: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "coova-chilli"
| #define PACKAGE_TARNAME "coova-chilli"
| #define PACKAGE_VERSION "1.3.2"
| #define PACKAGE_STRING "coova-chilli 1.3.2"
| #define PACKAGE_BUGREPORT "support@coova.com"
| #define PACKAGE_URL ""
| #define PACKAGE "coova-chilli"
| #define VERSION "1.3.2"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3669: error: in `/opt/coova-chilli':
configure:3671: error: C++ compiler cannot create executables
zultron commented 7 years ago

I'm amazed you found this work.

This isn't a very good general method for cross-building, because separating the build-arch portions of build tools (installed in the system root) from their host-arch portions of build inputs (installed under /sysroot) has to be separately hacked for each dependency. Browsing the Dockerfile reveals numerous such hacks using symlinks and monkey-patches.

Your errors will need similar hacks. The below error, pasted from your i386 build output, shows the build system looking for amd64-arch build inputs, of course incorrect. The armhf error is also related to the relocation of build inputs.

In file included from /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed/syslimits.h:7:0,
             from /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed/limits.h:34,
             from conftest.c:12:

That you must create the .ccache directory indicates that you're not running it the same way we do. You might study the build logs from the Travis CI builds and the build_docker script for how to invoke the Docker container, which might help if you're not using exactly the right incantation. There's a lot of magic hidden away in that build_docker script, as the final 10 lines indicate.

Let me warn you that you're exploring new territory, this will never be a supported method of cross-building, and you're not going to find many folks who can help with problems. If that doesn't scare you, then have fun!

timwhite commented 7 years ago

@zultron Thanks for getting back to me. I'm now re-reading Debian cross compiling and appear to be having some luck with it in my own docker container!