Source: dietlibc Version: 0.34~cvs20160606-7 User: helm...@debian.org Usertags: rebootstrap
dietlibc fails to cross build from source. The ultimate failure arises when it tries to execute diet for the host architecture. So I looked and what I found was very confusing. There are lots of problems. Let me start by quoting the dietlibc FAQ[1]: | Q: Do you have cross compiling support? | A: Yes. Just type something like "make ARCH=arm CROSS=arm-linux- all". | For arm, alpha, mips, ppc, sparc and i386, shortcuts exist. You can | also use "make arm", for example. You still use the same "diet" | program as for normal compilation, but you can then say | | $ diet sparc-linux-gcc -pipe -g -o t t.c | | Programs using autoconf can be configured like this: | | $ CC="diet sparc-linux-gcc" ./configure --disable-nls Unfortunately, the packaging gets this completely wrong. The FAQ says that you should set ARCH, but the packaging sets MYARCH. In GNU terminology, ARCH is the host architecture and MYARCH is the build architecture. Thus the packaging confuses build and host here. Next up, it doesn't pass CROSS. The value should be "${DEB_HOST_GNU_TYPE}-". The upstream Makefile expects to be in control of the CC variable. Unfortunately, most other Makefiles expect not to be in control, so dh_auto_build passes CC as a command line variable now. This renders upstream statements such as CC+=-D__dietlibc__ ineffective (and it should be using CFLAGS anyway). I'm afraid, we cannot use dh_auto_build here without expecting breakage. Then the build wants to run "bin-${MYARCH}/diet". But it doesn't build that. For cross compiling, one needs another build pass where ARCH and CROSS are not set. Finally, when using dietlibc, one wants the diet program to come from the build architecture and the library for the host architecture. The packaging however stuffs both into the same binary package. The typical fix is to split dietlibc-dev into another package dietlibc-dev-bin. Then move the diet program there and move it into an architecture-independent path. Mark dietlibc-dev-bin Multi-Arch: foreign and have dietlibc-dev depend on it. You can turn the original architecture-dependent paths into symlinks for backwards-compatibility. I tried implementing what I sketched here, but it turned out I was producing more and more stranger and stranger errors (presumably, because I don't understand the packaging well enough). Thus I only write down what I know and hope that you can fix at least some aspects. I'm happy to help. Unfortunately, dietlibc suddenly became part of the bootstrap problem when gdbm started Build-Depending on it. Helmut [1] https://www.fefe.de/dietlibc/FAQ.txt