Source: firebird3.0
Version: 3.0.2.32703.ds4-9
Tags: patch upstream
User: [email protected]
Usertags: rebootstrap

firebird3.0 fails to cross build from source, because configure.ac has a
lot of issues. It confuses "build" and "host" and uses AC_RUN_IFELSE in
a number of places. The attached patch addresses and explains these
issues in detail.

debian/rules also confuses build and host when determining whether to
pass --enable-raw-devices. It should be querying DEB_HOST_ARCH_OS here.

After fixing these issues, a cross build of firebird3.0 gets a lot
further and finally fails executing "lockfile". That's a program from
procmail, which is (implicitly) marked Multi-Arch: no. Presumably
procmail needs to become Multi-Arch: foreign or firebird3.0 needs to
stop using procmail for file locking.

Please consider applying the attached patch nonetheless.

Helmut
From: Helmut Grohne <[email protected]>
Subject: improve cross buildability

 * Rather than checking $build (the architecture we are building on), we should
   be checking $host. Unfortunately, $host tends to lack the vendor part, so we
   need a tricky sed expression for inserting it. For native builds, $host and
   $build are equal.
 * The check for whether sem_init works only aborts the build in case of
   failure. Since the check cannot be performed during cross building, the only
   sane way is to just assume sem_init to work.
 * Replace a pile of AC_RUN_IFELSE with AC_CHECK_SIZEOF and AC_CHECK_ALIGNOF.
   The latter macros have a slower fallback path for cross compilation that use
   compiler bisection to determine the values.

Index: firebird3.0-3.0.2.32703.ds4/configure.ac
===================================================================
--- firebird3.0-3.0.2.32703.ds4.orig/configure.ac
+++ firebird3.0-3.0.2.32703.ds4/configure.ac
@@ -85,7 +85,9 @@
 dnl Test for special ar options?
 AR_OPT_CHECK=false
 
-case "$build" in
+host_quadruplet=$(echo "$host" | sed 's/^\(@<:@^-@:>@*\)-\(@<:@^-@:>@*\)-\(@<:@^-@:>@*\)$/\1-pc-\2-\3/')
+echo "considering >$build< >$host< >$host_quadruplet<"
+case "$host_quadruplet" in
   x*64-*-darwin*)
     MAKEFILE_PREFIX=darwin_x86_64
     MAKEFILE_POSTFIX=darwin
@@ -147,7 +149,7 @@
 
   amd64-*-freebsd* | x86_64*-*-freebsd* | x86_64*-*-k*bsd*-gnu)
     MAKEFILE_PREFIX=freebsd_amd64
-    case "$build" in
+    case "$host_quadruplet" in
         x86_64*-*-k*bsd-gnu)      # Debian/kFreeBSD
             PLATFORM=GENTOOFREEBSD
             INSTALL_PREFIX=linux
@@ -952,7 +954,8 @@
 		}
 	]])],[AC_DEFINE(WORKING_SEM_INIT,1,[Define this if sem_init() works on the platform])
 AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
-AC_SEARCH_LIBS(sem_open, rt pthread)],[])
+AC_SEARCH_LIBS(sem_open, rt pthread)],[AC_DEFINE(WORKING_SEM_INIT,1)
+AC_MSG_RESULT([assuming yes (cross compiling)])])
 fi
 fi
 
@@ -976,12 +979,10 @@
 AC_TYPE_UID_T
 AC_SYS_LARGEFILE
 if test "$ac_cv_sys_file_offset_bits" = "no"; then
-  AC_MSG_CHECKING(for native large file support)
-  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <unistd.h>
-    main () {
-    exit(!(sizeof(off_t) == 8));
-  }]])],[ac_cv_sys_file_offset_bits=64; AC_DEFINE(_FILE_OFFSET_BITS,64)
-   AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)],[])
+  AC_CHECK_SIZEOF([off_t],[],[#include <unistd.h>])
+  if test "$ac_cv_sizeof_off_t" = 8; then
+    ac_cv_sys_file_offset_bits=64; AC_DEFINE(_FILE_OFFSET_BITS,64)
+  fi
 fi
 
 AC_CHECK_SIZEOF(void *)
@@ -1014,27 +1015,17 @@
 
 dnl EKU: try to determine the alignment of long and double
 dnl      replaces FB_ALIGNMENT and FB_DOUBLE_ALIGN in src/jrd/common.h
-AC_MSG_CHECKING(alignment of long)
-AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <semaphore.h>
-main () {
-  struct s {
-    char a;
-    union { long long x; sem_t y; } b;
-  };
-  exit((int)&((struct s*)0)->b);
-}]])],[ac_cv_c_alignment=$ac_status],[ac_cv_c_alignment=$ac_status],[])
-AC_MSG_RESULT($ac_cv_c_alignment)
+AC_CHECK_ALIGNOF([long long])
+AC_CHECK_ALIGNOF([sem_t],[#include <semaphore.h>])
+if test "$ac_cv_alignof_long_long" -gt "$ac_cv_alignof_sem_t"; then
+	ac_cv_c_alignment=$ac_cv_alignof_long_long
+else
+	ac_cv_c_alignment=$ac_cv_alignof_sem_t
+fi
 AC_DEFINE_UNQUOTED(FB_ALIGNMENT, $ac_cv_c_alignment, [Alignment of long])
 
-AC_MSG_CHECKING(alignment of double)
-AC_RUN_IFELSE([AC_LANG_SOURCE([[main () {
-  struct s {
-    char a;
-    double b;
-  };
-  exit((int)&((struct s*)0)->b);
-}]])],[ac_cv_c_double_align=$ac_status],[ac_cv_c_double_align=$ac_status],[])
-AC_MSG_RESULT($ac_cv_c_double_align)
+AC_CHECK_ALIGNOF([double])
+ac_cv_c_double_align=$ac_cv_alignof_double
 AC_DEFINE_UNQUOTED(FB_DOUBLE_ALIGN, $ac_cv_c_double_align, [Alignment of double])
 
 dnl EKU: Add any platform specific tests below

Reply via email to