Hi DJ Delorie,

I did not specify all the commandline arguments used in my email. I am
using --build=<build> in the GCC builds (as required). The build arguments
in use when things go pair shaped are:
'/L64/src/gcc-4.0.0/gcc-4.0.2-p01/configure --build=i686-pc-linux-gnu
--target=sparc-linux --host=sparc-linux --prefix=/usr/crbld
--with-sysroot=/L64/sparc/tree/sparc-linux/sys-root
--includedir=/usr/include --with-local-prefix=/usr/local --disable-nls
--enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit
--enable-languages=c,c++,ada --enable-shared --enable-c99
--enable-long-long'

I have found three issues so far. They are all in the ADA build. They are:

1) For native compiler builds, the build system assumes it can compile and
then run gnatmake using the <host> compiler. This only works if <host> =
<build>. The fix I have used is to force a cross compilation. Under this
situation, the compiler build system does not fall for this error. I will
take another look at this and try to refine my changes so that they only
change things that are visibly incorrect. The error shows up when the
compilation gets to gcc-4.0.2/gcc/ada/Make-lang.in line 370. The problems
identified are:
 a) GCC_FOR_TARGET is set to ./xgcc {arguments} but ./xgcc will not run on
the <build> host.
 b) SET_GCC_LIB_PATH_CMD is set to include the build directory. This is
not valid when compiled code will not run on <build>.

2) The build system assumes that ../../xgcc will run even if <build> is
not the same as <host>. This can be fixed by changing the
gcc-4.0.2-p01/gcc/ada/Makefile.in gnatlib target to use a configuration
defined CC. See patch below:

---------------------- PATCH ---------------------------
diff -ru gcc-4.0.2/gcc/ada/Makefile.in gcc-4.0.2-p01/gcc/ada/Makefile.in
--- gcc-4.0.2/gcc/ada/Makefile.in       2005-10-26 17:52:33.000000000 +0100
+++ gcc-4.0.2-p01/gcc/ada/Makefile.in   2005-11-01 08:14:46.000000000 +0000
@@ -135,6 +135,7 @@
 MISCLIB =
 SYMDEPS = $(LIBINTL_DEP)
 OUTPUT_OPTION = @OUTPUT_OPTION@
[EMAIL PROTECTED]@
 
 objext = .o
 exeext =
@@ -1825,12 +1826,12 @@
 # is guaranteed to overflow the buffer.
 
 gnatlib: ../stamp-gnatlib1 ../stamp-gnatlib2
-       $(MAKE) -C rts CC="../../xgcc -B../../" \
+       $(MAKE) -C rts CC="$(GNATLIB_GCC)" \
                INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
                 CFLAGS="$(GNATLIBCFLAGS_FOR_C)" \
                srcdir=$(fsrcdir) \
                -f ../Makefile $(LIBGNAT_OBJS)
-       $(MAKE) -C rts CC="../../xgcc -B../../" \
+       $(MAKE) -C rts CC="$(GNATLIB_GCC)" \
                ADA_INCLUDES="" \
                 CFLAGS="$(GNATLIBCFLAGS)" \
                ADAFLAGS="$(GNATLIBFLAGS)" \
diff -ru gcc-4.0.2/gcc/configure.ac gcc-4.0.2-p01/gcc/configure.ac
--- gcc-4.0.2/gcc/configure.ac  2005-10-29 02:22:29.000000000 +0100
+++ gcc-4.0.2-p01/gcc/configure.ac      2005-10-29 18:30:49.000000000 +0100
@@ -3331,6 +3331,7 @@
     echo "Links are now set up to build a cross-compiler" 1>&2
     echo " from ${host} to ${target}." 1>&2
   fi
+  GNATLIB_GCC="../../xgcc -B../../"
 else
   if test x${host} = x${target} ; then
     echo "Links are now set up to build (on ${build}) a native compiler" 1>&2
@@ -3339,8 +3340,11 @@
     echo "Links are now set up to build (on ${build}) a cross-compiler" 1>&2
     echo " from ${host} to ${target}." 1>&2
   fi
+  GNATLIB_GCC="${target_alias}-gcc"
 fi
 
+AC_SUBST(GNATLIB_GCC)
+
 AC_ARG_VAR(GMPLIBS,[How to link GMP])
 AC_ARG_VAR(GMPINC,[How to find GMP include files])
 
diff -ru gcc-4.0.2/gcc/configure gcc-4.0.2-p01/gcc/configure
--- gcc-4.0.2/gcc/configure     2005-10-29 02:22:29.000000000 +0100
+++ gcc-4.0.2-p01/gcc/configure 2005-10-29 18:31:42.000000000 +0100
@@ -309,7 +309,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME 
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix 
program_transform_name bindir sbindir libexecdir datadir sysconfdir 
sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir 
build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build 
build_cpu build_vendor build_os host host_cpu host_vendor host_os target 
target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir 
target_subdir gcc_version_trigger gcc_version_full gcc_version GENINSRC CC 
CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION 
CPP EGREP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER 
valgrind_path valgrind_path_defines valgrind_command coverage_flags 
enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE 
CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB 
ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target 
have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR 
stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV 
LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file PACKAGE 
VERSION USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS 
cc_for_cross_gnattools CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD 
BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 libgcc_visibility GGC zlibdir 
zlibinc MAINT gcc_tooldir dollar slibdir objdir subdirs srcdir 
all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs 
all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages 
all_stagestuff build_exeext build_install_headers_dir build_xm_file_list 
build_xm_include_list build_xm_defines check_languages cc_set_by_configure 
quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs 
extra_headers_list extra_objs extra_parts extra_passes extra_programs 
float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir 
host_exeext host_xm_file_list host_xm_include_list host_xm_defines 
out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files 
local_prefix md_file objc_boehm_gc out_file out_object_file 
stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure thread_file 
tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list 
xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs 
target_cpu_default set_gcc_lib_path GMPLIBS GMPINC LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME 
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix 
program_transform_name bindir sbindir libexecdir datadir sysconfdir 
sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir 
build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build 
build_cpu build_vendor build_os host host_cpu host_vendor host_os target 
target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir 
target_subdir gcc_version_trigger gcc_version_full gcc_version GENINSRC CC 
CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION 
CPP EGREP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER 
valgrind_path valgrind_path_defines valgrind_command coverage_flags 
enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE 
CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB 
ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target 
have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR 
stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV 
LTLIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file PACKAGE 
VERSION USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS 
cc_for_cross_gnattools CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD 
BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 libgcc_visibility GGC zlibdir 
zlibinc MAINT gcc_tooldir dollar slibdir objdir subdirs srcdir 
all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs 
all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages 
all_stagestuff build_exeext build_install_headers_dir build_xm_file_list 
build_xm_include_list build_xm_defines check_languages cc_set_by_configure 
quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs 
extra_headers_list extra_objs extra_parts extra_passes extra_programs 
float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir 
host_exeext host_xm_file_list host_xm_include_list host_xm_defines 
out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files 
local_prefix md_file objc_boehm_gc out_file out_object_file 
stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure thread_file 
tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list 
xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs 
target_cpu_default GNATLIB_GCC set_gcc_lib_path GMPLIBS GMPINC LIBOBJS 
LTLIBOBJS'
 ac_subst_files='language_hooks'
 
 # Initialize some variables set by options.
@@ -15430,6 +15430,7 @@
     echo "Links are now set up to build a cross-compiler" 1>&2
     echo " from ${host} to ${target}." 1>&2
   fi
+  GNATLIB_GCC="../../xgcc -B../../"
 else
   if test x${host} = x${target} ; then
     echo "Links are now set up to build (on ${build}) a native compiler" 1>&2
@@ -15438,6 +15439,7 @@
     echo "Links are now set up to build (on ${build}) a cross-compiler" 1>&2
     echo " from ${host} to ${target}." 1>&2
   fi
+  GNATLIB_GCC="${target_alias}-gcc"
 fi
 
 
@@ -16241,6 +16243,7 @@
 s,@c_target_objs@,$c_target_objs,;t t
 s,@cxx_target_objs@,$cxx_target_objs,;t t
 s,@target_cpu_default@,$target_cpu_default,;t t
+s,@GNATLIB_GCC@,$GNATLIB_GCC,;t t
 s,@set_gcc_lib_path@,$set_gcc_lib_path,;t t
 s,@GMPLIBS@,$GMPLIBS,;t t
 s,@GMPINC@,$GMPINC,;t t
---------------------- END OF PATCH --------------------

3) The ADA library/tools directory tries to use the <build> tools when it
should be using <target>-<tool> tools. The 'hack' I have used to fix this
is in the patch below. It detects that if the with_cross_host is the same
as the build host. If not, it assumes the compilation should be using
<target>-<tools>. I believe more work may be needed here as my hack is not
ideal (a more meaningfull name for the variable I am using for a start):

---------------------- PATCH ---------------------------
diff -ru gcc-4.0.2/libada/Makefile.in gcc-4.0.2-p01/libada/Makefile.in
--- gcc-4.0.2/libada/Makefile.in        2005-10-29 02:22:05.000000000 +0100
+++ gcc-4.0.2-p01/libada/Makefile.in    2005-10-29 18:51:54.000000000 +0100
@@ -32,6 +32,7 @@
 enable_shared = @enable_shared@
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@
[EMAIL PROTECTED]@
 
 # Variables for the user (or the top level) to override.
 objext=.o
@@ -160,13 +161,13 @@
 # put the host RTS dir first in the PATH to hide the default runtime
 # files that are among the sources
 # FIXME: This should be done in configure.
-RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib )))
+RTS_DIR:=$(strip $(subst \,/,$(shell ${canadian_alias}gnatls -v | grep adalib 
)))
 gnattools-cross: gnatlib
        $(MAKE)  -C $(GCC_DIR)/ada $(FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \
          ADA_INCLUDES="-I$(RTS_DIR)../adainclude -I$(RTS_DIR)" \
-         GNATMAKE="gnatmake" \
-         GNATBIND="gnatbind" \
-         GNATLINK="gnatlink" \
+         GNATMAKE="${canadian_alias}gnatmake" \
+         GNATBIND="${canadian_alias}gnatbind" \
+         GNATLINK="${canadian_alias}gnatlink" \
          LIBGNAT="" \
          gnattools1-re gnattools2 gnattools4
        # Rename cross tools to where the GCC makefile wants them when
diff -ru gcc-4.0.2/libada/configure.ac gcc-4.0.2-p01/libada/configure.ac
--- gcc-4.0.2/libada/configure.ac       2005-10-26 17:52:45.000000000 +0100
+++ gcc-4.0.2-p01/libada/configure.ac   2005-10-29 22:56:35.000000000 +0100
@@ -95,6 +95,14 @@
 fi
 AC_SUBST([default_gnattools_target])
 
+# Sort out programs to use for canadian builds
+if test ${build} = ${with_cross_host} ; then
+    canadian_alias=""
+else
+    canadian_alias="${target_noncanonical}-"
+fi
+AC_SUBST([canadian_alias])
+
 # Output: create a Makefile.
 AC_CONFIG_FILES([Makefile])
 
diff -ru gcc-4.0.2/libada/configure gcc-4.0.2-p01/libada/configure
--- gcc-4.0.2/libada/configure  2005-10-26 17:52:45.000000000 +0100
+++ gcc-4.0.2-p01/libada/configure      2005-10-29 22:57:52.000000000 +0100
@@ -272,7 +272,7 @@
 PACKAGE_BUGREPORT=
 
 ac_unique_file="Makefile.in"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME 
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix 
program_transform_name bindir sbindir libexecdir datadir sysconfdir 
sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir 
build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINT 
enable_shared INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu 
build_vendor build_os host host_cpu host_vendor host_os target target_cpu 
target_vendor target_os target_noncanonical LN_S x_ada_cflags 
default_gnatlib_target default_gnattools_target LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME 
PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix 
program_transform_name bindir sbindir libexecdir datadir sysconfdir 
sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir 
build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINT 
enable_shared INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA build build_cpu 
build_vendor build_os host host_cpu host_vendor host_os target target_cpu 
target_vendor target_os target_noncanonical LN_S x_ada_cflags 
default_gnatlib_target default_gnattools_target canadian_alias LIBOBJS 
LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -1569,6 +1569,12 @@
   default_gnattools_target="gnattools-cross"
 fi
 
+# Sort out programs to use for canadian builds
+if test ${build} = ${with_cross_host} ; then
+    canadian_alias=""
+else
+    canadian_alias="${target_noncanonical}-"
+fi
 
 # Output: create a Makefile.
           ac_config_files="$ac_config_files Makefile"
@@ -2231,6 +2237,7 @@
 s,@x_ada_cflags@,$x_ada_cflags,;t t
 s,@default_gnatlib_target@,$default_gnatlib_target,;t t
 s,@default_gnattools_target@,$default_gnattools_target,;t t
+s,@canadian_alias@,$canadian_alias,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
---------------------- END OF PATCH --------------------

There is an additional typing error in gcc-4.0.2/gcc/ada/s-pack29.adb
(also in gcc-3.4.x).
---------------------- PATCH ---------------------------
diff -ru gcc-4.0.2/gcc/ada/s-pack29.adb gcc-4.0.2-p01/gcc/ada/s-pack29.adb
--- gcc-4.0.2/gcc/ada/s-pack29.adb      2005-10-26 14:51:10.000000000 +0100
+++ gcc-4.0.2-p01/gcc/ada/s-pack29.adb  2005-10-27 15:24:05.000000000 +0100
@@ -13,7 +13,7 @@
 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
--- or FITNESS FOR A PARUICULAR PURPOSE.  See the GNU General Public License --
+-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
---------------------- END OF PATCH --------------------

On Sat, 29 Oct 2005, DJ Delorie wrote:

> 
> > In a Canadian Cross Compile, 'target' == 'host' != 'build' and the
> > compiler that is created may not run on the computer building the
> > compiler.
> 
> You're describing a cross-built native, not a canadian.
> http://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
> 
> Whenever --target=foo and build!=host, you need to have a pre-built
> foo-gcc that runs on $build.
> 
> One obvious bug I see in your scripts is that you are specifying
> --host without also specifying --build.  The documentation explicitly
> tells you to never do that.  Your last step is attempting to build a
> NATIVE compiler, assuming that the machine it's running on is
> sparc-linux.
> 

Reply via email to