From patchwork Thu Dec 16 12:41:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 75752 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id EB68F1007D3 for ; Thu, 16 Dec 2010 23:42:04 +1100 (EST) Received: (qmail 11637 invoked by alias); 16 Dec 2010 12:42:01 -0000 Received: (qmail 11537 invoked by uid 22791); 16 Dec 2010 12:42:00 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_CP, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (213.235.205.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Dec 2010 12:41:54 +0000 Received: from basil.firstfloor.org (p5B3C96B7.dip0.t-ipconnect.de [91.60.150.183]) by one.firstfloor.org (Postfix) with ESMTP id 6CB501A9805E; Thu, 16 Dec 2010 13:41:50 +0100 (CET) Received: by basil.firstfloor.org (Postfix, from userid 1000) id D7FD0B27C3; Thu, 16 Dec 2010 13:41:49 +0100 (CET) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH 2/2] Improve reporting of section conflict errors Date: Thu, 16 Dec 2010 13:41:48 +0100 Message-Id: <1292503308-11258-2-git-send-email-andi@firstfloor.org> In-Reply-To: <1292503308-11258-1-git-send-email-andi@firstfloor.org> References: <1292503308-11258-1-git-send-email-andi@firstfloor.org> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org From: Andi Kleen When making large projects LTO clean section conflicts can be surprisingly common. Currently they are hard to debug. This patch improves the error reporting a bit by printing out what flags actually differ. It's still not great -- better would be to print the other locations that actually conflict too. But that would be more complicated. Passes bootstrap and full test on x86_64-linux. Ok? gcc/ 2010-12-15 Andi Kleen * varasm.c (section_print_flags): Add. (get_section): Print more details on conflicting flags. --- gcc/varasm.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 62 insertions(+), 1 deletions(-) diff --git a/gcc/varasm.c b/gcc/varasm.c index ed44610..f676255 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -268,6 +268,59 @@ get_noswitch_section (unsigned int flags, noswitch_section_callback callback) return sect; } +/* Print section flags F into BUF */ + +static char * +section_print_flags (char *buf, unsigned f) +{ + static struct flag + { + const char *name; + unsigned flag; + unsigned mask; + } flags[] = + { + { "code", SECTION_CODE, 0 }, + { "write", SECTION_WRITE, 0 }, + { "debug", SECTION_DEBUG, 0}, + { "linkonce", SECTION_LINKONCE, 0 }, + { "small", SECTION_SMALL, 0 }, + { "bss", SECTION_BSS, 0 }, + { "forget", SECTION_FORGET, 0 }, + { "merge", SECTION_MERGE, 0 }, + { "strings", SECTION_STRINGS, 0 }, + { "override", SECTION_OVERRIDE, 0 }, + { "tls", SECTION_TLS, 0 }, + { "common", SECTION_COMMON, 0 }, + { "unnamed", SECTION_UNNAMED, SECTION_STYLE_MASK }, + { "named", SECTION_NAMED, SECTION_STYLE_MASK }, + { "noswitch", SECTION_NOSWITCH, SECTION_STYLE_MASK }, + { NULL, 0, 0 } + }; + struct flag *fl; + char *start = buf; + + f &= ~SECTION_OVERRIDE; + buf[0] = 0; + for (fl = &flags[0]; fl->name; fl++) + { + unsigned mask = fl->mask; + + if (mask == 0) + mask = 0xffffffff; + if ((f & mask) & fl->flag) + { + strcpy (buf, fl->name); + strcat (buf, " "); + buf += strlen (buf); + f &= ~fl->flag; + } + } + if (f) + sprintf (buf, "rest %x", f); + return start; +} + /* Return the named section structure associated with NAME. Create a new section with the given fields if no such structure exists. */ @@ -290,15 +343,23 @@ get_section (const char *name, unsigned int flags, tree decl) } else { + unsigned oflags; + sect = *slot; - if ((sect->common.flags & ~SECTION_DECLARED) != flags + oflags = sect->common.flags & ~SECTION_DECLARED; + if (oflags != flags && ((sect->common.flags | flags) & SECTION_OVERRIDE) == 0) { + char buf[1024]; + /* Sanity check user variables for flag changes. */ if (decl == 0) decl = sect->named.decl; gcc_assert (decl); error ("%+D causes a section type conflict", decl); + inform (DECL_SOURCE_LOCATION (decl), + "New section declaration differs in: %s", + section_print_flags (buf, oflags ^ flags)); } } return sect;