Hello,

in gcc/Makefile, there is a test to determine how to set up the GCC provided limits.h. Here is a collection of the relevant Makefile parts:

# ------------------------
# Installation directories
# ------------------------

# Common prefix for installation directories.
# NOTE: This directory must exist when you start installation.
prefix = /the/prefix

# Directory in which to put host dependent programs and libraries
exec_prefix = ${prefix}

# Directory in which to put the directories used by the compiler.
libdir = ${exec_prefix}/lib64

# Directory in which the compiler finds libraries etc.
libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(version)

# Used in install-cross.
gcc_tooldir = $(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)

# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
CROSS_SYSTEM_HEADER_DIR = $(gcc_tooldir)/sys-include

# autoconf sets SYSTEM_HEADER_DIR to one of the above.
# Purge it of unnecessary internal relative paths
# to directories that might not exist yet.
# The sed idiom for this is to repeat the search-and-replace until it doesn't match, using :a ... ta.
# Use single quotes here to avoid nested double- and backquotes, this
# macro is also used in a double-quoted context.
SYSTEM_HEADER_DIR = `echo $(CROSS_SYSTEM_HEADER_DIR) | sed -e :a -e 's,[^/]*/\.\.\/,,' -e ta`

# Test to see whether <limits.h> exists in the system header files.
LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h ]

#
# Build the include directories.  The stamp files are stmp-* rather than
# s-* so that mostlyclean does not force the include directory to
# be rebuilt.

# Build the include directories.
stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) fixinc_list
# Copy in the headers provided with gcc.
#
# The sed command gets just the last file name component;
# this is necessary because VPATH could add a dirname.
# Using basename would be simpler, but some systems don't have it.
#
# The touch command is here to workaround an AIX/Linux NFS bug.
#
# The move-if-change + cp -p twists for limits.h are intended to preserve
# the time stamp when we regenerate, to prevent pointless rebuilds during
# e.g. install-no-fixedincludes.
[...]
    set -e; for ml in `cat fixinc_list`; do \
      sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
      multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
      fix_dir=include-fixed$${multi_dir}; \
      if $(LIMITS_H_TEST) ; then \
cat $(srcdir)/limitx.h $(srcdir)/glimits.h $(srcdir)/limity.h > tmp-xlimits.h; \
      else \
        cat $(srcdir)/glimits.h > tmp-xlimits.h; \
      fi; \
[...]

Since Newlib is normally built as part of the GCC cross compiler build it makes no sense to use directories of the installation tree for this test. The installation tree should not affect the build of GCC with Newlib.

For RTEMS there are some hacks to deal with this limits.h problem in "gcc/config/t-rtems" and "libgcc/config/t-rtems", but I think we should get rid of this RTEMS special case solution.

There is already a --with-newlib configure option, so maybe it makes sense to use it for the "stmp-int-hdrs" Makefile target?

If I edited gcc/Makefile

# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
CROSS_SYSTEM_HEADER_DIR = $(objdir)/../$(target_subdir)/newlib/targ-include

and now the right GCC provided limits.h will be generated.

diff --git a/gcc/configure.ac b/gcc/configure.ac
index 0023b2a..020d34c 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1879,6 +1879,7 @@ if { { test x$host != x$target && test "x$with_sysroot" = x ; } ||
        test x$with_newlib = xyes ; } &&
      { test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then
        inhibit_libc=true
+ CROSS_SYSTEM_HEADER_DIR='$(objdir)/../$(target_subdir)/newlib/targ-include'
 fi
 AC_SUBST(inhibit_libc)

Unfortunately this doesn't work, since the "stmp-int-hdrs" Makefile target is built before the includes are copied to the '$(objdir)/../$(target_subdir)/newlib/targ-include' directory :-(

Does anyone know off hand if it is feasible to change this in the build mechanic?

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

Reply via email to