public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] build vs. host confusion
@ 1998-03-02  6:47 Bruno Haible
  1998-03-13 18:29 ` Jim Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 1998-03-02  6:47 UTC (permalink / raw)
  To: egcs

Hi,

The egcs configuration differs in two points from its documentation (the file
INSTALL and the info files).

  1. When configured as

            ./configure --build=i486-linuxlibc1

     it installs into $(prefix)/lib/gcc-lib/i486-pc-linux-gnulibc1/
     instead of into  $(prefix)/lib/gcc-lib/i486-linuxlibc1/

  2. The TARGET and BUILD values default from HOST. The doc says (and this
     makes much more sense) that the TARGET and HOST values default from
     BUILD.

The confusion comes from the autoconf macro AC_CANONICAL_SYSTEM, which
was designed for programs which know only about HOST and TARGET.

Here is a fix to both.

Sat Feb 28 22:30:13 1998  Bruno Haible  <bruno@linuix.mathematik.uni-karlsruhe.de>

        * aclocal.m4 (GCC_CANONICAL_SYSTEM): New macro.
        * configure.in: Use it.

*** egcs-980214/gcc/configure.in.bak	Sun Feb 22 10:34:03 1998
--- egcs-980214/gcc/configure.in	Sat Feb 28 22:14:59 1998
***************
*** 123,130 ****
  		;;
  esac
  
! # Determine the host, build, and target systems
! AC_CANONICAL_SYSTEM
  
  # Find the native compiler
  AC_PROG_CC
--- 123,130 ----
  		;;
  esac
  
! # Determine the build, host, and target systems
! GCC_CANONICAL_SYSTEM
  
  # Find the native compiler
  AC_PROG_CC
*** egcs-980214/gcc/aclocal.m4.bak	Sun Feb 22 10:33:34 1998
--- egcs-980214/gcc/aclocal.m4	Sat Feb 28 22:12:29 1998
***************
*** 1,3 ****
--- 1,139 ----
+ dnl Canonicalize the build, host, and target system types.
+ dnl The original autoconf macro AC_CANONICAL_SYSTEM determines HOST from
+ dnl config.guess, and has TARGET and BUILD default from HOST.
+ dnl GCC needs to determine BUILD from config.guess, and have HOST and TARGET
+ dnl default from BUILD.
+ AC_DEFUN(GCC_CANONICAL_SYSTEM,
+ [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+ AC_BEFORE([$0], [AC_ARG_PROGRAM])
+ # Do some error checking and defaulting for the host and target type.
+ # The inputs are:
+ #    configure --build=BUILD --host=HOST --target=TARGET NONOPT
+ #
+ # The rules are:
+ # 1. You are not allowed to specify --host, --target, and nonopt at the
+ #    same time.
+ # 2. Build defaults to nonopt.
+ # 3. If nonopt is not specified, then build defaults to the current host,
+ #    as determined by config.guess.
+ # 4. Target and host default to nonopt.
+ # 5. If nonopt is not specified, then target and host default to build.
+ 
+ # The aliases save the names the user supplied, while $host etc.
+ # will get canonicalized.
+ case $host---$target---$nonopt in
+ NONE---*---* | *---NONE---* | *---*---NONE) ;;
+ *) AC_MSG_ERROR(can only configure for one host and one target at a time) ;;
+ esac
+ 
+ GCC_CANONICAL_BUILD
+ GCC_CANONICAL_HOST
+ GCC_CANONICAL_TARGET
+ test "$host_alias" != "$target_alias" &&
+   test "$program_prefix$program_suffix$program_transform_name" = \
+     NONENONEs,x,x, &&
+   program_prefix=${target_alias}-
+ ])
+ 
+ dnl Subroutines of GCC_CANONICAL_SYSTEM.
+ 
+ AC_DEFUN(GCC_CANONICAL_BUILD,
+ [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+ 
+ # Make sure we can run config.sub.
+ if $ac_config_sub sun4 >/dev/null 2>&1; then :
+ else AC_MSG_ERROR(can not run $ac_config_sub)
+ fi
+ 
+ AC_MSG_CHECKING(build system type)
+ 
+ dnl Set build_alias.
+ build_alias=$build
+ case "$build_alias" in
+ NONE)
+   case $nonopt in
+   NONE)
+     if build_alias=`$ac_config_guess`; then :
+     else AC_MSG_ERROR(can not guess build type; you must specify one)
+     fi ;;
+   *) build_alias=$nonopt ;;
+   esac ;;
+ esac
+ 
+ dnl Set the other build vars.
+ changequote(<<, >>)dnl
+ build=`$ac_config_sub $build_alias`
+ build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ changequote([, ])dnl
+ AC_MSG_RESULT($build)
+ AC_SUBST(build)dnl
+ AC_SUBST(build_alias)dnl
+ AC_SUBST(build_cpu)dnl
+ AC_SUBST(build_vendor)dnl
+ AC_SUBST(build_os)dnl
+ ])
+ 
+ AC_DEFUN(GCC_CANONICAL_HOST,
+ [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+ AC_MSG_CHECKING(host system type)
+ 
+ dnl Set host_alias.
+ host_alias=$host
+ case "$host_alias" in
+ NONE)
+   case $nonopt in
+   NONE) host_alias=$build_alias ;;
+   *) host_alias=$nonopt ;;
+   esac ;;
+ esac
+ 
+ dnl Set the other host vars.
+ changequote(<<, >>)dnl
+ host=`$ac_config_sub $host_alias`
+ host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ changequote([, ])dnl
+ AC_MSG_RESULT($host)
+ AC_SUBST(host)dnl
+ AC_SUBST(host_alias)dnl
+ AC_SUBST(host_cpu)dnl
+ AC_SUBST(host_vendor)dnl
+ AC_SUBST(host_os)dnl
+ ])
+ 
+ AC_DEFUN(GCC_CANONICAL_TARGET,
+ [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+ AC_MSG_CHECKING(target system type)
+ 
+ dnl Set target_alias.
+ target_alias=$target
+ case "$target_alias" in
+ NONE)
+   case $nonopt in
+   NONE) target_alias=$build_alias ;;
+   *) target_alias=$nonopt ;;
+   esac ;;
+ esac
+ 
+ dnl Set the other target vars.
+ changequote(<<, >>)dnl
+ target=`$ac_config_sub $target_alias`
+ target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ changequote([, ])dnl
+ AC_MSG_RESULT($target)
+ AC_SUBST(target)dnl
+ AC_SUBST(target_alias)dnl
+ AC_SUBST(target_cpu)dnl
+ AC_SUBST(target_vendor)dnl
+ AC_SUBST(target_os)dnl
+ ])
+ 
+ 
  dnl See whether we need a declaration for a function.
  AC_DEFUN(GCC_NEED_DECLARATION,
  [AC_MSG_CHECKING([whether $1 must be declared])

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] build vs. host confusion
  1998-03-02  6:47 [patch] build vs. host confusion Bruno Haible
@ 1998-03-13 18:29 ` Jim Wilson
  1998-03-16 11:20   ` Craig Burley
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Wilson @ 1998-03-13 18:29 UTC (permalink / raw)
  To: Bruno Haible; +Cc: egcs

	The egcs configuration differs in two points from its documentation (the file
	INSTALL and the info files).

	  1. When configured as

            ./configure --build=i486-linuxlibc1

	     it installs into $(prefix)/lib/gcc-lib/i486-pc-linux-gnulibc1/
	     instead of into  $(prefix)/lib/gcc-lib/i486-linuxlibc1/

	  2. The TARGET and BUILD values default from HOST. The doc says (and this
	     makes much more sense) that the TARGET and HOST values default from
	     BUILD.

It is the documentation that is wrong in both cases.  Gcc is behaving as it
should.

If a user specifies a configuration name, and the string is different
than what config.guess returns, then there is no easy way to tell whether
whether this is the same configuration or not.  We handle this by making
some simplifying assumptions.  --target implies a cross build.  --host implies
a native build.  --build implies some kind of canadian (3-way) cross build,
where the build and host machine are different.

Since canadian crosses are the most obscure kind of build, we use the most
obscure option --build to indicate them.  This also has the advantage that
gcc behaves the same as other packages that do not understand --build.
That is, you can configure a native build using --host for any GNU package.
If gcc and friends used --build for a native build, then users would have to
remember to use configure --host for some packages and configure --build
for other packages, and this would be so confusing that too many people
would get it wrong.  So using --host for native builds is the best choice.
We have been doing things this way for so long that there is no point to
changing it.

This also has the advantage that gcc2 is consistent with gcc1.  This may not
be very relevant now, but it was when we decided to do things this way.

Jim

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] build vs. host confusion
  1998-03-13 18:29 ` Jim Wilson
@ 1998-03-16 11:20   ` Craig Burley
  0 siblings, 0 replies; 3+ messages in thread
From: Craig Burley @ 1998-03-16 11:20 UTC (permalink / raw)
  To: haible, egcs

I seem to recall bringing up this (or a similar) confusion quite
awhile ago (probably during 1997) on the gcc2 list.

Generally, GNU and other programs use "host" to denote the
system on which the program is being built and "target" to
denote the system on which the program is to be run.  For
most programs, this (a two-system-labeling approach) is adequate.

Compilers like gcc have a third system -- the system on which
code (programs) they *generate* is to be run.

Unfortunately (from one point of view), for compilers, we've
been changing the terminology.  "host" denotes what "target"
means elsewhere -- the system on which the program (that is,
the *compiler*) is to be run, and "target" denotes this third
system, the one on which code produced by the compiler is to
be run.  "build" is introduced to denote the system on which
the compiler is to be built -- the term "host" is used for
this when discussing other, non-code-generating programs.

I believe I suggested we consider changing the terminology
of gcc2, but it was considered to be way too late for that
(almost certainly the case now, and probably then as well).

Anyway, if the current docs don't clarify this difference for
people who look at the issue as described above (and, note that
compiler people might tend to look at it the "other" way, i.e.
not think of the compiler as "just another program"), then
perhaps they should be improved to do so.

        tq vm, (burley)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-03-16 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-02  6:47 [patch] build vs. host confusion Bruno Haible
1998-03-13 18:29 ` Jim Wilson
1998-03-16 11:20   ` Craig Burley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).