File pytorch-fix-hip-clang-build.patch of Package python-torch
diff --git a/aten/CMakeLists.txt b/aten/CMakeLists.txt
index bda6aea32..bd81f6027 100644
--- a/aten/CMakeLists.txt
+++ b/aten/CMakeLists.txt
@@ -67,6 +67,10 @@ if(USE_ROCM)
include(LoadHIP)
if(NOT PYTORCH_FOUND_HIP)
set(USE_ROCM OFF)
+ else()
+ add_compile_definitions("__HIP_PLATFORM_AMD__")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__HIP_PLATFORM_AMD__")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__HIP_PLATFORM_AMD__")
endif()
endif()
diff --git a/c10/hip/CMakeLists.txt b/c10/hip/CMakeLists.txt
index f153030e7..0302ac75e 100644
--- a/c10/hip/CMakeLists.txt
+++ b/c10/hip/CMakeLists.txt
@@ -39,7 +39,7 @@ if(NOT BUILD_LIBTORCHLESS)
# caffe2_hip adds a bunch of dependencies like rocsparse, but c10/hip is supposed to be
# minimal. I'm not sure if we need hip_hcc or not; for now leave it out
-
+ set_target_properties(c10_hip PROPERTIES CXX_STANDARD 17)
# If building shared library, set dllimport/dllexport proper.
target_compile_options(c10_hip PRIVATE "-DC10_HIP_BUILD_MAIN_LIB")
# Enable hidden visibility if compiler supports it.
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
index 9be7f3732..95ff8296e 100644
--- a/caffe2/CMakeLists.txt
+++ b/caffe2/CMakeLists.txt
@@ -845,10 +845,9 @@ if(CMAKE_COMPILER_IS_GNUCXX AND BUILD_LIBTORCH_CPU_WITH_DEBUG)
endif()
if(USE_LLVM AND LLVM_FOUND)
- llvm_map_components_to_libnames(LLVM_LINK_LIBS
+ llvm_config(torch_cpu USE_SHARED
support core analysis executionengine instcombine
scalaropts transformutils ${LLVM_TARGETS_TO_BUILD} orcjit)
- target_link_libraries(torch_cpu PRIVATE ${LLVM_LINK_LIBS})
if(APPLE)
set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/unexported_symbols.lds")
set_target_properties(torch_cpu PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT})
@@ -1635,7 +1634,7 @@ if(USE_ROCM)
# Since PyTorch files contain HIP headers, these flags are required for the necessary definitions to be added.
target_compile_options(torch_hip PUBLIC ${HIP_CXX_FLAGS}) # experiment
-
+ set_target_properties(torch_hip PROPERTIES CXX_STANDARD 17)
target_link_libraries(torch_hip PUBLIC c10_hip)
if(NOT INTERN_BUILD_MOBILE)
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index e78305e0a..59ad0c579 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1056,7 +1056,7 @@ if(USE_ROCM)
list(APPEND HIP_CXX_FLAGS -Wno-duplicate-decl-specifier)
list(APPEND HIP_CXX_FLAGS -DCAFFE2_USE_MIOPEN)
list(APPEND HIP_CXX_FLAGS -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_HIP)
- list(APPEND HIP_CXX_FLAGS -std=c++17)
+ #list(APPEND HIP_CXX_FLAGS -std=c++17)
list(APPEND HIP_CXX_FLAGS -DHIPBLAS_V2)
if(HIP_NEW_TYPE_ENUMS)
list(APPEND HIP_CXX_FLAGS -DHIP_NEW_TYPE_ENUMS)
@@ -1072,7 +1072,7 @@ if(USE_ROCM)
endif(CMAKE_BUILD_TYPE MATCHES Debug)
# needed for compat with newer versions of hip-clang that introduced C++20 mangling rules
- list(APPEND HIP_HIPCC_FLAGS -fclang-abi-compat=17)
+ #list(APPEND HIP_HIPCC_FLAGS -fclang-abi-compat=17)
set(HIP_CLANG_FLAGS ${HIP_CXX_FLAGS})
# Ask hcc to generate device code during compilation so we can use