Source: vim
Version: 2:8.1.0693-2
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

vim fails to cross build from source for a larger pile of reasons. Let
me go through them step by step:

 * Build-Depends: ruby and Build-Depend: python3-dev asks for the host
   architecture interpreters respectively. Those interpreters are not
   runnable. What you need here is build architecture interpreters plus
   host architecture development packages for the respective languages.

 * The packaging does not instruct the build system to perform a cross
   build. You need to pass --host to ./src/configure. Unfortunately, the
   very first invocation happens via "make -C src scratch", so we need
   to stuff the relevant flags into CONF_ARGS.

 * ./src/configure fails in lots of places, because it cannot figure out
   the results without running stuff. We'll have to tell it to trust
   that getcwd, memmove and toupper work.

 * Some checks in ./src/configure fail unnecessarily. For instance
   sizeof(wchar_t) can easily be determined using AC_CHECK_SIZEOF.
   Checking whether tgetent actually works can be skipped and checking
   the tty group should be skipable as well as it is skipable during
   native builds.

 * After passing the first ./src/configure, debian/rules invokes it a
   number of further times. Again, we need to pass --host.

 * Finally, it fails finding ruby/config.h.

I have no clue how to fix the last issue, but the attached patch fixes
all the other ones. Does the patch make sense to you? Please close this
bug when addressing multiple of the points raised above even if vim
doesn't cross build. I tried making the embedded cross.patch
upstreamable. If these explanations are too succinct, don't hesitate to
ask for details.

Helmut
diff --minimal -Nru vim-8.1.0693/debian/changelog vim-8.1.0693/debian/changelog
--- vim-8.1.0693/debian/changelog       2019-01-05 21:53:12.000000000 +0100
+++ vim-8.1.0693/debian/changelog       2019-01-06 21:19:29.000000000 +0100
@@ -1,3 +1,15 @@
+vim (2:8.1.0693-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Improve cross building: (Closes: #-1)
+    + Multiarchify python and ruby Build-Depends.
+    + Add --host to ./src/configure via make scratch.
+    + Export a pile of vim-specific autoconf cache variables.
+    + cross.patch: Fix a few autoconf checks.
+    + Also pass --host to CFGFLAGS.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sun, 06 Jan 2019 21:19:29 +0100
+
 vim (2:8.1.0693-2) unstable; urgency=medium
 
   * Separate /etc/vim and /usr/share/vim/vimfiles.  The former should be for
diff --minimal -Nru vim-8.1.0693/debian/control vim-8.1.0693/debian/control
--- vim-8.1.0693/debian/control 2019-01-05 21:53:12.000000000 +0100
+++ vim-8.1.0693/debian/control 2019-01-06 21:19:27.000000000 +0100
@@ -18,6 +18,7 @@
  libgtk2.0-dev,
  liblua5.2-dev,
  libperl-dev,
+ libpython3-dev,
  libselinux1-dev [linux-any],
  libncurses-dev,
 # Needed to run libvterm's tests
@@ -26,8 +27,8 @@
  libxpm-dev,
  libxt-dev,
  lua5.2,
- python3-dev,
- ruby,
+ python3-dev:any,
+ ruby:any,
  ruby-dev,
  tcl-dev,
 Build-Conflicts:
diff --minimal -Nru vim-8.1.0693/debian/patches/cross.patch 
vim-8.1.0693/debian/patches/cross.patch
--- vim-8.1.0693/debian/patches/cross.patch     1970-01-01 01:00:00.000000000 
+0100
+++ vim-8.1.0693/debian/patches/cross.patch     2019-01-06 21:19:29.000000000 
+0100
@@ -0,0 +1,51 @@
+--- vim-8.1.0693.orig/src/configure.ac
++++ vim-8.1.0693/src/configure.ac
+@@ -2319,23 +2319,17 @@
+ 
+     LDFLAGS="$ac_save_LDFLAGS"
+ 
+-    AC_MSG_CHECKING(size of wchar_t is 2 bytes)
+-    AC_CACHE_VAL(ac_cv_small_wchar_t,
+-      [AC_TRY_RUN([
++    AC_CHECK_SIZEOF([wchar_t],,[
+ #include <X11/Xlib.h>
+ #if STDC_HEADERS
+ # include <stdlib.h>
+ # include <stddef.h>
+ #endif
+-              main()
+-              {
+-                if (sizeof(wchar_t) <= 2)
+-                  exit(1);
+-                exit(0);
+-              }],
+-              ac_cv_small_wchar_t="no",
+-              ac_cv_small_wchar_t="yes",
+-              AC_MSG_ERROR(failed to compile test program))])
++    ])
++    AC_MSG_CHECKING(size of wchar_t is 2 bytes)
++    AS_IF([test "$ac_cv_sizeof_wchar_t" -le 2],
++        ac_cv_small_wchar_t="yes",
++        ac_cv_small_wchar_t="no")
+     AC_MSG_RESULT($ac_cv_small_wchar_t)
+     if test "x$ac_cv_small_wchar_t" = "xyes" ; then
+       AC_DEFINE(SMALL_WCHAR_T)
+@@ -3464,7 +3458,7 @@
+ # include <stddef.h>
+ #endif
+ main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }],
+-                        res="OK", res="FAIL", res="FAIL")
++                        res="OK", res="FAIL", res="OK")
+       if test "$res" = "OK"; then
+       break
+       fi
+@@ -3703,7 +3697,8 @@
+       vim_cv_tty_group=world
+       AC_MSG_RESULT([can't determine - assume ptys are world accessible])
+     ],[
+-      AC_MSG_ERROR(cross-compiling: please set 'vim_cv_tty_group' and 
'vim_cv_tty_mode')
++      vim_cv_tty_group=world
++      AC_MSG_RESULT([cross-compiling: - assume ptys are world accessible])
+     ])
+   ])
+ rm -f conftest_grp
diff --minimal -Nru vim-8.1.0693/debian/patches/series 
vim-8.1.0693/debian/patches/series
--- vim-8.1.0693/debian/patches/series  2019-01-05 21:53:12.000000000 +0100
+++ vim-8.1.0693/debian/patches/series  2019-01-06 21:19:29.000000000 +0100
@@ -3,3 +3,4 @@
 debian/Detect-the-rst-filetype-using-the-contents-of-the-file.patch
 debian/Add-recognition-of-more-LaTeX-commands-for-tex-filetype-d.patch
 debian/Document-Debian-s-decision-to-disable-modelines-by-defaul.patch
+cross.patch
diff --minimal -Nru vim-8.1.0693/debian/rules vim-8.1.0693/debian/rules
--- vim-8.1.0693/debian/rules   2019-01-05 21:53:12.000000000 +0100
+++ vim-8.1.0693/debian/rules   2019-01-06 21:19:29.000000000 +0100
@@ -14,6 +14,14 @@
   ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
     MAKETEST := yes
   endif
+else
+  export CONF_ARGS = --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
+  export vim_cv_toupper_broken=no
+  export vim_cv_terminfo=yes
+  export vim_cv_tgetent=zero
+  export vim_cv_getcwd_broken=no
+  export vim_cv_stat_ignores_slash=no
+  export vim_cv_memmove_handles_overlap=yes
 endif
 
 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
@@ -26,6 +34,9 @@
 CFGFLAGS += --with-compiledby="$(BUILDER)"
 CFGFLAGS += --enable-fail-if-missing
 CFGFLAGS += --with-global-runtime='/etc/vim,$$VIM/vimfiles'
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+CFGFLAGS += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
+endif
 
 TINYFLAGS:=--with-features=small
 TINYFLAGS+=--disable-gui

Reply via email to