vcpkg/ports/libtorch/fix-build.patch

185 lines
6.8 KiB
Diff
Raw Normal View History

diff --git a/c10/cuda/CMakeLists.txt b/c10/cuda/CMakeLists.txt
2024-07-04 11:01:35 +08:00
index c0628d0..5dfb7f2 100644
--- a/c10/cuda/CMakeLists.txt
+++ b/c10/cuda/CMakeLists.txt
@@ -74,7 +74,11 @@ add_subdirectory(test)
# Note: for now, we will put all export path into one single Caffe2Targets group
# to deal with the cmake deployment need. Inside the Caffe2Targets set, the
# individual libraries like libc10.so and libcaffe2.so are still self-contained.
-install(TARGETS c10_cuda EXPORT Caffe2Targets DESTINATION lib)
+install(TARGETS c10_cuda EXPORT Caffe2Targets
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+ )
foreach(file ${C10_CUDA_HEADERS})
get_filename_component( dir ${file} DIRECTORY )
install( FILES ${file} DESTINATION include/c10/cuda/${dir} )
diff --git a/c10/util/Exception.h b/c10/util/Exception.h
2024-07-04 11:01:35 +08:00
index ecbc7c1..2dd1001 100644
--- a/c10/util/Exception.h
+++ b/c10/util/Exception.h
@@ -14,6 +14,9 @@
#define __func__ __FUNCTION__
#endif
+#ifdef _MSC_VER
+#pragma warning(suppress : 4251)
+#endif
namespace c10 {
/// The primary ATen error class.
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
2024-07-04 11:01:35 +08:00
index b46a444..255d7f4 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1581,19 +1581,10 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
target_compile_options(onnx PRIVATE -Wno-deprecated-declarations)
endif()
else()
- add_library(onnx UNKNOWN IMPORTED)
- find_library(ONNX_LIBRARY NAMES onnx REQUIRED)
- if(NOT ONNX_LIBRARY)
- message(FATAL_ERROR "Cannot find onnx")
- endif()
- set_property(TARGET onnx PROPERTY IMPORTED_LOCATION ${ONNX_LIBRARY})
- add_library(onnx_proto UNKNOWN IMPORTED)
- find_library(ONNX_PROTO_LIBRARY NAMES onnx_proto REQUIRED)
- if(NOT ONNX_PROTO_LIBRARY)
- message(FATAL_ERROR "Cannot find onnx")
- endif()
- set_property(TARGET onnx_proto PROPERTY IMPORTED_LOCATION ${ONNX_PROTO_LIBRARY})
- message("-- Found onnx: ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY}")
2024-07-04 11:01:35 +08:00
+ find_package(ONNX REQUIRED)
+ set(ONNX_LIBRARY onnx)
+ set(ONNX_PROTO_LIBRARY onnx_proto)
+ message("-- Found onnx")
list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx)
endif()
include_directories(${FOXI_INCLUDE_DIRS})
diff --git a/pyproject.toml b/pyproject.toml
2024-07-04 11:01:35 +08:00
index eb764cb..c70f317 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,11 +4,9 @@ requires = [
"wheel",
"astunparse",
"numpy",
- "ninja",
"pyyaml",
- "cmake",
"typing-extensions",
- "requests",
+# "requests",
]
# Use legacy backend to import local packages in setup.py
build-backend = "setuptools.build_meta:__legacy__"
diff --git a/setup.py b/setup.py
2024-07-04 11:01:35 +08:00
index 7016441..a6416c7 100644
--- a/setup.py
+++ b/setup.py
@@ -263,7 +263,7 @@ from tools.setup_helpers.env import build_type, IS_DARWIN, IS_LINUX, IS_WINDOWS
################################################################################
VERBOSE_SCRIPT = True
-RUN_BUILD_DEPS = True
+RUN_BUILD_DEPS = False
# see if the user passed a quiet flag to setup.py arguments and respect
# that in our parts of the build
EMIT_BUILD_WARNING = False
@@ -307,9 +307,9 @@ else:
# Constant known variables used throughout this file
cwd = os.path.dirname(os.path.abspath(__file__))
-lib_path = os.path.join(cwd, "torch", "lib")
+lib_path = os.path.join(cwd, "../../@TARGET_TRIPLET@/", "lib")
third_party_path = os.path.join(cwd, "third_party")
-caffe2_build_dir = os.path.join(cwd, "build")
+caffe2_build_dir = os.path.join(cwd, "../../@TARGET_TRIPLET@")
# CMAKE: full path to python library
if IS_WINDOWS:
@@ -759,7 +759,7 @@ class build_ext(setuptools.command.build_ext.build_ext):
with open(filename) as f:
return json.load(f)
- ninja_files = glob.glob("build/*compile_commands.json")
+ ninja_files = glob.glob("../../@TARGET_TRIPLET@/*compile_commands.json")
cmake_files = glob.glob("torch/lib/build/*/compile_commands.json")
all_commands = [entry for f in ninja_files + cmake_files for entry in load(f)]
diff --git a/third_party/nvfuser/csrc/instrumentation.h b/third_party/nvfuser/csrc/instrumentation.h
2024-07-04 11:01:35 +08:00
index cd57825..75e81e9 100644
--- a/third_party/nvfuser/csrc/instrumentation.h
+++ b/third_party/nvfuser/csrc/instrumentation.h
@@ -2,7 +2,7 @@
#include <utils.h>
-#include <nvToolsExt.h>
+#include <nvtx3/nvToolsExt.h>
// NOLINTNEXTLINE(modernize-deprecated-headers)
#include <stdio.h>
diff --git a/tools/setup_helpers/env.py b/tools/setup_helpers/env.py
2024-07-04 11:01:35 +08:00
index d87e97a..6c52f39 100644
--- a/tools/setup_helpers/env.py
+++ b/tools/setup_helpers/env.py
@@ -19,7 +19,7 @@ CONDA_DIR = os.path.join(os.path.dirname(sys.executable), "..")
IS_64BIT = struct.calcsize("P") == 8
-BUILD_DIR = "build"
+BUILD_DIR = "../../@TARGET_TRIPLET@"
def check_env_flag(name: str, default: str = "") -> bool:
diff --git a/torch/lib/libshm/CMakeLists.txt b/torch/lib/libshm/CMakeLists.txt
2024-07-04 11:01:35 +08:00
index 20158a9..7d3c475 100644
--- a/torch/lib/libshm/CMakeLists.txt
+++ b/torch/lib/libshm/CMakeLists.txt
@@ -71,6 +71,10 @@ target_link_libraries(torch_shm_manager PRIVATE shm)
set_target_properties(torch_shm_manager PROPERTIES
INSTALL_RPATH "${_rpath_portable_origin}/../lib")
-install(TARGETS shm LIBRARY DESTINATION ${LIBSHM_INSTALL_LIB_SUBDIR})
+install(TARGETS shm
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+)
install(FILES libshm.h DESTINATION "include")
install(TARGETS torch_shm_manager DESTINATION "bin")
diff --git a/torch/lib/libshm_windows/CMakeLists.txt b/torch/lib/libshm_windows/CMakeLists.txt
2024-07-04 11:01:35 +08:00
index df2a106..b86e0b6 100644
--- a/torch/lib/libshm_windows/CMakeLists.txt
+++ b/torch/lib/libshm_windows/CMakeLists.txt
@@ -19,9 +19,12 @@ target_include_directories(shm PRIVATE
target_link_libraries(shm torch c10)
-install(TARGETS shm DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}")
+install(TARGETS shm
+ LIBRARY DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}"
+ ARCHIVE DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}"
+ RUNTIME DESTINATION "${LIBSHM_INSTALL_BIN_SUBDIR}")
install(FILES libshm.h DESTINATION "include")
if(MSVC AND BUILD_SHARED_LIBS)
- install(FILES $<TARGET_PDB_FILE:shm> DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}" OPTIONAL)
+ install(FILES $<TARGET_PDB_FILE:shm> DESTINATION "${LIBSHM_INSTALL_BIN_SUBDIR}" OPTIONAL)
endif()
diff --git a/torch/utils/cpp_extension.py b/torch/utils/cpp_extension.py
2024-07-04 11:01:35 +08:00
index 6600eb3..15ddc8c 100644
--- a/torch/utils/cpp_extension.py
+++ b/torch/utils/cpp_extension.py
@@ -38,7 +38,7 @@ SHARED_FLAG = '/DLL' if IS_WINDOWS else '-shared'
_HERE = os.path.abspath(__file__)
_TORCH_PATH = os.path.dirname(os.path.dirname(_HERE))
-TORCH_LIB_PATH = os.path.join(_TORCH_PATH, 'lib')
+TORCH_LIB_PATH = os.path.join(_TORCH_PATH, '../../../@TARGET_TRIPLET@', 'lib')
SUBPROCESS_DECODE_ARGS = ('oem',) if IS_WINDOWS else ()