Skip to content

Commit de87952

Browse files
James-A-Clarkjsquyres
authored andcommitted
Use a compilation test to set the MPIR unwind flags instead of setting
them based on compiler name. Also correct CPP_FLAGS -> C_FLAGS. Signed-off-by: James Clark <[email protected]>
1 parent b8e9bf5 commit de87952

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

config/orte_setup_debugger_flags.m4

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ dnl
2424
dnl $HEADER$
2525
dnl
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+
AC_DEFUN([_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS],[
31+
OPAL_VAR_SCOPE_PUSH([ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save])
32+
ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save=$CFLAGS
33+
AC_MSG_CHECKING([if $1 compiler flag works])
34+
CFLAGS="$CFLAGS $1"
35+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[int i = 3;])],
36+
[$2; AC_MSG_RESULT([yes])],
37+
[AC_MSG_RESULT([no])])
38+
CFLAGS=$ORTE_SETUP_DEBUGGER_FLAGS_CFLAGS_save
39+
OPAL_VAR_SCOPE_POP
40+
])
41+
2742
AC_DEFUN([ORTE_SETUP_DEBUGGER_FLAGS],[
2843
#
2944
# Do a final process of the CFLAGS to make a WITHOUT_OPTFLAGS
@@ -60,19 +75,24 @@ AC_DEFUN([ORTE_SETUP_DEBUGGER_FLAGS],[
6075
# producing a stack when explicit unwind information is unavailable.
6176
# This is implied by -g, but we want to save space and don't need
6277
# full debug symbols.
63-
if test "x$opal_cv_c_compiler_vendor" = "xibm"; then
64-
MPIR_UNWIND_CFLAGS="-g"
65-
elif test "x$opal_cv_c_compiler_vendor" = "xgnu"; then
66-
MPIR_UNWIND_CFLAGS="-fasynchronous-unwind-tables"
67-
elif test "x$opal_cv_c_compiler_vendor" = "xintel"; then
68-
MPIR_UNWIND_CFLAGS="-fasynchronous-unwind-tables"
69-
elif test "x$opal_cv_c_compiler_vendor" = "xportland group"; then
70-
MPIR_UNWIND_CFLAGS="-Meh_frame -Mframe"
71-
else
72-
MPIR_UNWIND_CFLAGS=
78+
foundFlags=no
79+
MPIR_UNWIND_CFLAGS=
80+
81+
# Test for GNU and Intel compiler flags
82+
_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-fasynchronous-unwind-tables],
83+
[MPIR_UNWIND_CFLAGS=-fasynchronous-unwind-tables foundFlags=yes])
84+
85+
# Test for PGI compiler flags
86+
if test $foundFlags = no; then
87+
_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-Meh_frame -Mframe],
88+
[MPIR_UNWIND_CFLAGS="-Meh_frame -Mframe" foundFlags=yes])
89+
fi
90+
91+
# Finally fall back to -g if neither of the above were available
92+
if test $foundFlags = no; then
93+
_ORTE_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-g],
94+
[MPIR_UNWIND_CFLAGS=-g foundFlags=yes])
7395
fi
7496

75-
AC_MSG_CHECKING([for MPIR unwind info flags])
76-
AC_MSG_RESULT([$MPIR_UNWIND_CFLAGS])
7797
AC_SUBST(MPIR_UNWIND_CFLAGS)
7898
])

orte/mca/ess/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
# $HEADER$
1818
#
1919

20-
# Add unwind flags because all of the files in this tree are
20+
AM_CPPFLAGS = $(LTDLINCL)
21+
22+
# Add unwind flags because files in this tree are
2123
# involved in startup.
22-
AM_CPPFLAGS = $(LTDLINCL) $(MPIR_UNWIND_CFLAGS)
24+
AM_CFLAGS = $(MPIR_UNWIND_CFLAGS)
2325

2426
# main library setup
2527
noinst_LTLIBRARIES = libmca_ess.la

orte/mca/ess/pmi/Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
# $HEADER$
1212
#
1313

14-
AM_CPPFLAGS = $(ess_pmi_CPPFLAGS) $(MPIR_UNWIND_CFLAGS)
14+
# Add MPIR unwind flags because files in this tree are
15+
# involved in startup. This is not needed in the other
16+
# subdirs in orte/mca/ess because the other components are
17+
# solely used by daemons and thus are not accessible by the debugger.
18+
AM_CFLAGS = $(MPIR_UNWIND_CFLAGS)
19+
20+
AM_CPPFLAGS = $(ess_pmi_CPPFLAGS)
1521

1622
sources = \
1723
ess_pmi.h \

0 commit comments

Comments
 (0)