From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25433 invoked by alias); 19 Dec 2012 17:50:04 -0000 Received: (qmail 25298 invoked by uid 48); 19 Dec 2012 17:49:47 -0000 From: "wookey at wookware dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgcc/55743] New: limits.h included unnecessarily in libgcc2.c - can break --without-headers bootstrap Date: Wed, 19 Dec 2012 17:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgcc X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: wookey at wookware dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg01907.txt.bz2 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 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.