This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gnattools cannot be built for freestanding/bare metal environment without hacking up the build machinery


On Fri, 2014-02-14 at 12:11 +0000, Brian Drummond wrote:

> Revisiting the MSP430 as it's now an official gcc target, this is still a
> problem here too, so there are at least 3 targets for which it's a problem.

It's a problem for all targets.

> Looking at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19959
> and comparing comments #6 and #14, perhaps this command should be 
> "make -C gcc gnattools-cross" ? I'll try to do a clean build and test this
> today.
> 

It won't work, I've tried all those so called work arounds. They rely on
having libada built, it will complain to say that it can't be built
because there is no libada. See the attachments.

> But it would be better if the build "just worked" so at
> 
> > if test "${ENABLE_LIBADA}" != "yes" ; then
> >   noconfigdirs="$noconfigdirs"
> > fi
> we need a better test here (also checking for a crosscompiler build).

I have added one. It does work, sort of.

> > I think that we need a configure flag to disable libada and not
> > gnattools for these bare board targets.
> 
> Following comment #15 in bug 19959, perhaps it's time to open a bug against
> --disable-libada.

The attachments allow you to configure the toolchain for bare metal, no
RTS. This flag is --enable-cross-gnattools, it checks if this is a cross
compiler and if it is, disables libada, but not gnattools.

There is an issue and I don't know why it does this, but it won't allow
you to build the gnattools straight away. You have to use:

make all-gcc
make -C gnattools/ gnattools
rm gcc/stamp-tools
make -C gcc cross-gnattools
make install-gcc

This will then build.

I have not checked to see if you can still build gcc for normal hosted
with this patch, neither have I checked to make sure --disable-libada
works in hosted either.

I have built the following with these patches:

arm-none-eabi
mips-elf
msp430-elf
x86_64-elf

Not one installs libada and I have gnattools:

$ ls ~/opt/tinyada/lib/gcc/arm-none-eabi/4.9.0/
include  include-fixed  install-tools  plugin
$ ls ~/opt/tinyada/lib/gcc/mips-elf/4.9.0/
include  include-fixed  install-tools  plugin
$ ls ~/opt/tinyada/lib/gcc/msp430-elf/4.9.0/
include  include-fixed  install-tools  plugin
$ ls ~/opt/tinyada/lib/gcc/x86_64-elf/4.9.0/
include  include-fixed  install-tools  plugin

Luke.

>From f8c74c16b9f7ef3be02a9a7d3480baf88d09efd6 Mon Sep 17 00:00:00 2001
From: "Luke A. Guest" <laguest@archeia.com>
Date: Fri, 14 Feb 2014 13:53:27 +0000
Subject: [PATCH 1/2] Set the target for a bare metal environment.

---
 gnattools/configure    | 9 +++++++++
 gnattools/configure.ac | 9 +++++++++
 2 files changed, 18 insertions(+)

diff --git a/gnattools/configure b/gnattools/configure
index 883b705..b5bf03d 100755
--- a/gnattools/configure
+++ b/gnattools/configure
@@ -2090,6 +2090,15 @@ case "${target}" in
     indepsw.adb<indepsw-mingw.adb"
     EXTRA_GNATTOOLS='../../gnatdll$(exeext)'
     ;;
+  # Any bare machine stuff can go here, i.e. mips-elf, arm-elf,
+  # arm-none-eabi-elf, etc.
+  #
+  # This file just enables the ability to build static libs with gnatmake and
+  # project files.
+  *-*-elf* | *-*-eabi*)
+    TOOLS_TARGET_PAIRS="\
+    mlib-tgt-specific.adb<mlib-tgt-specific-xi.adb"
+    ;;
 esac
 
 # From user or toplevel makefile.
diff --git a/gnattools/configure.ac b/gnattools/configure.ac
index 5edaadf..dbdc958 100644
--- a/gnattools/configure.ac
+++ b/gnattools/configure.ac
@@ -130,6 +130,15 @@ case "${target}" in
     indepsw.adb<indepsw-mingw.adb"
     EXTRA_GNATTOOLS='../../gnatdll$(exeext)'
     ;;
+  # Any bare machine stuff can go here, i.e. mips-elf, arm-elf,
+  # arm-none-eabi-elf, etc.
+  #
+  # This file just enables the ability to build static libs with gnatmake and
+  # project files.
+  *-*-elf* | *-*-eabi*)
+    TOOLS_TARGET_PAIRS="\
+    mlib-tgt-specific.adb<mlib-tgt-specific-xi.adb"
+    ;;
 esac
 
 # From user or toplevel makefile.
-- 
1.8.5.3

>From a2b4516f93f4d99e5ddae4c1eed78f2014f0875b Mon Sep 17 00:00:00 2001
From: "Luke A. Guest" <laguest@archeia.com>
Date: Fri, 14 Feb 2014 13:54:29 +0000
Subject: [PATCH 2/2] Added --enable-cross-gnattools flag for bare metal
 environment.

---
 configure    | 25 ++++++++++++++++++++++--
 configure.ac | 63 ++++++++++++++++++++++++++++++++++++------------------------
 2 files changed, 61 insertions(+), 27 deletions(-)

diff --git a/configure b/configure
index 749a35e..c0d706d 100755
--- a/configure
+++ b/configure
@@ -749,6 +749,7 @@ enable_ld
 enable_libquadmath
 enable_libquadmath_support
 enable_libada
+enable_cross_gnattools
 enable_libssp
 enable_libstdcxx
 enable_static_libjava
@@ -1466,6 +1467,10 @@ Optional Features:
   --disable-libquadmath-support
                           disable libquadmath support for Fortran
   --enable-libada         build libada directory
+  --enable-cross-gnattools
+                          Enable cross gnattools for cross-compiler for
+                          freestanding environment, --disable-libada is set
+                          automatically
   --enable-libssp         build libssp directory
   --disable-libstdcxx     do not build libstdc++-v3 directory
   --enable-static-libjava[=ARG]
@@ -3068,8 +3073,24 @@ else
   ENABLE_LIBADA=yes
 fi
 
-if test "${ENABLE_LIBADA}" != "yes" ; then
-  noconfigdirs="$noconfigdirs gnattools"
+
+# Check whether --enable-cross-gnattools was given.
+if test "${enable_cross_gnattools+set}" = set; then :
+  enableval=$enable_cross_gnattools; ENABLE_CROSS_GNATTOOLS=$enableval
+else
+  ENABLE_CROSS_GNATTOOLS=yes
+fi
+
+
+if test "${is_cross_compiler}" = "yes" && test "${ENABLE_CROSS_GNATTOOLS}" = "yes" ; then
+  if test "${target_vendor}" = "none" || test "${target_vendor}" = "unknown" ; then
+    enable_libada=no
+    ENABLE_LIBADA=$enable_libada
+  fi
+else
+  if test "${ENABLE_LIBADA}" != "yes" ; then
+    noconfigdirs="$noconfigdirs gnattools"
+  fi
 fi
 
 # Check whether --enable-libssp was given.
diff --git a/configure.ac b/configure.ac
index b24b33d..4fcac1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,11 +113,11 @@ extra_host_args=
 ### or a host dependent tool.  Then put it into the appropriate list
 ### (library or tools, host or target), doing a dependency sort.
 
-# Subdirs will be configured in the order listed in build_configdirs, 
+# Subdirs will be configured in the order listed in build_configdirs,
 # configdirs, or target_configdirs; see the serialization section below.
 
-# Dependency sorting is only needed when *configuration* must be done in 
-# a particular order.  In all cases a dependency should be specified in 
+# Dependency sorting is only needed when *configuration* must be done in
+# a particular order.  In all cases a dependency should be specified in
 # the Makefile, whether or not it's implicitly specified here.
 
 # Double entries in build_configdirs, configdirs, or target_configdirs may
@@ -214,7 +214,7 @@ if test x"${host}" = x"${target}" ; then
   is_cross_compiler=no
 else
   is_cross_compiler=yes
-fi	
+fi
 
 # Find the build and target subdir names.
 GCC_TOPLEV_SUBDIRS
@@ -250,7 +250,7 @@ if test x$with_system_zlib = xyes ; then
   noconfigdirs="$noconfigdirs zlib"
 fi
 
-# some tools are so dependent upon X11 that if we're not building with X, 
+# some tools are so dependent upon X11 that if we're not building with X,
 # it's not even worth trying to configure, much less build, that tool.
 
 case ${with_x} in
@@ -258,7 +258,7 @@ case ${with_x} in
   no)
     skipdirs="${skipdirs} tk itcl libgui"
     # We won't be able to build gdbtk without X.
-    enable_gdbtk=no 
+    enable_gdbtk=no
     ;;
   *)  echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2 ;;
 esac
@@ -384,7 +384,7 @@ esac
 # Only spaces may be used in this macro; not newlines or tabs.
 unsupported_languages=
 
-# Remove more programs from consideration, based on the host or 
+# Remove more programs from consideration, based on the host or
 # target this usually means that a port of the program doesn't
 # exist yet.
 
@@ -420,8 +420,21 @@ AC_ARG_ENABLE(libada,
 [AS_HELP_STRING([--enable-libada], [build libada directory])],
 ENABLE_LIBADA=$enableval,
 ENABLE_LIBADA=yes)
-if test "${ENABLE_LIBADA}" != "yes" ; then
-  noconfigdirs="$noconfigdirs gnattools"
+
+AC_ARG_ENABLE(cross-gnattools,
+[AS_HELP_STRING([--enable-cross-gnattools], [Enable cross gnattools for cross-compiler for freestanding environment, --disable-libada is set automatically])],
+ENABLE_CROSS_GNATTOOLS=$enableval,
+ENABLE_CROSS_GNATTOOLS=yes)
+
+if test "${is_cross_compiler}" = "yes" && test "${ENABLE_CROSS_GNATTOOLS}" = "yes" ; then
+  if test "${target_vendor}" = "none" || test "${target_vendor}" = "unknown" ; then
+    enable_libada=no
+    ENABLE_LIBADA=$enable_libada
+  fi
+else
+  if test "${ENABLE_LIBADA}" != "yes" ; then
+    noconfigdirs="$noconfigdirs gnattools"
+  fi
 fi
 
 AC_ARG_ENABLE(libssp,
@@ -768,7 +781,7 @@ case "${target}" in
     ;;
   *-*-lynxos*)
     noconfigdirs="$noconfigdirs ${libgcj}"
-    ;; 
+    ;;
 esac
 
 # Disable libgo for some systems where it is known to not work.
@@ -873,7 +886,7 @@ case "${target}" in
     ;;
   *-*-lynxos*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
-    ;; 
+    ;;
   *-*-mingw*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
@@ -1183,7 +1196,7 @@ case "${host}" in
   hppa*-hp-hpux*)
     host_makefile_frag="config/mh-pa"
     ;;
-  hppa*-*)	
+  hppa*-*)
     host_makefile_frag="config/mh-pa"
     ;;
   *-*-darwin*)
@@ -1857,7 +1870,7 @@ if test -d ${srcdir}/gcc; then
       # an apparent bug in bash 1.12 on linux.
       ${srcdir}/gcc/[[*]]/config-lang.in) ;;
       *)
-        # From the config-lang.in, get $language, $target_libs, 
+        # From the config-lang.in, get $language, $target_libs,
         # $lang_dirs, $boot_language, and $build_by_default
         language=
         target_libs=
@@ -2110,7 +2123,7 @@ done
 build_configdirs_all="$build_configdirs"
 build_configdirs=
 for i in ${build_configdirs_all} ; do
-  j=`echo $i | sed -e s/build-//g` 
+  j=`echo $i | sed -e s/build-//g`
   if test -f ${srcdir}/$j/configure ; then
     build_configdirs="${build_configdirs} $i"
   fi
@@ -2127,7 +2140,7 @@ done
 target_configdirs_all="$target_configdirs"
 target_configdirs=
 for i in ${target_configdirs_all} ; do
-  j=`echo $i | sed -e s/target-//g` 
+  j=`echo $i | sed -e s/target-//g`
   if test -f ${srcdir}/$j/configure ; then
     target_configdirs="${target_configdirs} $i"
   fi
@@ -2178,7 +2191,7 @@ ACX_TOOL_DIRS
 
 copy_dirs=
 
-AC_ARG_WITH([build-sysroot], 
+AC_ARG_WITH([build-sysroot],
   [AS_HELP_STRING([--with-build-sysroot=SYSROOT],
 		  [use sysroot as the system root during the build])],
   [if test x"$withval" != x ; then
@@ -2269,11 +2282,11 @@ fi
 # This is done by determining whether or not the appropriate directory
 # is available, and by checking whether or not specific configurations
 # have requested that this magic not happen.
-# 
-# The command line options always override the explicit settings in 
+#
+# The command line options always override the explicit settings in
 # configure.in, and the settings in configure.in override this magic.
 #
-# If the default for a toolchain is to use GNU as and ld, and you don't 
+# If the default for a toolchain is to use GNU as and ld, and you don't
 # want to do that, then you should use the --without-gnu-as and
 # --without-gnu-ld options for the configure script.  Similarly, if
 # the default is to use the included zlib and you don't want to do that,
@@ -2374,7 +2387,7 @@ case "${target}" in
     target_makefile_frag="config/mt-gnu"
     ;;
   *-*-aix4.[[3456789]]* | *-*-aix[[56789]].*)
-    # nm and ar from AIX 4.3 and above require -X32_64 flag to all ar and nm 
+    # nm and ar from AIX 4.3 and above require -X32_64 flag to all ar and nm
     # commands to handle both 32-bit and 64-bit objects.  These flags are
     # harmless if we're using GNU nm or ar.
     extra_arflags_for_target=" -X32_64"
@@ -2444,7 +2457,7 @@ if test $? = 0 ; then
   if test -s conftest || test -s conftest.exe ; then
     we_are_ok=yes
   fi
-fi 
+fi
 case $we_are_ok in
   no)
     echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
@@ -2824,7 +2837,7 @@ baseargs=`echo "x$baseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
 # --program-suffix have been applied to it.  Autoconf has already
 # doubled dollar signs and backslashes in program_transform_name; we want
 # the backslashes un-doubled, and then the entire thing wrapped in single
-# quotes, because this will be expanded first by make and then by the shell. 
+# quotes, because this will be expanded first by make and then by the shell.
 # Also, because we want to override the logic in subdir configure scripts to
 # choose program_transform_name, replace any s,x,x, with s,y,y,.
 sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" <<EOF_SED > conftestsed.out
@@ -2891,7 +2904,7 @@ case "$target:$have_compiler:$host:$target:$enable_multilib" in
       if test -s conftest || test -s conftest.exe ; then
 	dev64=yes
       fi
-    fi 
+    fi
     rm -f conftest*
     if test x${dev64} != xyes ; then
       AC_MSG_ERROR([I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.])
@@ -3169,7 +3182,7 @@ AC_SUBST(CFLAGS)
 AC_SUBST(CXXFLAGS)
 
 # Target tools.
-AC_ARG_WITH([build-time-tools], 
+AC_ARG_WITH([build-time-tools],
   [AS_HELP_STRING([--with-build-time-tools=PATH],
 		  [use given path to find target tools during the build])],
   [case x"$withval" in
@@ -3274,7 +3287,7 @@ if test "$USE_MAINTAINER_MODE" = yes; then
 else
   MAINTAINER_MODE_TRUE='#'
   MAINTAINER_MODE_FALSE=
-fi	
+fi
 MAINT=$MAINTAINER_MODE_TRUE
 AC_SUBST(MAINT)dnl
 
-- 
1.8.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]