In sparc systems glibc uses libgcc's unwinder to implement the backtrace(3) function, defaulting to a simple non-dwarf unwinder if libgcc_s doesn't provide a working _Unwind_Backtrace.
However, libgcc's unwinder uses .eh_frame instead of .frame_debug, and .eh_frame is fully populated only if applications are built with -fexceptions or -fasynchronous-unwind-tables. This patch changes GCC to assume -fasynchronous-unwind-tables by default in sparcv9 and sparc64, like other ports (notably x86) do. Tested in both sparcv9-*-* and sparc64-*-* targets. * common/config/sparc/sparc-common.c (sparc_option_init_struct): New function. (TARGET_OPTION_INIT_STRUCT): Defined. --- gcc/ChangeLog | 6 ++++++ gcc/common/config/sparc/sparc-common.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3a13f5f..ba7befe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-02-25 Jose E. Marchesi <jose.march...@oracle.com> + + * common/config/sparc/sparc-common.c (sparc_option_init_struct): + New function. + (TARGET_OPTION_INIT_STRUCT): Defined. + 2016-02-25 Richard Biener <rguent...@suse.de> PR tree-optimization/48795 diff --git a/gcc/common/config/sparc/sparc-common.c b/gcc/common/config/sparc/sparc-common.c index 3958b7e..1c5bc06 100644 --- a/gcc/common/config/sparc/sparc-common.c +++ b/gcc/common/config/sparc/sparc-common.c @@ -24,6 +24,14 @@ along with GCC; see the file COPYING3. If not see #include "common/common-target.h" #include "common/common-target-def.h" +/* Implement TARGET_OPTION_INIT_STRUCT. */ + +static void +sparc_option_init_struct (struct gcc_options *opts) +{ + opts->x_flag_asynchronous_unwind_tables = 2; +} + /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ static const struct default_options sparc_option_optimization_table[] = { @@ -31,6 +39,8 @@ static const struct default_options sparc_option_optimization_table[] = { OPT_LEVELS_NONE, 0, NULL, 0 } }; +#undef TARGET_OPTION_INIT_STRUCT +#define TARGET_OPTION_INIT_STRUCT sparc_option_init_struct #undef TARGET_DEFAULT_TARGET_FLAGS #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT #undef TARGET_OPTION_OPTIMIZATION_TABLE -- 2.3.4