[CMAkE] Add support for generating PDBs for LD 2.42+

This commit is contained in:
Timo Kreuzer 2024-03-04 20:34:28 +02:00
parent 77392be363
commit 7d62b5e1ae
2 changed files with 35 additions and 9 deletions

View File

@ -292,6 +292,13 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
# This will set I18N_DEFS for later use
set_i18n_language(${I18N_LANG})
# For MSVC builds, this puts all debug symbols file in the same directory.
if(MSVC)
set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
else() #if(SEPARATE_DBG)
set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/symbols")
endif()
# Compiler specific definitions and macros
if(MSVC)
include(sdk/cmake/msvc.cmake)
@ -337,7 +344,7 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
add_subdirectory(sdk/include/asm)
if(ARCH MATCHES "64$")
include(sdk/cmake/baseaddress64.cmake)
include(sdk/cmake/baseaddress64.cmake)
elseif(NO_ROSSYM)
include(sdk/cmake/baseaddress_dwarf.cmake)
elseif(MSVC)
@ -346,13 +353,6 @@ Enable this if the module uses typeid or dynamic_cast. You will probably need to
include(sdk/cmake/baseaddress.cmake)
endif()
# For MSVC builds, this puts all debug symbols file in the same directory.
if(MSVC)
set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/msvc_pdb")
elseif(SEPARATE_DBG)
set(CMAKE_PDB_OUTPUT_DIRECTORY "${REACTOS_BINARY_DIR}/symbols")
endif()
#begin with boot so reactos_cab target is defined before all other modules
add_subdirectory(boot)
add_subdirectory(base)

View File

@ -212,7 +212,33 @@ else()
set(ARCH2 ${ARCH})
endif()
if(SEPARATE_DBG)
# Try to detect the linker and version
execute_process(COMMAND ${CMAKE_C_COMPILER} "-Wl,--version" ERROR_QUIET OUTPUT_VARIABLE LINKER_VERSION_OUTPUT)
if(LINKER_VERSION_OUTPUT MATCHES "GNU ld.*")
# Extract the version number
string(REGEX REPLACE ".*GNU ld \\(GNU Binutils\\) ([0-9\\.]+).*" "\\1" LD_VERSION_NUMBER ${LINKER_VERSION_OUTPUT})
message (STATUS "Using GNU ld version ${LD_VERSION_NUMBER}")
if(LD_VERSION_NUMBER VERSION_GREATER_EQUAL "2.42")
set(PDB_SUPPORTED TRUE)
else()
set(PDB_SUPPORTED FALSE)
endif()
message (STATUS "PDBs supported: ${PDB_SUPPORTED}")
else()
set(PDB_SUPPORTED FALSE)
endif()
if(_WINKD_ AND PDB_SUPPORTED)
# Generate PDBs
message(STATUS "Generating PDB debug information.")
set(PDB_OPTION "-Wl,--pdb=${CMAKE_PDB_OUTPUT_DIRECTORY}/<TARGET_NAME>.pdb")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PDB_OPTION}")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PDB_OPTION}")
set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${PDB_OPTION}")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${PDB_OPTION}")
set(CMAKE_RC_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES> ${PDB_OPTION}")
elseif(SEPARATE_DBG)
# PDB style debug puts all dwarf debug info in a separate dbg file
message(STATUS "Building separate debug symbols")
file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/symbols)