[ROCm][Windows] Run hipcc with compatibility flags. (#153986)

See also https://github.com/ROCm/TheRock/issues/590. Including the `-Wno-ignored-attributes` flag here avoids 700MB of log warning spam while compiling and the `-fms-extensions` seems beneficial to include: https://clang.llvm.org/docs/MSVCCompatibility.html.

Co-authored-by: Aaryaman Vasishta <jem456.vasishta@gmail.com>
Co-authored-by: Scott Todd <scott.todd0@gmail.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/153986
Approved by: https://github.com/Skylion007, https://github.com/jeffdaily

Co-authored-by: Aaryaman Vasishta <jem456.vasishta@gmail.com>
This commit is contained in:
Scott Todd 2025-05-21 20:26:52 +00:00 committed by PyTorch MergeBot
parent 3c89cfd460
commit 0e5f2339d0
2 changed files with 7 additions and 0 deletions

View File

@ -1733,6 +1733,10 @@ if(USE_ROCM)
endforeach() endforeach()
endif() endif()
if(WIN32)
list(APPEND HIP_CXX_FLAGS "-fms-extensions")
endif()
# Call again since Caffe2_HIP_INCLUDE is extended with ATen include dirs. # Call again since Caffe2_HIP_INCLUDE is extended with ATen include dirs.
hip_include_directories(${Caffe2_HIP_INCLUDE}) hip_include_directories(${Caffe2_HIP_INCLUDE})

View File

@ -1028,6 +1028,9 @@ if(USE_ROCM)
list(APPEND HIP_HIPCC_FLAGS --offload-compress) list(APPEND HIP_HIPCC_FLAGS --offload-compress)
if(WIN32) if(WIN32)
add_definitions(-DROCM_ON_WINDOWS) add_definitions(-DROCM_ON_WINDOWS)
list(APPEND HIP_CXX_FLAGS -fms-extensions)
# Suppress warnings about dllexport.
list(APPEND HIP_CXX_FLAGS -Wno-ignored-attributes)
endif() endif()
add_definitions(-DROCM_VERSION=${ROCM_VERSION_DEV_INT}) add_definitions(-DROCM_VERSION=${ROCM_VERSION_DEV_INT})
add_definitions(-DTORCH_HIP_VERSION=${TORCH_HIP_VERSION}) add_definitions(-DTORCH_HIP_VERSION=${TORCH_HIP_VERSION})