@@ -10,7 +10,7 @@ dnl Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
1010dnl University of Stuttgart. All rights reserved.
1111dnl Copyright (c) 2004-2005 The Regents of the University of California.
1212dnl All rights reserved.
13- dnl Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
13+ dnl Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved.
1414dnl Copyright (c) 2006-2009 Sun Microsystems, Inc. All rights reserved.
1515dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
1616dnl reserved.
2424dnl $HEADER $
2525dnl
2626
27+ dnl Check to see if specific CFLAGS work
28+ dnl $1 : compiler flags to check
29+ dnl $2 : Action if the flags work
30+ dnl $3 : Action if the flags do not work
31+ AC_DEFUN([_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS],[
32+ OPAL_VAR_SCOPE_PUSH([ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save])
33+
34+ ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save= $CFLAGS
35+ AC_MSG_CHECKING([if $1 compiler flag works])
36+ CFLAGS= " $CFLAGS $1 "
37+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[int i = 3; ])],
38+ [ORTE_SETUP_DEBUGGER_FLAGS_HAPPY= yes],
39+ [ORTE_SETUP_DEBUGGER_FLAGS_HAPPY= no])
40+ AC_MSG_RESULT([$ORTE_SETUP_DEBUGGER_FLAGS_HAPPY ])
41+ CFLAGS= $ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save
42+
43+ OPAL_VAR_SCOPE_POP
44+
45+ AS_IF([test $ORTE_SETUP_DEBUGGER_FLAGS_HAPPY = yes],
46+ [$2 ], [$3 ])
47+ ])
48+
2749AC_DEFUN([ORTE_SETUP_DEBUGGER_FLAGS],[
2850 #
2951 # Do a final process of the CFLAGS to make a WITHOUT_OPTFLAGS
@@ -53,4 +75,22 @@ AC_DEFUN([ORTE_SETUP_DEBUGGER_FLAGS],[
5375
5476 AC_SUBST(CFLAGS_WITHOUT_OPTFLAGS)
5577 AC_SUBST(DEBUGGER_CFLAGS)
78+
79+ # Check for compiler specific flag to add in unwind information.
80+ # This is needed when attaching using MPIR to unwind back to the
81+ # user's main function. Certain optimisations can prevent GDB from
82+ # producing a stack when explicit unwind information is unavailable.
83+ # This is implied by -g, but we want to save space and don't need
84+ # full debug symbols.
85+ _ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-fasynchronous-unwind-tables],
86+ [MPIR_UNWIND_CFLAGS= " -fasynchronous-unwind-tables" ],
87+ [_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-Meh_frame -Mframe],
88+ [MPIR_UNWIND_CFLAGS= " -Meh_frame -Mframe" ],
89+ [MPIR_UNWIND_CFLAGS= -g])
90+ ])
91+
92+ AC_MSG_CHECKING([for final compiler unwind flags])
93+ AC_MSG_RESULT([$MPIR_UNWIND_CFLAGS ])
94+
95+ AC_SUBST(MPIR_UNWIND_CFLAGS)
5696])
0 commit comments