|
| 1 | +dnl -*- shell-script -*- |
| 2 | +dnl |
| 3 | +dnl Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana |
| 4 | +dnl University Research and Technology |
| 5 | +dnl Corporation. All rights reserved. |
| 6 | +dnl Copyright (c) 2004-2005 The University of Tennessee and The University |
| 7 | +dnl of Tennessee Research Foundation. All rights |
| 8 | +dnl reserved. |
| 9 | +dnl Copyright (c) 2004-2007 High Performance Computing Center Stuttgart, |
| 10 | +dnl University of Stuttgart. All rights reserved. |
| 11 | +dnl Copyright (c) 2004-2005 The Regents of the University of California. |
| 12 | +dnl All rights reserved. |
| 13 | +dnl Copyright (c) 2006-2019 Cisco Systems, Inc. All rights reserved. |
| 14 | +dnl Copyright (c) 2006-2009 Sun Microsystems, Inc. All rights reserved. |
| 15 | +dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights |
| 16 | +dnl reserved. |
| 17 | +dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved. |
| 18 | +dnl Copyright (c) 2015 Research Organization for Information Science |
| 19 | +dnl and Technology (RIST). All rights reserved. |
| 20 | +dnl $COPYRIGHT$ |
| 21 | +dnl |
| 22 | +dnl Additional copyrights may follow |
| 23 | +dnl |
| 24 | +dnl $HEADER$ |
| 25 | +dnl |
| 26 | + |
| 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([_OMPI_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS],[ |
| 32 | + OPAL_VAR_SCOPE_PUSH([OMPI_SETUP_DEBUGGER_FLAGS_CFLAGS_save]) |
| 33 | + |
| 34 | + OMPI_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 | + [OMPI_SETUP_DEBUGGER_FLAGS_HAPPY=yes], |
| 39 | + [OMPI_SETUP_DEBUGGER_FLAGS_HAPPY=no]) |
| 40 | + AC_MSG_RESULT([$OMPI_SETUP_DEBUGGER_FLAGS_HAPPY]) |
| 41 | + CFLAGS=$OMPI_SETUP_DEBUGGER_FLAGS_CFLAGS_save |
| 42 | + |
| 43 | + OPAL_VAR_SCOPE_POP |
| 44 | + |
| 45 | + AS_IF([test $OMPI_SETUP_DEBUGGER_FLAGS_HAPPY = yes], |
| 46 | + [$2], [$3]) |
| 47 | +]) |
| 48 | + |
| 49 | +AC_DEFUN([OMPI_SETUP_DEBUGGER_FLAGS],[ |
| 50 | + # |
| 51 | + # Do a final process of the CFLAGS to make a WITHOUT_OPTFLAGS |
| 52 | + # version. We need this so that we can guarantee to build the |
| 53 | + # debugger-sensitive files with -g and nothing else. |
| 54 | + # |
| 55 | + |
| 56 | + OPAL_STRIP_OPTFLAGS($CFLAGS) |
| 57 | + CFLAGS_WITHOUT_OPTFLAGS="$s_result" |
| 58 | + # Tweak the compiler flags passed to ompirun for Sun Studio SPARC |
| 59 | + # https://svn.open-mpi.org/trac/ompi/ticket/1448 |
| 60 | + if test "x$opal_cv_c_compiler_vendor" = "xsun" && test -n "`echo $host | $GREP sparc`"; then |
| 61 | + DEBUGGER_CFLAGS="-g -xO0" |
| 62 | + else |
| 63 | + # Tweak the compiler flags passed for intel |
| 64 | + # to stop its aggressive inlining of functions |
| 65 | + if test "x$opal_cv_c_compiler_vendor" = "xintel"; then |
| 66 | + DEBUGGER_CFLAGS="-g -O0" |
| 67 | + else |
| 68 | + DEBUGGER_CFLAGS="-g" |
| 69 | + fi |
| 70 | + fi |
| 71 | + AC_MSG_CHECKING([which of CFLAGS are ok for debugger modules]) |
| 72 | + AC_MSG_RESULT([$CFLAGS_WITHOUT_OPTFLAGS]) |
| 73 | + AC_MSG_CHECKING([for debugger extra CFLAGS]) |
| 74 | + AC_MSG_RESULT([$DEBUGGER_CFLAGS]) |
| 75 | + |
| 76 | + AC_SUBST(CFLAGS_WITHOUT_OPTFLAGS) |
| 77 | + 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 | + _OMPI_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-fasynchronous-unwind-tables], |
| 86 | + [MPIR_UNWIND_CFLAGS="-fasynchronous-unwind-tables"], |
| 87 | + [_OMPI_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) |
| 96 | +]) |
0 commit comments