diff --git a/auxdir/x_ac_debug.m4 b/auxdir/x_ac_debug.m4
index a63c4380565bbb1d7fa0d0f1abc04b1183b7e893..b1b100dbba7e3e678b9591a26b6c60f832246d3c 100644
--- a/auxdir/x_ac_debug.m4
+++ b/auxdir/x_ac_debug.m4
@@ -12,6 +12,7 @@
 #    If CFLAGS are not passed to configure, they will be set based
 #    on whether debugging has been enabled.  Also, the NDEBUG macro
 #    (used by assert) will be set accordingly.
+#    Always enable "-g" debug flag so debugger can work with srun.
 #
 #  WARNINGS:
 #    This macro must be placed after AC_PROG_CC or equivalent.
@@ -30,9 +31,13 @@ AC_DEFUN([X_AC_DEBUG],
       esac
     ]
   )
+
+  if test -z "$ac_save_CFLAGS"; then
+    test "$ac_cv_prog_cc_g" = yes && CFLAGS="-g $CFLAGS"
+  fi
+
   if test "$ac_debug" = yes; then
     if test -z "$ac_save_CFLAGS"; then
-      test "$ac_cv_prog_cc_g" = yes && CFLAGS="-g $CFLAGS"
       test "$GCC" = yes && 
            CFLAGS="-Wall -fno-strict-aliasing $CFLAGS"
       AC_DEFINE(DEBUG_SYSTEM, 1, [Define for extra debug messages.])