debugir icon indicating copy to clipboard operation
debugir copied to clipboard

Windows VS 2022 Build Support

Open m3rcer opened this issue 1 month ago • 1 comments

Windows VS 2022 Build Support

  • Switched the core library to static linkage, added MSVC-friendly warning/RTTI flags, and autodetect the VS2022 DIA SDK so the LLVM static component set can link cleanly on Windows. This follows the guidance in issue #26.
if (WIN32)
  find_library(
    DIA_GUIDS_LIB
    NAMES diaguids
    PATHS
      "$ENV{VSINSTALLDIR}/DIA SDK/lib/amd64"
      "$ENV{ProgramFiles}/Microsoft Visual Studio/2022/Community/DIA SDK/lib/amd64"
      "$ENV{ProgramFiles}/Microsoft Visual Studio/2022/BuildTools/DIA SDK/lib/amd64"
      "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/2022/Community/DIA SDK/lib/amd64"
      "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/2022/BuildTools/DIA SDK/lib/amd64"
    NO_DEFAULT_PATH
  )
  if (DIA_GUIDS_LIB)
    list(APPEND llvm_libs ${DIA_GUIDS_LIB})
  endif()
endif()

add_library(dbgir STATIC DebugIR.cpp)

if (NOT LLVM_ENABLE_RTTI)
  target_compile_options(
    dbgir
    PUBLIC
      $<$<CXX_COMPILER_ID:MSVC>:/GR->
      $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fno-rtti>
  )
endif()

if (MSVC)
  set(DEBUGIR_WARN_FLAGS
    /W4
    /permissive-
  )
else()
  set(DEBUGIR_WARN_FLAGS
    -Wall
    -Werror
    -pedantic
    -Wextra
    -Wno-unknown-pragmas
    -Wno-unused-parameter
  )
endif()
  • Updated the LLVM export metadata so LLVMDebugInfoPDB now pulls diaguids.lib from the installed VS2022 Build Tools.
add_library(LLVMDebugInfoPDB STATIC IMPORTED)

set_target_properties(LLVMDebugInfoPDB PROPERTIES
  INTERFACE_LINK_LIBRARIES "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/DIA SDK/lib/amd64/diaguids.lib;LLVMBinaryFormat;LLVMObject;LLVMSupport;LLVMDebugInfoCodeView;LLVMDebugInfoMSF"
)
  • Reconfigured and rebuilt with
    cmake -DLLVM_DIR="C:/IRvana/LLVM-18.1.5/lib/cmake/llvm" -DLINK_LLVM_SHARED=OFF -DCMAKE_BUILD_TYPE=Release ..
    cmake --build . --config Release

m3rcer avatar Nov 26 '25 14:11 m3rcer