diff --git a/config/ompi_configure_options.m4 b/config/ompi_configure_options.m4 index 517225b546..810ad23d21 100644 --- a/config/ompi_configure_options.m4 +++ b/config/ompi_configure_options.m4 @@ -143,6 +143,9 @@ fi AC_DEFINE_UNQUOTED(OMPI_ENABLE_DEBUG, $WANT_DEBUG, [Whether we want developer-level debugging code or not]) +AC_ARG_ENABLE(debug-symbols, + AC_HELP_STRING([--disable-debug-symbols], + [Disable adding compiler flags to enable debugging symbols if --enable-debug is specified. For non-debugging builds, this flag has no effect.])) # # Fortran 77 diff --git a/config/ompi_setup_cc.m4 b/config/ompi_setup_cc.m4 index 420e17ef7a..397b389656 100644 --- a/config/ompi_setup_cc.m4 +++ b/config/ompi_setup_cc.m4 @@ -47,7 +47,7 @@ AC_DEFUN([OMPI_SETUP_CC],[ fi # Do we want debugging? - if test "$WANT_DEBUG" = "1"; then + if test "$WANT_DEBUG" = "1" -a "$enable_debug_symbols" != "no" ; then if test "$ompi_c_vendor" = "gnu"; then CFLAGS="$CFLAGS -g3" else @@ -161,10 +161,14 @@ AC_DEFUN([OMPI_SETUP_CC],[ # be conservative and just use -O. # # Note: gcc-impersonating compilers accept -O3 - if test "$GCC" = yes; then - OPTFLAGS="-O3" + if test "$WANT_DEBUG" = "1"; then + OPTFLAGS= else - OPTFLAGS="-O" + if test "$GCC" = yes; then + OPTFLAGS="-O3" + else + OPTFLAGS="-O" + fi fi OMPI_CHECK_OPTFLAGS("$OMPI_CFLAGS_BEFORE_PICKY") diff --git a/config/ompi_setup_cxx.m4 b/config/ompi_setup_cxx.m4 index d7db7c4b06..9167c08936 100644 --- a/config/ompi_setup_cxx.m4 +++ b/config/ompi_setup_cxx.m4 @@ -42,7 +42,7 @@ AC_DEFUN([OMPI_SETUP_CXX],[ fi # Do we want debugging? - if test "$WANT_DEBUG" = "1"; then + if test "$WANT_DEBUG" = "1" -a "$enable_debug_symbols" != "no" ; then CXXFLAGS="$CXXFLAGS -g" OMPI_UNIQ(CXXFLAGS) AC_MSG_WARN([-g has been added to CXXFLAGS (--enable-debug)]) @@ -148,11 +148,16 @@ AC_DEFUN([OMPI_SETUP_CXX],[ esac # Note: gcc-imperonating compilers accept -O3 - if test "$GXX" = yes; then - OPTFLAGS="-O3" + if test "$WANT_DEBUG" = "1"; then + OPTFLAGS= else - OPTFLAGS="-O" + if test "$GXX" = yes; then + OPTFLAGS="-O3" + else + OPTFLAGS="-O" + fi fi + # config/ompi_check_optflags.m4 OMPI_CHECK_OPTFLAGS(["$CXXFLAGS"]) AC_MSG_CHECKING([for C++ optimization flags])