On 16 Jun 2000, Alexandre Oliva wrote:

> GCC and Sourceware src (== Cygnus)'s top-level configure always passes
> --build, --host and --target down to sub-directories.  Therefore, we
> must not assume that, just because --host is given, we're cross
> compiling.
> 
> Comparing build with host and deciding for cross compilation if they
> differ might be reasonable, but it still breaks backward
> compatibility, and some Cygnus folks have complained about having to
> modify lots of scripts to accomodate this change.

What this basically comes down to is, should --host=$TRIPLE
automatically assume a cross compile? The current version
of autoconf breaks backward compatibility with older
versions in the case where people are using the
--host argument to indicate the build system. It is
debatable if that is right or wrong, but it is the
way autoconf used to work. The downside to switching
back to the old approach is that it makes cross
compiling harder as folks would need to
give both --build and --host to do a cross.


There is a case where the new behavior is clearly wrong.
That is when --build and --host are both given and they
are exactly the same. I have appended a patch to
fix that problem.

Mo DeJong
Red Hat Inc

Index: acgeneral.m4
===================================================================
RCS file: /cvs/autoconf/acgeneral.m4,v
retrieving revision 1.488
diff -u -r1.488 acgeneral.m4
--- acgeneral.m4        2000/06/16 17:40:44     1.488
+++ acgeneral.m4        2000/06/16 18:48:13
@@ -829,7 +829,6 @@
 # Initializations.
 #
 ac_default_prefix=/usr/local
-cross_compiling=no
 subdirs=
 MFLAGS= MAKEFLAGS=
 AC_SUBST(SHELL, ${CONFIG_SHELL-/bin/sh})dnl
@@ -1054,10 +1053,8 @@
     ac_init_help=short ;;
 
   -host | --host | --hos | --ho)
-    cross_compiling=yes
     ac_prev=host_alias ;;
   -host=* | --host=* | --hos=* | --ho=*)
-    cross_compiling=yes
     host_alias=$ac_optarg ;;
 
   -includedir | --includedir | --includedi | --included | --include \
@@ -1289,9 +1286,18 @@
 host=$host_alias
 target=$target_alias
 
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
+# There might be people who have scripts that pass in --build and --host.
+# In this case, we do not want to cross compile if the --build and --host
+# arguments are exactly the same (it is just a native build). In the
+# case where only --host is given we want to do a Canadian cross.
+
+if test "x$host_alias" = "x" || test "$host_alias" = "$build_alias" ; then
+  cross_compiling=no
+  ac_tool_prefix=
+else
+  cross_compiling=yes
+  ac_tool_prefix=$host_alias-
+fi
 AC_DIVERT_POP()dnl
 ])# _AC_INIT_PARSE_ARGS
 
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.34
diff -u -r1.34 aclang.m4
--- aclang.m4   2000/06/09 11:14:05     1.34
+++ aclang.m4   2000/06/16 18:48:14
@@ -469,9 +469,14 @@
 # AC_LANG_COMPILER_WORKS
 # ----------------------
 define([_AC_LANG_COMPILER_WORKS],
-[AC_MSG_CHECKING([whether the _AC_LANG compiler works])
+[
+AC_MSG_CHECKING([whether we are cross compiling])
+AC_MSG_RESULT($cross_compiling)
+
+AC_MSG_CHECKING([whether the _AC_LANG compiler works])
 AC_LINK_IFELSE([AC_LANG_PROGRAM()],
-[# If not cross compiling, check that we can run a simple program.
+[
+# If not cross compiling, check that we can run a simple program.
 if test $cross_compiling != yes; then
   if AC_TRY_COMMAND(./conftest); then :; else
     AC_MSG_RESULT(no)


Reply via email to