* [patch] Fix EH breakage in LTO mode
@ 2017-11-09 16:39 Eric Botcazou
2017-11-09 16:51 ` Richard Biener
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Eric Botcazou @ 2017-11-09 16:39 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1893 bytes --]
Hi,
the patch
2017-07-06 Jan Hubicka <hubicka@ucw.cz>
* 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 <ebotcazou@adacore.com>
* 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
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 4181 bytes --]
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_:
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 16:39 [patch] Fix EH breakage in LTO mode Eric Botcazou
@ 2017-11-09 16:51 ` Richard Biener
2017-11-09 17:17 ` Jan Hubicka
2017-11-09 18:03 ` Rainer Orth
2 siblings, 0 replies; 9+ messages in thread
From: Richard Biener @ 2017-11-09 16:51 UTC (permalink / raw)
To: gcc-patches, Eric Botcazou
On November 9, 2017 5:11:39 PM GMT+01:00, Eric Botcazou <ebotcazou@adacore.com> wrote:
>Hi,
>
>the patch
>
>2017-07-06 Jan Hubicka <hubicka@ucw.cz>
>
> * 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?
OK.
Richard.
>
>2017-11-09 Eric Botcazou <ebotcazou@adacore.com>
>
> * 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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 16:39 [patch] Fix EH breakage in LTO mode Eric Botcazou
2017-11-09 16:51 ` Richard Biener
@ 2017-11-09 17:17 ` Jan Hubicka
2017-11-09 17:20 ` Eric Botcazou
2017-11-09 18:03 ` Rainer Orth
2 siblings, 1 reply; 9+ messages in thread
From: Jan Hubicka @ 2017-11-09 17:17 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
> Hi,
>
> the patch
>
> 2017-07-06 Jan Hubicka <hubicka@ucw.cz>
>
> * 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).
I am not sure I follow your argumentation here. flag_exceptions is optimization
which means that one should not test it globally. For that reason I would just
change dwarf2out to simply trigger dwarf2out_frame_finish if any of the compiled
functions needed it (had flag_exceptions set).
My readon of lto-wrapper is that it will set flag_exceptions for whole compilation
unit when one of compilation units were copmiled with flag_exceptions.
How that helps the neutral functions?
Honza
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 17:17 ` Jan Hubicka
@ 2017-11-09 17:20 ` Eric Botcazou
2017-11-09 18:12 ` Jan Hubicka
0 siblings, 1 reply; 9+ messages in thread
From: Eric Botcazou @ 2017-11-09 17:20 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
> I am not sure I follow your argumentation here. flag_exceptions is
> optimization which means that one should not test it globally. For that
> reason I would just change dwarf2out to simply trigger
> dwarf2out_frame_finish if any of the compiled functions needed it (had
> flag_exceptions set).
That's not sufficient for a partition with only EH-neutral functions.
> My readon of lto-wrapper is that it will set flag_exceptions for whole
> compilation unit when one of compilation units were copmiled with
> flag_exceptions.
>
> How that helps the neutral functions?
flag_exceptions is never set in a partition with only EH-neutral functions.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 16:39 [patch] Fix EH breakage in LTO mode Eric Botcazou
2017-11-09 16:51 ` Richard Biener
2017-11-09 17:17 ` Jan Hubicka
@ 2017-11-09 18:03 ` Rainer Orth
2017-11-09 23:39 ` Eric Botcazou
2 siblings, 1 reply; 9+ messages in thread
From: Rainer Orth @ 2017-11-09 18:03 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
Hi Eric,
> the patch
>
> 2017-07-06 Jan Hubicka <hubicka@ucw.cz>
>
> * 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.
this is PR lto/81351.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 17:20 ` Eric Botcazou
@ 2017-11-09 18:12 ` Jan Hubicka
2017-11-09 20:03 ` Richard Biener
2017-11-09 23:43 ` Eric Botcazou
0 siblings, 2 replies; 9+ messages in thread
From: Jan Hubicka @ 2017-11-09 18:12 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
> > I am not sure I follow your argumentation here. flag_exceptions is
> > optimization which means that one should not test it globally. For that
> > reason I would just change dwarf2out to simply trigger
> > dwarf2out_frame_finish if any of the compiled functions needed it (had
> > flag_exceptions set).
>
> That's not sufficient for a partition with only EH-neutral functions.
>
> > My readon of lto-wrapper is that it will set flag_exceptions for whole
> > compilation unit when one of compilation units were copmiled with
> > flag_exceptions.
> >
> > How that helps the neutral functions?
>
> flag_exceptions is never set in a partition with only EH-neutral functions.
Hmm, I am still not following. By EH-neutral you mean function compiled
with -fno-exceptions so it has no unwind info at all or one that has unwind
info but does not do anything with EH?
Honza
>
> --
> Eric Botcazou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 18:12 ` Jan Hubicka
@ 2017-11-09 20:03 ` Richard Biener
2017-11-09 23:43 ` Eric Botcazou
1 sibling, 0 replies; 9+ messages in thread
From: Richard Biener @ 2017-11-09 20:03 UTC (permalink / raw)
To: gcc-patches, Jan Hubicka, Eric Botcazou
On November 9, 2017 7:03:18 PM GMT+01:00, Jan Hubicka <hubicka@ucw.cz> wrote:
>> > I am not sure I follow your argumentation here. flag_exceptions is
>> > optimization which means that one should not test it globally. For
>that
>> > reason I would just change dwarf2out to simply trigger
>> > dwarf2out_frame_finish if any of the compiled functions needed it
>(had
>> > flag_exceptions set).
>>
>> That's not sufficient for a partition with only EH-neutral functions.
>>
>> > My readon of lto-wrapper is that it will set flag_exceptions for
>whole
>> > compilation unit when one of compilation units were copmiled with
>> > flag_exceptions.
>> >
>> > How that helps the neutral functions?
>>
>> flag_exceptions is never set in a partition with only EH-neutral
>functions.
>
>Hmm, I am still not following. By EH-neutral you mean function compiled
>with -fno-exceptions so it has no unwind info at all or one that has
>unwind
>info but does not do anything with EH?
The latter. We choose a 'neutral' EH personality for those and thus if all behave that way we fail to init EH.
I suppose we could record a TU wide setting of options attached to the TRANSLATION_UNIT_DECL and read global flags from that?
Richard.
>Honza
>>
>> --
>> Eric Botcazou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 18:03 ` Rainer Orth
@ 2017-11-09 23:39 ` Eric Botcazou
0 siblings, 0 replies; 9+ messages in thread
From: Eric Botcazou @ 2017-11-09 23:39 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches
> this is PR lto/81351.
Totally missed it... Do not hesitate to CC me for SPARC regressions.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Fix EH breakage in LTO mode
2017-11-09 18:12 ` Jan Hubicka
2017-11-09 20:03 ` Richard Biener
@ 2017-11-09 23:43 ` Eric Botcazou
1 sibling, 0 replies; 9+ messages in thread
From: Eric Botcazou @ 2017-11-09 23:43 UTC (permalink / raw)
To: Jan Hubicka; +Cc: gcc-patches
> Hmm, I am still not following. By EH-neutral you mean function compiled
> with -fno-exceptions so it has no unwind info at all or one that has unwind
> info but does not do anything with EH?
OK, I see what you mean now. So, even if lto_init_eh is never invoked and
thus never sets flag_exceptions for the partition, you would record whether
the flag was saved in the optimization node of at least one function, right?
But this would require to compile C code with -fexceptions if it's included in
an EH-enabled LTO link, whereas you didn't need do it previously (of course
this is all masked on x86 because -funwind-tables is always enabled). On the
other hand, this is required for a normal link too.
I guess that would be more consistent with what happens with -fdwarf2-cfi-asm.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-11-09 23:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 16:39 [patch] Fix EH breakage in LTO mode Eric Botcazou
2017-11-09 16:51 ` Richard Biener
2017-11-09 17:17 ` Jan Hubicka
2017-11-09 17:20 ` Eric Botcazou
2017-11-09 18:12 ` Jan Hubicka
2017-11-09 20:03 ` Richard Biener
2017-11-09 23:43 ` Eric Botcazou
2017-11-09 18:03 ` Rainer Orth
2017-11-09 23:39 ` Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).