[Bug libgcc/55743] New: limits.h included unnecessarily in libgcc2.c - can break --without-headers bootstrap
wookey at wookware dot org
gcc-bugzilla@gcc.gnu.org
Wed Dec 19 17:50:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55743
Bug #: 55743
Summary: limits.h included unnecessarily in libgcc2.c - can
break --without-headers bootstrap
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcc
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: wookey@wookware.org
The offending code is three very similar function in libgcc2.c around 1733:
#if defined(L_fixunsxfsi) && LIBGCC2_HAS_XF_MODE
/* Reenable the normal types, in case limits.h needs them. */
#undef char
#undef short
#undef int
#undef long
#undef unsigned
#undef float
#undef double
#undef MIN
#undef MAX
#include <limits.h>
UWtype
__fixunsxfSI (XFtype a)
{
if (a >= - (DFtype) Wtype_MIN)
return (Wtype) (a + Wtype_MIN) - Wtype_MIN;
return (Wtype) a;
}
#endif
That inclusion of limits.h was there because the function __fixunsxfSI used to
use LONG_MIN from that headers file, but this was changed a while back
(http://repo.or.cz/w/official-gcc.git/blobdiff/49f0f270673c4512c11f72a038b84c321ae5534a..7429c938827aa98bf3b02c4ac89510f4d28ef0b1:/gcc/libgcc2.c)
to use Wtype_MIN instead, which is defined in the local libgcc2.h header.
so in fact the limits.h inclusion is no longer needed.
And having it there can cause problems because if this file is built during a
stage1 bootstrap configured with --without-headers (before glibc headers are
available), then the include finds limits.h in the includes-fixed dir and thus
limits.h on the build machine (via #include_next) (which tries to bring in
bits/predefs.h of the wrong architecture), or at least it does in the
Debian/Ubuntu toolchain packaging. This is no doubt wrong too, and other
changes should probably be made, but simply removing the unnecessary limits.h
including fixes the issue for me and seems correct.
Distro-specific details are given in bugs
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=696267 and
https://bugs.launchpad.net/debian/+source/gcc-4.7/+bug/1091823
The patch was generated against 4.7.2 but the issue is still present in trunk.
More information about the Gcc-bugs
mailing list