diff --git a/Docs/sphinx_documentation/source/BuildingAMReX.rst b/Docs/sphinx_documentation/source/BuildingAMReX.rst index 761bfafb0c7..4b9ff7b6076 100644 --- a/Docs/sphinx_documentation/source/BuildingAMReX.rst +++ b/Docs/sphinx_documentation/source/BuildingAMReX.rst @@ -496,6 +496,8 @@ The list of available options is reported in the :ref:`table ` bel +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ | AMReX_FPE | Build with Floating Point Exceptions checks | NO | YES, NO | +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ + | AMReX_ADDRLINES | Build with minimal debug info for line numbers | YES | YES, NO | + +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ | AMReX_ASSERTIONS | Build with assertions turned on | NO | YES, NO | +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ | AMReX_BOUND_CHECK | Enable bound checking in Array4 class | NO | YES, NO | @@ -618,6 +620,8 @@ In the above snippet, ```` is any of the targets listed in th +-----------------------+-------------------------------------------------+ | Flags_FPE | Floating Point Exception flags (interface) | +-----------------------+-------------------------------------------------+ + | Flags_ADDRLINES | Minimal debug/line numbers flags (interface) | + +-----------------------+-------------------------------------------------+ .. raw:: latex \end{center} diff --git a/Docs/sphinx_documentation/source/Debugging.rst b/Docs/sphinx_documentation/source/Debugging.rst index aa5a9dcc9a3..80fdb48f219 100644 --- a/Docs/sphinx_documentation/source/Debugging.rst +++ b/Docs/sphinx_documentation/source/Debugging.rst @@ -29,6 +29,9 @@ with ``TEST=TRUE`` or ``DEBUG=TRUE`` in GNU make, or with ``-DCMAKE_BUILD_TYPE=D One can also control the setting for ``FArrayBox`` using the runtime parameter, ``fab.init_snan``. Note for Macs, M1 and M2 chips using Arm64 architecture are not able to trap division by zero. +By default, even AMReX release mode builds add minimal address to line debub information. +This can be turned off via ``-DAMReX_ADDRLINES=NO``. + One can get more information than the backtrace of the call stack by instrumenting the code. Here is an example. You know the line ``Real rho = state(cell,0);`` is causing a segfault. You diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt index febdea04b5b..f1f9ec1649b 100644 --- a/Src/CMakeLists.txt +++ b/Src/CMakeLists.txt @@ -86,6 +86,13 @@ foreach(D IN LISTS AMReX_SPACEDIM) $ ) endif () + + if (AMReX_ADDRLINES) + target_link_libraries(amrex_${D}d + PUBLIC + $ + ) + endif () endforeach() # General configuration diff --git a/Tools/CMake/AMReXConfig.cmake.in b/Tools/CMake/AMReXConfig.cmake.in index 7b7f04727a2..b533e59dc18 100644 --- a/Tools/CMake/AMReXConfig.cmake.in +++ b/Tools/CMake/AMReXConfig.cmake.in @@ -88,6 +88,7 @@ set(AMReX_HDF5_ZFP_FOUND @AMReX_HDF5_ZFP@) # Compilation options set(AMReX_FPE_FOUND @AMReX_FPE@) +set(AMReX_ADDRLINES_FOUND @AMReX_ADDRLINES@) set(AMReX_PIC_FOUND @AMReX_PIC@) set(AMReX_ASSERTIONS_FOUND @AMReX_ASSERTIONS@) diff --git a/Tools/CMake/AMReXFlagsTargets.cmake b/Tools/CMake/AMReXFlagsTargets.cmake index a2e86b2fbd3..ef6c4e3f53a 100644 --- a/Tools/CMake/AMReXFlagsTargets.cmake +++ b/Tools/CMake/AMReXFlagsTargets.cmake @@ -5,6 +5,7 @@ # Flags_CXX --> Optional flags for C++ code # Flags_Fortran --> Optional flags for Fortran code # Flags_FPE --> Floating-Point Exception flags for both C++ and Fortran +# Flags_ADDRLINES --> Minimal debug flags that only record address to line number # # These INTERFACE targets can be added to the AMReX export set. # @@ -61,6 +62,24 @@ else () endif () +# +# Minimal Debug info for address --> line +# +add_library(Flags_ADDRLINES INTERFACE) +add_library(AMReX::Flags_ADDRLINES ALIAS Flags_ADDRLINES) + +target_compile_options( Flags_ADDRLINES + INTERFACE + $<${_cxx_gnu}:-g1> + $<${_cxx_intel}:> # TODO: help wanted + $<${_cxx_pgi}:> # TODO: help wanted + $<${_cxx_cray}:> # TODO: help wanted + $<${_cxx_clang}:-gline-tables-only> + $<${_cxx_appleclang}:-gline-tables-only> + # info for profiling: minimal addition and needed for Intel VTune + $<${_cxx_intelllvm}:-gline-tables-only -fdebug-info-for-profiling> +) + # # C++ flags # diff --git a/Tools/CMake/AMReXOptions.cmake b/Tools/CMake/AMReXOptions.cmake index e24244ea29a..8842a7d2964 100644 --- a/Tools/CMake/AMReXOptions.cmake +++ b/Tools/CMake/AMReXOptions.cmake @@ -369,6 +369,9 @@ print_option( AMReX_IPO ) option(AMReX_FPE "Enable Floating Point Exceptions checks" OFF) print_option( AMReX_FPE ) +option(AMReX_ADDRLINES "Add minimal debug info that only records line numbers" ON) +print_option( AMReX_ADDRLINES ) + if ( "${CMAKE_BUILD_TYPE}" MATCHES "Debug" ) option( AMReX_ASSERTIONS "Enable assertions" ON) else () @@ -377,7 +380,7 @@ endif () print_option( AMReX_ASSERTIONS ) -option(AMReX_BOUND_CHECK "Enable bound checking in Array4 class" OFF) +option(AMReX_BOUND_CHECK "Enable bound checking in Array4 class" OFF) print_option( AMReX_BOUND_CHECK ) if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") diff --git a/Tools/CMake/AMReX_Config.cmake b/Tools/CMake/AMReX_Config.cmake index 8c76fb5e36d..822bf557462 100644 --- a/Tools/CMake/AMReX_Config.cmake +++ b/Tools/CMake/AMReX_Config.cmake @@ -23,8 +23,10 @@ function (configure_amrex AMREX_TARGET) # # Check that needed options have already been defined # - if ( ( NOT ( DEFINED AMReX_MPI ) ) OR ( NOT (DEFINED AMReX_OMP) ) - OR ( NOT (DEFINED AMReX_PIC) ) OR (NOT (DEFINED AMReX_FPE))) + if ( (NOT (DEFINED AMReX_MPI) ) OR (NOT (DEFINED AMReX_OMP) ) + OR (NOT (DEFINED AMReX_PIC) ) OR (NOT (DEFINED AMReX_FPE) ) + OR (NOT (DEFINED AMReX_ADDRLINES) ) + ) message ( AUTHOR_WARNING "Required options are not defined" ) endif ()