From patchwork Wed Jan 21 22:44:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 431627 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DC95D140297 for ; Thu, 22 Jan 2015 09:35:09 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=CjSazL96uJ0+ LZZVUye+upp31aq2c2SWEAL/UGhW7wSpdlUPOQAZc3Q43Rp1AkTXOSm76b35J1vv PMhssrPLjH4w3xa1666lBgi0g8hR5bVlFgnOaM8bVE6rKMdpsSntDdodgFP6QfW2 XQc3cRv7P8JwoQe4Y7eLJk3xDiC5wps= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=pZp0CnuFcbKs0DABRd V+zHd/2Dw=; b=dJBFGgOiad4BuZNLOXctBVt3QFk1Ha/jyXtMse470dHxgeqDHO n2w1ZLO/7LQOtPHFdBanH91RXKEwWEtqq/47UuNfvsAgopTfcbMW4PclmCiyY8W1 0UwJ/nWTnNtWRAR4F3H0UeX74zp2y08bCkGVzbcXTl8rd/XWcnkpyb/0M= Received: (qmail 12825 invoked by alias); 21 Jan 2015 22:35:02 -0000 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 Received: (qmail 12798 invoked by uid 89); 21 Jan 2015 22:35:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 21 Jan 2015 22:34:57 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0LMYrup007146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Jan 2015 17:34:54 -0500 Received: from c64.redhat.com (vpn-229-226.phx2.redhat.com [10.3.229.226]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0LMYqXG017407; Wed, 21 Jan 2015 17:34:53 -0500 From: David Malcolm To: jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH: toplev.c] PR jit/64721: don't install signal-handlers when running within libgccjit Date: Wed, 21 Jan 2015 17:44:03 -0500 Message-Id: <1421880243-21485-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes Don't install signal handlers in toplev.c if we're called from libgccjit, only install them if we're called from main.c, thus avoiding touching process-wide state from a shared library (see the PR for details of how this is currently leading to SIGSEGV on errors in "make check-jit"). Is this one sufficiently obvious to still be applicable in stage 4? (assuming bootstrap?) gcc/ChangeLog: PR jit/64721 * main.c (main): Construct toplev instances with init_signals=true. * toplev.c (general_init): Add param "init_signals", and use it to conditionalize the calls to signal and host_hooks.extra_signals. (toplev::toplev): Add param "init_signals". (toplev::main): When invoking general_init, pass m_init_signals to control whether signal-handlers are installed. * toplev.h (toplev::toplev): Add param "init_signals". (toplev::m_init_signals): New field. gcc/jit/ChangeLog: PR jit/64721 * jit-playback.c (gcc::jit::playback::context::compile): Construct toplev instances with init_signals=false. --- gcc/jit/jit-playback.c | 3 ++- gcc/main.c | 3 ++- gcc/toplev.c | 32 ++++++++++++++++++-------------- gcc/toplev.h | 4 +++- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index b4f2073..d2549a0 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -1723,7 +1723,8 @@ compile () acquire_mutex (); /* This runs the compiler. */ - toplev toplev (false); + toplev toplev (false, /* use_TV_TOTAL */ + false); /* init_signals */ enter_scope ("toplev::main"); if (get_logger ()) for (unsigned i = 0; i < fake_args.length (); i++) diff --git a/gcc/main.c b/gcc/main.c index 7a02983..79baf0d 100644 --- a/gcc/main.c +++ b/gcc/main.c @@ -33,7 +33,8 @@ int main (int argc, char **argv); int main (int argc, char **argv) { - toplev toplev (true); + toplev toplev (true, /* use_TV_TOTAL */ + true /* init_signals */); return toplev.main (argc, argv); } diff --git a/gcc/toplev.c b/gcc/toplev.c index 7bf177f..09f41ba 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -137,7 +137,7 @@ along with GCC; see the file COPYING3. If not see #include -static void general_init (const char *); +static void general_init (const char *, bool); static void do_compile (); static void process_options (void); static void backend_init (void); @@ -1149,7 +1149,7 @@ open_auxiliary_file (const char *ext) options are parsed. Signal handlers, internationalization etc. ARGV0 is main's argv[0]. */ static void -general_init (const char *argv0) +general_init (const char *argv0, bool init_signals) { const char *p; @@ -1188,28 +1188,31 @@ general_init (const char *argv0) global_dc->option_state = &global_options; global_dc->option_name = option_name; - /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */ + if (init_signals) + { + /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */ #ifdef SIGSEGV - signal (SIGSEGV, crash_signal); + signal (SIGSEGV, crash_signal); #endif #ifdef SIGILL - signal (SIGILL, crash_signal); + signal (SIGILL, crash_signal); #endif #ifdef SIGBUS - signal (SIGBUS, crash_signal); + signal (SIGBUS, crash_signal); #endif #ifdef SIGABRT - signal (SIGABRT, crash_signal); + signal (SIGABRT, crash_signal); #endif #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT) - signal (SIGIOT, crash_signal); + signal (SIGIOT, crash_signal); #endif #ifdef SIGFPE - signal (SIGFPE, crash_signal); + signal (SIGFPE, crash_signal); #endif - /* Other host-specific signal setup. */ - (*host_hooks.extra_signals)(); + /* Other host-specific signal setup. */ + (*host_hooks.extra_signals)(); + } /* Initialize the garbage-collector, string pools and tree type hash table. */ @@ -2057,8 +2060,9 @@ do_compile () } } -toplev::toplev (bool use_TV_TOTAL) - : m_use_TV_TOTAL (use_TV_TOTAL) +toplev::toplev (bool use_TV_TOTAL, bool init_signals) + : m_use_TV_TOTAL (use_TV_TOTAL), + m_init_signals (init_signals) { if (!m_use_TV_TOTAL) start_timevars (); @@ -2095,7 +2099,7 @@ toplev::main (int argc, char **argv) expandargv (&argc, &argv); /* Initialization of GCC's environment, and diagnostics. */ - general_init (argv[0]); + general_init (argv[0], m_init_signals); /* One-off initialization of options that does not need to be repeated when options are added for particular functions. */ diff --git a/gcc/toplev.h b/gcc/toplev.h index 5503795..6b423be 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -28,7 +28,8 @@ extern unsigned int save_decoded_options_count; class toplev { public: - toplev (bool use_TV_TOTAL); + toplev (bool use_TV_TOTAL, + bool init_signals); ~toplev (); int main (int argc, char **argv); @@ -40,6 +41,7 @@ private: void start_timevars (); bool m_use_TV_TOTAL; + bool m_init_signals; }; extern void rest_of_decl_compilation (tree, int, int);