The gnulib configure machinery doesn't take into account cross-builds.  

I ran into this while doing a cross-build of GDB.  It broke badly on a 
build=X86_64-linux, host=i386-netbsdelf cross-build, because Linux attempted to 
execute the generated conftest image (a NetBSD image).  That's wrong of course, 
but worse yet, it got into an infinite loop, apparently the emulation is buggy. 
 So my build got stuck.

The specific issue is in the "locale" checks in gnulib.  The patch below cures 
it.

        paul

diff --git a/gdb/gnulib/import/m4/locale-fr.m4 
b/gdb/gnulib/import/m4/locale-fr.m4
index 92ff552..fdd7c39 100644
--- a/gdb/gnulib/import/m4/locale-fr.m4
+++ b/gdb/gnulib/import/m4/locale-fr.m4
@@ -73,8 +73,8 @@ int main () {
 }
 changequote([,])dnl
       ])])
-    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
-      case "$host_os" in
+    AC_RUN_IFELSE([test -s conftest$ac_exeext],
+        [case "$host_os" in
         # Handle native Windows specially, because there setlocale() interprets
         # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
         # "fr" or "fra" as "French" or "French_France.1252",
@@ -123,9 +123,7 @@ changequote([,])dnl
             fi
           fi
           ;;
-      esac
-    fi
-    rm -fr conftest*
+      esac],[gt_cv_locale_fr=none],[gt_cv_locale_fr=none])
   ])
   LOCALE_FR=$gt_cv_locale_fr
   AC_SUBST([LOCALE_FR])
@@ -201,8 +199,8 @@ int main () {
 }
 changequote([,])dnl
       ])])
-    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
-      case "$host_os" in
+    AC_RUN_IFELSE([test -s conftest$ac_exeext],
+        [case "$host_os" in
         # Handle native Windows specially, because there setlocale() interprets
         # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
         # "fr" or "fra" as "French" or "French_France.1252",
@@ -241,9 +239,7 @@ changequote([,])dnl
             fi
           fi
           ;;
-      esac
-    fi
-    rm -fr conftest*
+      esac],[gt_cv_locale_fr_utf8=none],[gt_cv_locale_fr_utf8=none])
   ])
   LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
   AC_SUBST([LOCALE_FR_UTF8])
diff --git a/gdb/gnulib/import/m4/locale-ja.m4 
b/gdb/gnulib/import/m4/locale-ja.m4
index a3abef8..c8f418d 100644
--- a/gdb/gnulib/import/m4/locale-ja.m4
+++ b/gdb/gnulib/import/m4/locale-ja.m4
@@ -75,8 +75,8 @@ int main ()
 }
 changequote([,])dnl
       ])])
-    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
-      case "$host_os" in
+    AC_RUN_IFELSE([test -s conftest$ac_exeext],
+        [case "$host_os" in
         # Handle native Windows specially, because there setlocale() interprets
         # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
         # "fr" or "fra" as "French" or "French_France.1252",
@@ -127,10 +127,8 @@ changequote([,])dnl
             fi
           fi
           ;;
-      esac
-    fi
-    rm -fr conftest*
-  ])
+      esac],[gt_cv_locale_ja=none],[gt_cv_locale_ja=none]
+  )])
   LOCALE_JA=$gt_cv_locale_ja
   AC_SUBST([LOCALE_JA])
 ])
diff --git a/gdb/gnulib/import/m4/locale-zh.m4 
b/gdb/gnulib/import/m4/locale-zh.m4
index c5c4ef6..1417814 100644
--- a/gdb/gnulib/import/m4/locale-zh.m4
+++ b/gdb/gnulib/import/m4/locale-zh.m4
@@ -76,8 +76,8 @@ int main ()
 }
 changequote([,])dnl
       ])])
-    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
-      case "$host_os" in
+    AC_RUN_IFELSE([test -s conftest$ac_exeext],
+        [case "$host_os" in
         # Handle native Windows specially, because there setlocale() interprets
         # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
         # "fr" or "fra" as "French" or "French_France.1252",
@@ -117,13 +117,7 @@ changequote([,])dnl
             fi
           fi
           ;;
-      esac
-    else
-      # If there was a link error, due to mblen(), the system is so old that
-      # it certainly doesn't have a chinese locale.
-      gt_cv_locale_zh_CN=none
-    fi
-    rm -fr conftest*
+      esac],[gt_cv_locale_zh_CN=none],[gt_cv_locale_zh_CN=none])])
   ])
   LOCALE_ZH_CN=$gt_cv_locale_zh_CN
   AC_SUBST([LOCALE_ZH_CN])

Reply via email to