Bug#644546: eglibc: Support cross-compiler bootstrap with "stage1" build
Source: eglibc
Version: 2.13-21
Severity: wishlist
Tags: patch
In order to support bootstrap of a Debian cross-compiler, it would be
extremely helpful if the EGLIBC packaging supported the stage1 steps as
described in the "eglibc-2.13/EGLIBC.cross-building" file.
The attached patch allows for such a build, which creates only a single
libc-dev package (EG: "libc6-dev" on my target arch).
There was one necessary unrelated change, due to the fact that a stage1
cross-compiler does not include a package setting up the "default"
commands of the form "$TRIPLET-gcc", so I added the DEB_GCC_VERSIOn
variable to force CC to be a particular compiler version.
The specific commands I used to test this patch on my amd64 host:
$ sudo apt-get build-dep eglibc=2.13-21
$ apt-get source eglibc=2.13-21
$ patch -d eglibc-2.13 -p1 <eglibc-2.13-cross-stage1-support.patch
$ ( cd eglibc-2.13 && DEB_GCC_VERSION=-4.6 DEB_STAGE=stage1 \
dpkg-buildpackage -apowerpcspe -b -us -uc ) 2>&1 | tee eglibc-stage1.log
This produced a single "libc6-dev_2.13-21_powerpcspe.deb" file, which I
installed using the following command:
$ sudo dpkg-cross -M -a powerpcspe -X libc6 -X libc-dev-bin \
-i libc6-dev_2.13-21_powerpcspe.deb
The only remaining issue is that the "libc6-dev" package that is built
still has dependencies on "libc6" and "libc-dev-bin". Unfortunately I
can't figure out the debian/control file generation well enough to fix
that, so I'm hoping that the EGLIBC maintainers can make it work.
The result is that I can proceed to building a stage2 GCC using the
standard "DEB_STAGE=stage2" process in the gcc-4.6 package.
I have to say, I'm not exactly proud of the way it works, it sort of
forcibly overrides several variables and make pattern rules to build
only the single default target-architecture headers it wants. On the
other hand the changes are almost entirely self-contained in a single
new file: "debian/rules.d/stage1.mk".
Cheers,
Kyle Moffett
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (700, 'testing'), (700, 'stable'), (600, 'unstable'), (500, 'stable-updates'), (500, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.39-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
diff -ruN eglibc-2.13/debian/rules eglibc-2.13.stage1/debian/rules
--- eglibc-2.13/debian/rules 2011-10-06 15:45:01.000000000 -0400
+++ eglibc-2.13.stage1/debian/rules 2011-10-06 14:29:57.000000000 -0400
@@ -101,11 +101,12 @@
# Set CC and CXX for cross-compiling
ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
-CC = $(DEB_HOST_GNU_TYPE)-gcc
-CXX = $(DEB_HOST_GNU_TYPE)-g++
+CC = $(DEB_HOST_GNU_TYPE)-gcc$(DEB_GCC_VERSION)
+CXX = $(DEB_HOST_GNU_TYPE)-g++$(DEB_GCC_VERSION)
else
-CC = gcc-4.4
-CXX = g++-4.4
+DEB_GCC_VERSION ?= -4.4
+CC = gcc$(DEB_GCC_VERSION)
+CXX = g++$(DEB_GCC_VERSION)
endif
BUILD_CFLAGS = -O2 -g
diff -ruN eglibc-2.13/debian/rules.d/stage1.mk eglibc-2.13.stage1/debian/rules.d/stage1.mk
--- eglibc-2.13/debian/rules.d/stage1.mk 1969-12-31 19:00:00.000000000 -0500
+++ eglibc-2.13.stage1/debian/rules.d/stage1.mk 2011-10-06 15:40:35.000000000 -0400
@@ -0,0 +1,71 @@
+## This reuses various macros from the debian/rules.d/build.mk file
+
+ifeq ($(DEB_STAGE),stage1)
+
+override EGLIBC_PASSES = libc
+override DEB_ARCH_REGULAR_PACKAGES = $(libc)-dev
+override DEB_INDEP_REGULAR_PACKAGES =
+override DEB_UDEB_PACKAGES =
+
+## Development libraries we need to fake
+stage1_libfake.so := \
+ libc.so
+
+stage1_libfake.a := \
+ libanl.a \
+ libBrokenLocale.a \
+ libbsd-compat.a \
+ libc.a \
+ libc_nonshared.a \
+ libcrypt.a \
+ libdl.a \
+ libg.a \
+ libieee.a \
+ libm.a \
+ libmcheck.a \
+ libnsl.a \
+ libpthread.a \
+ libpthread_nonshared.a \
+ libresolv.a \
+ librpcsvc.a \
+ librt.a \
+ libutil.a \
+
+$(stamp)build_libc: $(stamp)configure_libc
+ @echo Building $(curpass)
+ @## Build the crtX.o init routines
+ $(call logme, -a $(log_build), $(MAKE) -C $(DEB_BUILDDIR) $(NJOBS) csu/subdir_lib)
+ $(call logme, -a $(log_build), $(AR) qcs $(DEB_BUILDDIR)/libfake.a)
+ $(call logme, -a $(log_build), $(CC) -nostdlib -nostartfiles -shared \
+ -o $(DEB_BUILDDIR)/libfake.so $(DEB_BUILDDIR)/libfake.a)
+ $(call logme, -a $(log_build), echo "---------------" ; echo -n "Build ended: " ; date --rfc-2822)
+ touch $@
+
+$(stamp)check_libc: $(stamp)build_libc
+ @echo Nothing to test for $(curpass)
+ touch $@
+
+$(stamp)install_libc: DESTDIR=$(CURDIR)/debian/tmp-$(curpass)
+$(stamp)install_libc: $(stamp)check_libc
+ @echo Installing $(curpass)
+ rm -rf $(CURDIR)/debian/tmp-$(curpass)
+ ## These libc/ld-linux binaries are total garbage, but they allow
+ ## a subsequent stage2 GCC build to succeed.
+ install -d $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)
+ for lib_a in $(stage1_libfake.a); do \
+ install -T $(DEB_BUILDDIR)/libfake.a $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$lib_a; \
+ done
+ for lib_so in $(stage1_libfake.so); do \
+ install -T $(DEB_BUILDDIR)/libfake.so $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$lib_so; \
+ done
+ $(MAKE) -C $(DEB_BUILDDIR) install_root=$(DESTDIR) install-bootstrap-headers=yes \
+ csu/subdir_install install-headers
+ mkdir -p $(DESTDIR)/usr/include/$(DEB_HOST_MULTIARCH)
+ mv $(DESTDIR)/usr/include/bits $(DESTDIR)/usr/include/$(DEB_HOST_MULTIARCH)
+ mv $(DESTDIR)/usr/include/gnu $(DESTDIR)/usr/include/$(DEB_HOST_MULTIARCH)
+ mv $(DESTDIR)/usr/include/sys $(DESTDIR)/usr/include/$(DEB_HOST_MULTIARCH)
+ mv $(DESTDIR)/usr/include/fpu_control.h $(DESTDIR)/usr/include/$(DEB_HOST_MULTIARCH)
+ $(call xx,extra_install)
+ touch $@
+
+endif
Reply to: