Package: src:ncurses
Version: 5.9+20140913-1
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

When cross building ncurses for multilib enabled architectures (e.g.
i386, sparc), the build fails. The failure mode depends on the installed
packages.  If gcc-multilib is not installed[1], the multilib builds
which are invoked with e.g. CC="gcc -m32" fail. Otherwise, dh_strip
fails[3] on wrong-arch binaries. Even if the build was succeeding, the
resulting packages would contain wrong-arch binaries.

The fix is not to use CC="gcc -msomething" in cross builds but rather
use CC="$triplet-gcc -msomething". The attached patch achieves just
that. Does it look reasonable to you (after the jessie release)?

Helmut

[1] Technically, this means that the g++-multilib Build-Dependency is
    not satisfied. However, this dependency needs translation[2] in
    order to be useful for cross compilation. So not having gcc-multilib
    installed is morally valid. Just fixing Build-Depends is not yet
    feasible as gcc-for-host and friends are still in experimental.
[2] https://wiki.debian.org/CrossTranslatableBuildDeps
[3] https://jenkins.debian.net/job/rebootstrap_sparc_gcc49/91/console
diff -Nru ncurses-5.9+20140913/debian/changelog 
ncurses-5.9+20140913/debian/changelog
--- ncurses-5.9+20140913/debian/changelog       2014-09-17 19:00:57.000000000 
+0200
+++ ncurses-5.9+20140913/debian/changelog       2014-12-29 19:26:41.000000000 
+0100
@@ -1,3 +1,10 @@
+ncurses (5.9+20140913-1.1) UNRELEASED; urgency=low
+
+  * Non-maintainer upload.
+  * Use correct compiler for multilib cross builds. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Mon, 29 Dec 2014 19:25:54 +0100
+
 ncurses (5.9+20140913-1) unstable; urgency=low
 
   * New upstream patchlevel.
diff -Nru ncurses-5.9+20140913/debian/rules ncurses-5.9+20140913/debian/rules
--- ncurses-5.9+20140913/debian/rules   2014-09-15 20:01:33.000000000 +0200
+++ ncurses-5.9+20140913/debian/rules   2014-12-29 19:25:50.000000000 +0100
@@ -7,6 +7,14 @@
 export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
 export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
 
+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+HOST_CC ?= $(DEB_HOST_GNU_TYPE)-gcc
+HOST_CXX ?= $(DEB_HOST_GNU_TYPE)-g++
+else
+HOST_CC ?= gcc
+HOST_CXX ?= g++
+endif
+
 # These are important since this is a library package
 soname=5
 sodepver = (>= 5.9+20140712)
@@ -191,8 +199,8 @@
 
        cf_cv_type_of_bool='unsigned char'; export cf_cv_type_of_bool; \
        cf_cv_working_poll=yes; export cf_cv_working_poll; \
-       cd $(objdir-32) && CFLAGS="$(CFLAGS)" CC="gcc -m32" \
-               BUILD_CC="gcc" CXX="g++ -m32" \
+       cd $(objdir-32) && CFLAGS="$(CFLAGS)" CC="$(HOST_CC) -m32" \
+               BUILD_CC="gcc" CXX="$(HOST_CXX) -m32" \
                $(srcdir)/configure \
                $(CONFARGS) \
                --host=$(build_32_target) \
@@ -205,8 +213,8 @@
 
        cf_cv_type_of_bool='unsigned char'; export cf_cv_type_of_bool; \
        cf_cv_working_poll=yes; export cf_cv_working_poll; \
-       cd $(objdir-64) && CFLAGS="$(CFLAGS)" CC="gcc -m64" \
-               BUILD_CC="gcc" CXX="g++ -m64" \
+       cd $(objdir-64) && CFLAGS="$(CFLAGS)" CC="$(HOST_CC) -m64" \
+               BUILD_CC="gcc" CXX="$(HOST_CXX) -m64" \
                $(srcdir)/configure \
                $(CONFARGS) \
                --host=$(build_64_target) \
@@ -254,8 +262,8 @@
 
        cf_cv_type_of_bool='unsigned char'; export cf_cv_type_of_bool; \
        cf_cv_working_poll=yes; export cf_cv_working_poll; \
-       cd $(wobjdir-32) && CFLAGS="$(CFLAGS)" CC="gcc -m32" \
-               BUILD_CC="gcc" BUILD_CPPFLAGS="-D_GNU_SOURCE" CXX="g++ -m32" \
+       cd $(wobjdir-32) && CFLAGS="$(CFLAGS)" CC="$(HOST_CC) -m32" \
+               BUILD_CC="gcc" BUILD_CPPFLAGS="-D_GNU_SOURCE" CXX="$(HOST_CXX) 
-m32" \
                $(srcdir)/configure \
                $(CONFARGS) \
                --host=$(build_32_target) \

Reply via email to