Skip to content

Commit

Permalink
Add -gdwarf-aranges flag for llvm-mingw Clang
Browse files Browse the repository at this point in the history
Clang does not generate DWARF aranges data by default, which makes
DrMingw not able to parse the DWARF debug symbols. Add -gdwarf-aranges
explicitly.

See: jrfonseca/drmingw#42 (comment)
  • Loading branch information
alvinhochun committed Apr 19, 2022
1 parent 7a5f142 commit dc85593
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ if (MINGW)
else ()
message(WARNING "Linker Security Flags not enabled!")
endif ()

# Clang does not generate DWARF aranges data by default, which makes
# DrMingw not able to parse the DWARF debug symbols. Add -gdwarf-aranges
# explicitly.
# See: https://github.com/jrfonseca/drmingw/issues/42#issuecomment-516614561
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -gdwarf-aranges")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -gdwarf-aranges")
endif ()

set(GLOBAL_PROFILE ${GLOBAL_PROFILE}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
)
elseif (MSVC)
set(SECURITY_C_FLAGS ${CMAKE_C_FLAGS})
set(SECURITY_CXX_FLAGS ${CMAKE_CXX_FLAGS})
Expand Down
8 changes: 8 additions & 0 deletions 3rdparty/ext_qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ if (WIN32)
if (QT_ENABLE_DEBUG_INFO)
# Set the option to build Qt with debugging info enabled
list(APPEND _QT_conf -force-debug-info)
if (MINGW)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
list(APPEND _QT_conf
QMAKE_CFLAGS+=-gdwarf-aranges
QMAKE_CXXFLAGS+=-gdwarf-aranges
)
endif ()
endif ()
endif(QT_ENABLE_DEBUG_INFO)
if (QT_ENABLE_DYNAMIC_OPENGL)
list(APPEND _QT_conf -opengl dynamic -angle)
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ add_feature_info("Dr. Mingw" USE_DRMINGW "Enable the Dr. Mingw crash handler")
else (USE_MINGW_HARDENING_LINKER)
message(WARNING "Linker Security Flags not enabled!")
endif (USE_MINGW_HARDENING_LINKER)

# Clang does not generate DWARF aranges data by default, which makes
# DrMingw not able to parse the DWARF debug symbols. Add -gdwarf-aranges
# explicitly.
# See: https://github.com/jrfonseca/drmingw/issues/42#issuecomment-516614561
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -gdwarf-aranges")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -gdwarf-aranges")
endif ()
elseif (MSVC)
# Increase the stack size to match MinGW's. Prevents crashes with GMic.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:4194304")
Expand Down

0 comments on commit dc85593

Please sign in to comment.