From patchwork Mon Jul 18 21:58:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 105362 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 3E996B6F71 for ; Tue, 19 Jul 2011 07:58:56 +1000 (EST) Received: (qmail 10437 invoked by alias); 18 Jul 2011 21:58:54 -0000 Received: (qmail 10428 invoked by uid 22791); 18 Jul 2011 21:58:54 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_RG X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Jul 2011 21:58:40 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6ILwe3r007765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Jul 2011 17:58:40 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6ILwdph006677 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 18 Jul 2011 17:58:40 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p6ILwc89008491 for ; Mon, 18 Jul 2011 23:58:38 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p6ILwcjW008489 for gcc-patches@gcc.gnu.org; Mon, 18 Jul 2011 23:58:38 +0200 Date: Mon, 18 Jul 2011 23:58:38 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Attempt to increase RLIMIT_STACK in the driver as well as compiler (PR c++/49756) Message-ID: <20110718215838.GZ2687@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! Especially the FEs and gimplification are highly recursive on more complex (especially badly generated) testcases, the following patch attempts to increase stack size to 64MB if possible. It is done in the driver (where it can affect the children of the driver early) and also in toplev_main to make similar results when invoking the compiler by hand, unless mmap of some shared library or some other mmap make it impossible to have such a large stack. Bootstrapped/regtested on x86_64-linux and i686-linux, cures gcc.c-torture/compile/limits-exprparen.c ICEs on x86_64-linux on all -O* levels as well as the testcase from this PR (which is quite large and compile time consuming, so not including it in this testcase). 2011-07-18 Jakub Jelinek PR c++/49756 * gcc.c (main): Try to increase RLIMIT_STACK to at least 64MB if possible. * toplev.c (toplev_main): Likewise. Jakub --- gcc/gcc.c.jj 2011-07-08 15:09:38.000000000 +0200 +++ gcc/gcc.c 2011-07-18 21:13:18.000000000 +0200 @@ -6156,6 +6156,22 @@ main (int argc, char **argv) signal (SIGCHLD, SIG_DFL); #endif +#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK) && defined(RLIM_INFINITY) + { + /* Parsing and gimplification sometimes need quite large stack. + Increase stack size limits if possible. */ + struct rlimit rlim; + if (getrlimit (RLIMIT_STACK, &rlim) == 0 + && rlim.rlim_cur != RLIM_INFINITY) + { + rlim.rlim_cur = MAX (rlim.rlim_cur, 64 * 1024 * 1024); + if (rlim.rlim_max != RLIM_INFINITY) + rlim.rlim_cur = MIN (rlim.rlim_cur, rlim.rlim_max); + setrlimit (RLIMIT_STACK, &rlim); + } + } +#endif + /* Allocate the argument vector. */ alloc_args (); --- gcc/toplev.c.jj 2011-07-11 10:39:50.000000000 +0200 +++ gcc/toplev.c 2011-07-18 21:14:24.000000000 +0200 @@ -1911,6 +1911,22 @@ do_compile (void) int toplev_main (int argc, char **argv) { +#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK) && defined(RLIM_INFINITY) + { + /* Parsing and gimplification sometimes need quite large stack. + Increase stack size limits if possible. */ + struct rlimit rlim; + if (getrlimit (RLIMIT_STACK, &rlim) == 0 + && rlim.rlim_cur != RLIM_INFINITY) + { + rlim.rlim_cur = MAX (rlim.rlim_cur, 64 * 1024 * 1024); + if (rlim.rlim_max != RLIM_INFINITY) + rlim.rlim_cur = MIN (rlim.rlim_cur, rlim.rlim_max); + setrlimit (RLIMIT_STACK, &rlim); + } + } +#endif + expandargv (&argc, &argv); /* Initialization of GCC's environment, and diagnostics. */