From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96705 invoked by alias); 9 Nov 2017 16:11:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 88859 invoked by uid 89); 9 Nov 2017 16:11:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=fopenmp, front-end, sk:tempora X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Nov 2017 16:11:42 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B3EA681549 for ; Thu, 9 Nov 2017 17:11:40 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Yu9dngFStMu for ; Thu, 9 Nov 2017 17:11:40 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 87E538139A for ; Thu, 9 Nov 2017 17:11:40 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix EH breakage in LTO mode Date: Thu, 09 Nov 2017 16:39:00 -0000 Message-ID: <1568718.AUOz7rQ1P4@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart6684570.XCZmjyxDIu" Content-Transfer-Encoding: 7Bit X-SW-Source: 2017-11/txt/msg00773.txt.bz2 This is a multi-part message in MIME format. --nextPart6684570.XCZmjyxDIu Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 1893 Hi, the patch 2017-07-06 Jan Hubicka * lto-wrapper.c (merge_and_complain): Do not merge fexceptions, fnon_call_exceptions, ftrapv, ffp_contract_, fmath_errno, fsigned_zeros, ftrapping_math, fwrapv. (append_compiler_options): Do not track these options. (append_linker_options): Likewie has broken exception handling in LTO mode for targets which don't force either -funwind-tables or -fasynchronous-unwind-tables (i.e not x86) and do not default to -fdwarf2-cfi-asm (i.e. not Linux), for example SPARC/Solaris. The problem is that the eh_frame section is no longer generated because it is emitted from compile_file: #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO if (dwarf2out_do_frame ()) dwarf2out_frame_finish (); #endif and this requires that either flag_unwind_tables or flag_exceptions be set. But both -funwind-tables and -fexceptions are optimization options defaulting to 0 and they are reset to 0 through optimization_default_node after the last function is processed by the cgraph machinery. Note that flag_exceptions is generally set to 1 in lto_init_eh very early, but the above mechanism overrides it. However, flag_exceptions may *never* be set to 1 for a specific partition if it contains only EH-neutral functions; that's why I think that there is no other way than restoring the build-wide handling of -fexceptions before Jan's patch (hopefully it's the only affected switch). Tested (lightly for now) on x86-64/Linux and SPARC/Solaris, OK for mainline? 2017-11-09 Eric Botcazou * lto-opts.c (lto_write_options): Do not save -fnon-call-exceptions, -ffp-contract, -fmath-errno, -fsigned-zeros, -ftrapping-math, -ftrapv and -fwrapv. * lto-wrapper.c (merge_and_complain): Merge again -fexceptions. (append_compiler_options): Pass again -fexceptions. -- Eric Botcazou --nextPart6684570.XCZmjyxDIu Content-Disposition: attachment; filename="p.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="p.diff" Content-length: 4181 Index: lto-opts.c =================================================================== --- lto-opts.c (revision 254560) +++ lto-opts.c (working copy) @@ -82,61 +82,10 @@ lto_write_options (void) && global_options.x_flag_exceptions) append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fexceptions"); - /* -fnon-call-exceptions changes the generation of exception - regions. It is enabled implicitly by the Go frontend. */ - if (!global_options_set.x_flag_non_call_exceptions - && global_options.x_flag_non_call_exceptions) - append_to_collect_gcc_options (&temporary_obstack, &first_p, - "-fnon-call-exceptions"); - /* The default -ffp-contract changes depending on the language - standard. Pass thru conservative standard settings. */ - if (!global_options_set.x_flag_fp_contract_mode) - switch (global_options.x_flag_fp_contract_mode) - { - case FP_CONTRACT_OFF: - append_to_collect_gcc_options (&temporary_obstack, &first_p, - "-ffp-contract=off"); - break; - case FP_CONTRACT_ON: - append_to_collect_gcc_options (&temporary_obstack, &first_p, - "-ffp-contract=on"); - break; - case FP_CONTRACT_FAST: - /* Nothing. That merges conservatively and is the default for LTO. */ - break; - default: - gcc_unreachable (); - } - /* The default -fmath-errno, -fsigned-zeros and -ftrapping-math change - depending on the language (they can be disabled by the Ada front-end). - Pass thru conservative standard settings. */ - if (!global_options_set.x_flag_errno_math) - append_to_collect_gcc_options (&temporary_obstack, &first_p, - global_options.x_flag_errno_math - ? "-fmath-errno" - : "-fno-math-errno"); - if (!global_options_set.x_flag_signed_zeros) - append_to_collect_gcc_options (&temporary_obstack, &first_p, - global_options.x_flag_signed_zeros - ? "-fsigned-zeros" - : "-fno-signed-zeros"); - if (!global_options_set.x_flag_trapping_math) - append_to_collect_gcc_options (&temporary_obstack, &first_p, - global_options.x_flag_trapping_math - ? "-ftrapping-math" - : "-fno-trapping-math"); - /* We need to merge -f[no-]strict-overflow, -f[no-]wrapv and -f[no-]trapv - conservatively, so stream out their defaults. */ - if (!global_options_set.x_flag_wrapv - && global_options.x_flag_wrapv) - append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fwrapv"); - if (!global_options_set.x_flag_trapv - && !global_options.x_flag_trapv) - append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fno-trapv"); - if (!global_options_set.x_flag_openmp && !global_options.x_flag_openmp) - append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fno-openmp"); + append_to_collect_gcc_options (&temporary_obstack, &first_p, + "-fno-openmp"); if (!global_options_set.x_flag_openacc && !global_options.x_flag_openacc) append_to_collect_gcc_options (&temporary_obstack, &first_p, Index: lto-wrapper.c =================================================================== --- lto-wrapper.c (revision 254560) +++ lto-wrapper.c (working copy) @@ -280,6 +280,7 @@ merge_and_complain (struct cl_decoded_op pie_option = foption; break; + case OPT_fexceptions: case OPT_fopenmp: case OPT_fopenacc: case OPT_fcilkplus: @@ -290,10 +291,11 @@ merge_and_complain (struct cl_decoded_op break; if (j == *decoded_options_count) append_option (decoded_options, decoded_options_count, foption); - /* -fopenmp > -fno-openmp, + /* -fexceptions -> -fno-exceptions + -fopenmp > -fno-openmp, -fopenacc > -fno-openacc, -fcilkplus > -fno-cilkplus, - -fcheck_pointer_bounds > -fcheck_pointer_bounds */ + -fcheck-pointer-bounds > -fno-check-pointer-bounds */ else if (foption->value > (*decoded_options)[j].value) (*decoded_options)[j] = *foption; break; @@ -546,6 +548,7 @@ append_compiler_options (obstack *argv_o case OPT_fpie: case OPT_fcommon: case OPT_fgnu_tm: + case OPT_fexceptions: case OPT_fopenmp: case OPT_fopenacc: case OPT_fopenacc_dim_: --nextPart6684570.XCZmjyxDIu--