File: ompi_setup_debugger_flags.m4

package info (click to toggle)
openmpi 5.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 202,312 kB
  • sloc: ansic: 612,441; makefile: 42,495; sh: 11,230; javascript: 9,244; f90: 7,052; java: 6,404; perl: 5,154; python: 1,856; lex: 740; fortran: 61; cpp: 20; tcl: 12
file content (96 lines) | stat: -rw-r--r-- 3,930 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
dnl                         University Research and Technology
dnl                         Corporation.  All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl                         of Tennessee Research Foundation.  All rights
dnl                         reserved.
dnl Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
dnl                         University of Stuttgart.  All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl                         All rights reserved.
dnl Copyright (c) 2006-2019 Cisco Systems, Inc.  All rights reserved.
dnl Copyright (c) 2006-2009 Sun Microsystems, Inc.  All rights reserved.
dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC.  All rights
dnl                         reserved.
dnl Copyright (c) 2009      Oak Ridge National Labs.  All rights reserved.
dnl Copyright (c) 2015      Research Organization for Information Science
dnl                         and Technology (RIST). All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

dnl Check to see if specific CFLAGS work
dnl $1: compiler flags to check
dnl $2: Action if the flags work
dnl $3: Action if the flags do not work
AC_DEFUN([_OMPI_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS],[
    OPAL_VAR_SCOPE_PUSH([OMPI_SETUP_DEBUGGER_FLAGS_CFLAGS_save])

    OMPI_SETUP_DEBUGGER_FLAGS_CFLAGS_save=$CFLAGS
    AC_MSG_CHECKING([if $1 compiler flag works])
    CFLAGS="$CFLAGS $1"
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[int i = 3;])],
        [OMPI_SETUP_DEBUGGER_FLAGS_HAPPY=yes],
        [OMPI_SETUP_DEBUGGER_FLAGS_HAPPY=no])
    AC_MSG_RESULT([$OMPI_SETUP_DEBUGGER_FLAGS_HAPPY])
    CFLAGS=$OMPI_SETUP_DEBUGGER_FLAGS_CFLAGS_save

    OPAL_VAR_SCOPE_POP

    AS_IF([test $OMPI_SETUP_DEBUGGER_FLAGS_HAPPY = yes],
          [$2], [$3])
])

AC_DEFUN([OMPI_SETUP_DEBUGGER_FLAGS],[
    #
    # Do a final process of the CFLAGS to make a WITHOUT_OPTFLAGS
    # version.  We need this so that we can guarantee to build the
    # debugger-sensitive files with -g and nothing else.
    #

    OPAL_STRIP_OPTFLAGS($CFLAGS)
    CFLAGS_WITHOUT_OPTFLAGS="$s_result"
    # Tweak the compiler flags passed to ompirun for Sun Studio SPARC
    # https://svn.open-mpi.org/trac/ompi/ticket/1448
    if test "x$opal_cv_c_compiler_vendor" = "xsun" && test -n "`echo $host | $GREP sparc`"; then
        DEBUGGER_CFLAGS="-g -xO0"
    else
        # Tweak the compiler flags passed for intel
        # to stop its aggressive inlining of functions
        if test "x$opal_cv_c_compiler_vendor" = "xintel"; then
            DEBUGGER_CFLAGS="-g -O0"
        else
            DEBUGGER_CFLAGS="-g"
        fi
    fi
    AC_MSG_CHECKING([which of CFLAGS are ok for debugger modules])
    AC_MSG_RESULT([$CFLAGS_WITHOUT_OPTFLAGS])
    AC_MSG_CHECKING([for debugger extra CFLAGS])
    AC_MSG_RESULT([$DEBUGGER_CFLAGS])

    AC_SUBST(CFLAGS_WITHOUT_OPTFLAGS)
    AC_SUBST(DEBUGGER_CFLAGS)

    # Check for compiler specific flag to add in unwind information.
    # This is needed when attaching using MPIR to unwind back to the
    # user's main function. Certain optimisations can prevent GDB from
    # producing a stack when explicit unwind information is unavailable.
    # This is implied by -g, but we want to save space and don't need
    # full debug symbols.
    _OMPI_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-fasynchronous-unwind-tables],
        [MPIR_UNWIND_CFLAGS="-fasynchronous-unwind-tables"],
        [_OMPI_SETUP_DEBUGGER_FLAGS_TRY_CFLAGS([-Meh_frame -Mframe],
            [MPIR_UNWIND_CFLAGS="-Meh_frame -Mframe"],
            [MPIR_UNWIND_CFLAGS=-g])
        ])

    AC_MSG_CHECKING([for final compiler unwind flags])
    AC_MSG_RESULT([$MPIR_UNWIND_CFLAGS])

    AC_SUBST(MPIR_UNWIND_CFLAGS)
])