Skip to content

Commit dbe0d55

Browse files
authored
Merge pull request #9886 from awlauria/02_v5.0.x
v5.0.x: Remove -O2 from --enable-debug builds.
2 parents 9605bed + 2704c9f commit dbe0d55

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

config/ompi_setup_fc.m4

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ AC_DEFUN([OMPI_SETUP_FC],[
7272
ompi_fc_happy=0],
7373
[ompi_fc_happy=1])
7474

75-
AS_IF([test $ompi_fc_happy -eq 1 && test "$WANT_DEBUG" = "1" && test "$enable_debug_symbols" != "no"],
76-
[FCFLAGS="$FCFLAGS -g"
77-
OPAL_FLAGS_UNIQ(FCFLAGS)
78-
AC_MSG_WARN([-g has been added to FCFLAGS (--enable-debug)])
79-
])
80-
8175
# Make sure the compiler actually works, if not cross-compiling.
8276
# Don't just use the AC macro so that we can have a pretty
8377
# message.

config/opal_configure_options.m4

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,47 @@ AC_DEFINE_UNQUOTED(OPAL_ENABLE_TIMING, $WANT_TIMING,
187187
AM_CONDITIONAL([OPAL_COMPILE_TIMING], [test "$WANT_TIMING" = "1"])
188188
AM_CONDITIONAL([OPAL_INSTALL_TIMING_BINARIES], [test "$WANT_TIMING" = "1" && test "$enable_binaries" != "no"])
189189

190+
# Later calls to AC_PROG_CC/CXX/FC can
191+
# inject things like -O2 into compile flags if they are
192+
# not defined, which we don't want. Make sure these flags
193+
# are at least set to an empty string now.
194+
#
195+
# Complicating matters is that autogen can re-order
196+
# these calls toward the top of configure. This block should
197+
# be at/near the top, so do it now.
198+
#
190199
if test "$WANT_DEBUG" = "0"; then
191200
CFLAGS="-DNDEBUG $CFLAGS"
192201
CXXFLAGS="-DNDEBUG $CXXFLAGS"
202+
203+
# NDEBUG doesn't exist in fortran, so just make sure it's defined.
204+
if [ test -z "$FCFLAGS" ]; then
205+
FCFLAGS=""
206+
fi
207+
else
208+
# Do we want debugging symbols?
209+
if test "$enable_debug_symbols" != "no" ; then
210+
CFLAGS="$CFLAGS -g"
211+
CXXFLAGS="$CXXFLAGS -g"
212+
FCFLAGS="$FCFLAGS -g"
213+
AC_MSG_WARN([-g has been added to compiler (--enable-debug)])
214+
else
215+
# If not set, define compile flags to an empty string
216+
# to prevent AC_PROG_CC/FC/CXX from modifying compiler flags.
217+
# See: https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/C-Compiler.html
218+
# for more info.
219+
if [ test -z "$CFLAGS" ]; then
220+
CFLAGS=""
221+
fi
222+
if [ test -z "$CXXFLAGS" ]; then
223+
CXXFLAGS=""
224+
fi
225+
if [ test -z "$FCFLAGS" ]; then
226+
FCFLAGS=""
227+
fi
228+
fi
193229
fi
230+
194231
AC_DEFINE_UNQUOTED(OPAL_ENABLE_DEBUG, $WANT_DEBUG,
195232
[Whether we want developer-level debugging code or not])
196233

config/opal_setup_cc.m4

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,6 @@ AC_DEFUN([OPAL_SETUP_CC],[
276276
OPAL_FLAGS_UNIQ(LDFLAGS)
277277
WANT_DEBUG=1
278278
fi
279-
280-
281-
# Do we want debugging?
282-
if test "$WANT_DEBUG" = "1" && test "$enable_debug_symbols" != "no" ; then
283-
CFLAGS="$CFLAGS -g"
284-
285-
OPAL_FLAGS_UNIQ(CFLAGS)
286-
AC_MSG_WARN([-g has been added to CFLAGS (--enable-debug)])
287-
fi
288279

289280
# These flags are generally gcc-specific; even the
290281
# gcc-impersonating compilers won't accept them.
@@ -428,20 +419,12 @@ AC_DEFUN([_OPAL_PROG_CC],[
428419
#
429420
# Check for the compiler
430421
#
431-
OPAL_VAR_SCOPE_PUSH([opal_cflags_save dummy opal_cc_arvgv0])
422+
OPAL_VAR_SCOPE_PUSH([dummy opal_cc_arvgv0])
432423

433-
# AC_USE_SYSTEM_EXTENSIONS alters CFLAGS (e.g., adds -g -O2)
434-
opal_cflags_save="$CFLAGS"
435424
AC_USE_SYSTEM_EXTENSIONS
436-
# AC_USE_SYSTEM_EXTENSIONS will modify CFLAGS if nothing was in there
437-
# beforehand. We don't want that. So if there was nothing in
438-
# CFLAGS, put nothing back in there.
439-
AS_IF([test -z "$opal_cflags_save"], [CFLAGS=])
440425

441-
opal_cflags_save="$CFLAGS"
442426
AC_PROG_CC
443427
BASECC="`basename $CC`"
444-
CFLAGS="$opal_cflags_save"
445428
OPAL_CC="$CC"
446429
AC_DEFINE_UNQUOTED(OPAL_CC, "$OPAL_CC", [OMPI underlying C compiler])
447430
set dummy $CC

0 commit comments

Comments
 (0)