Skip to content

Use DWARF unwinding with Clang to avoid overproduction of linking warnings with clang + gfortran #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions acsm_compiler_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,30 @@ AC_DEFUN([ACSM_SET_CXX_FLAGS],
ACSM_CXXFLAGS_DBG="$ACSM_CXXFLAGS_DBG -Wunused-parameter -Wunused -Wpointer-arith -Wformat -Wparentheses -Qunused-arguments -Woverloaded-virtual -fno-limit-debug-info"
ACSM_NODEPRECATEDFLAG="-Wno-deprecated"

dnl On Darwin with clang + gfortran, we get very many warnings for compact unwinding issues
dnl We deliberately keep relying on the less performant dwarf unwinding until the over-production of warnings is solved.
old_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} -femit-dwarf-unwind=always -Wl,-keep_dwarf_unwind -Wl,-no_compact_unwind "

AC_LINK_IFELSE([
AC_LANG_SOURCE(
[[int main() { return 0; }]]
)],[
AC_MSG_RESULT(<<< Disabling compact unwinding and retaining dwarf unwinding for gfortran compatibility >>>)
dnl Ideally we would be passing this as a fortran flag.
ACSM_CXXFLAGS_OPT+=" -femit-dwarf-unwind=always -Wl,-keep_dwarf_unwind -Wl,-no_compact_unwind "
ACSM_CXXFLAGS_DEVEL+=" -femit-dwarf-unwind=always -Wl,-keep_dwarf_unwind -Wl,-no_compact_unwind "
ACSM_CXXFLAGS_DBG+=" -femit-dwarf-unwind=always -Wl,-keep_dwarf_unwind -Wl,-no_compact_unwind "
ACSM_CFLAGS_OPT+=" -femit-dwarf-unwind=always -Wl,-keep_dwarf_unwind -Wl,-no_compact_unwind "
dnl CFLAGS_OPT are copied into _DEVEL and _DBG
],[
AC_MSG_RESULT(<<< Compact unwinding enabled >>>)
dnl Failed to link with new flags, do not add them
])
dnl Reset to old flags in case for any potential other test
CXXFLAGS="$old_CXXFLAGS"
AC_OUTPUT

dnl -ftrapping-math is only supported with
dnl clang 10 and newer.
dnl
Expand All @@ -617,9 +641,9 @@ AC_DEFUN([ACSM_SET_CXX_FLAGS],
ACSM_PARANOID_FLAGS="$ACSM_PARANOID_FLAGS -Wunused-parameter -Wunused-value -Wvariadic-macros"
ACSM_PARANOID_FLAGS="$ACSM_PARANOID_FLAGS -Wvolatile-register-var -Wwrite-strings"

ACSM_CFLAGS_OPT="-O2 -Qunused-arguments -Wunused"
ACSM_CFLAGS_DEVEL="$ACSM_CFLAGS_OPT -g -Wimplicit -fno-limit-debug-info -Wunused"
ACSM_CFLAGS_DBG="-g -Wimplicit -Qunused-arguments -fno-limit-debug-info -Wunused"
ACSM_CFLAGS_OPT+="-O2 -Qunused-arguments -Wunused"
ACSM_CFLAGS_DEVEL+="$ACSM_CFLAGS_OPT -g -Wimplicit -fno-limit-debug-info -Wunused"
ACSM_CFLAGS_DBG+="-g -Wimplicit -Qunused-arguments -fno-limit-debug-info -Wunused"
],

dnl default case
Expand Down