Skip to content

Commit 4b82b7c

Browse files
authored
update libtorch (#1096)
* update libtorch * update libuv * fix libuv * disable iphoneos
1 parent d0fca1a commit 4b82b7c

File tree

3 files changed

+48
-19
lines changed

3 files changed

+48
-19
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/third_party/breakpad/src/client/linux/handler/exception_handler.cc b/third_party/breakpad/src/client/linux/handler/exception_handler.cc
2+
--- a/third_party/breakpad/src/client/linux/handler/exception_handler.cc
3+
+++ b/third_party/breakpad/src/client/linux/handler/exception_handler.cc
4+
@@ -138,7 +138,7 @@ void InstallAlternateStackLocked() {
5+
// SIGSTKSZ may be too small to prevent the signal handlers from overrunning
6+
// the alternative stack. Ensure that the size of the alternative stack is
7+
// large enough.
8+
- static const unsigned kSigStackSize = std::max(16384, SIGSTKSZ);
9+
+ const unsigned kSigStackSize = std::max<unsigned>(16384, SIGSTKSZ);
10+
11+
// Only set an alternative stack if there isn't already one, or if the current
12+
// one is too small.

packages/l/libtorch/xmake.lua

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,24 @@ package("libtorch")
1010
add_versions("v1.8.2", "e0495a7aa104471d95dc85a1b8f6473fbcc427a8")
1111
add_versions("v1.9.0", "d69c22dd61a2f006dcfe1e3ea8468a3ecaf931aa")
1212
add_versions("v1.9.1", "dfbd030854359207cb3040b864614affeace11ce")
13+
add_versions("v1.11.0", "bc2c6edaf163b1a1330e37a6e34caf8c553e4755")
1314

1415
add_patches("1.9.x", path.join(os.scriptdir(), "patches", "1.9.0", "gcc11.patch"), "4191bb3296f18f040c230d7c5364fb160871962d6278e4ae0f8bc481f27d8e4b")
16+
add_patches("1.11.0", path.join(os.scriptdir(), "patches", "1.11.0", "gcc11.patch"), "1404b0bc6ce7433ecdc59d3412e3d9ed507bb5fd2cd59134a254d7d4a8d73012")
1517

1618
add_configs("python", {description = "Build python interface.", default = false, type = "boolean"})
17-
add_configs("ninja", {description = "Use ninja as build tool.", default = true, type = "boolean"})
19+
add_configs("cuda", {description = "Enable CUDA support.", default = false, type = "boolean"})
20+
add_configs("ninja", {description = "Use ninja as build tool.", default = false, type = "boolean"})
21+
add_configs("blas", {description = "Set BLAS vendor.", default = "openblas", type = "string", values = {"mkl", "openblas", "eigen"}})
1822
if not is_plat("macosx") then
19-
add_configs("blas", {description = "Set BLAS vendor.", default = "openblas", type = "string", values = {"mkl", "openblas"}})
23+
add_configs("distributed", {description = "Enable distributed support.", default = false, type = "boolean"})
2024
end
2125

2226
add_deps("cmake")
23-
add_deps("python 3.x", {kind = "binary", system = false})
24-
add_deps("libuv")
25-
add_deps("cuda", {optional = true, configs = {utils = {"nvrtc", "cudnn", "cufft", "curand", "cublas", "cudart_static"}}})
26-
add_deps("nvtx", {optional = true, system = true})
27+
add_deps("python 3.x", {kind = "binary"})
28+
2729
add_includedirs("include")
2830
add_includedirs("include/torch/csrc/api/include")
29-
3031
if is_plat("linux") then
3132
add_syslinks("rt")
3233
end
@@ -40,6 +41,13 @@ package("libtorch")
4041
if package:config("ninja") then
4142
package:add("deps", "ninja")
4243
end
44+
if package:config("cuda") then
45+
package:add("deps", "cuda", {configs = {utils = {"nvrtc", "cudnn", "cufft", "curand", "cublas", "cudart_static"}}})
46+
package:add("deps", "nvtx")
47+
end
48+
if package:config("distributed") then
49+
package:add("deps", "libuv")
50+
end
4351
if not package:is_plat("macosx") and package:config("blas") then
4452
package:add("deps", package:config("blas"))
4553
end
@@ -56,13 +64,12 @@ package("libtorch")
5664
end
5765

5866
-- tackle link flags
59-
local has_cuda = package:dep("cuda"):exists() and package:dep("nvtx"):exists()
6067
local libnames = {"torch", "torch_cpu"}
61-
if has_cuda then
68+
if package:config("cuda") then
6269
table.insert(libnames, "torch_cuda")
6370
end
6471
table.insert(libnames, "c10")
65-
if has_cuda then
72+
if package:config("cuda") then
6673
table.insert(libnames, "c10_cuda")
6774
end
6875
local suffix = ""
@@ -82,11 +89,10 @@ package("libtorch")
8289
end
8390
end
8491
if not package:config("shared") then
85-
for _, lib in ipairs({"nnpack", "pytorch_qnnpack", "qnnpack", "XNNPACK", "caffe2_protos", "protobuf-lite", "protobuf", "protoc", "onnx", "onnx_proto", "foxi_loader", "pthreadpool", "eigen_blas", "fbgemm", "cpuinfo", "clog", "dnnl", "mkldnn", "sleef", "asmjit", "fmt"}) do
92+
for _, lib in ipairs({"nnpack", "pytorch_qnnpack", "qnnpack", "XNNPACK", "caffe2_protos", "protobuf-lite", "protobuf", "protoc", "onnx", "onnx_proto", "foxi_loader", "pthreadpool", "eigen_blas", "fbgemm", "cpuinfo", "clog", "dnnl", "mkldnn", "sleef", "asmjit", "fmt", "kineto"}) do
8693
package:add("links", lib)
8794
end
8895
end
89-
package:add("links", "kineto")
9096

9197
-- some patches to the third-party cmake files
9298
io.replace("third_party/fbgemm/CMakeLists.txt", "PRIVATE FBGEMM_STATIC", "PUBLIC FBGEMM_STATIC", {plain = true})
@@ -97,7 +103,9 @@ package("libtorch")
97103

98104
-- prepare python
99105
os.vrun("python -m pip install typing_extensions pyyaml")
100-
local configs = {"-DUSE_MPI=OFF", "-DCMAKE_INSTALL_LIBDIR=lib"}
106+
local configs = {"-DUSE_MPI=OFF",
107+
"-DCMAKE_INSTALL_LIBDIR=lib",
108+
"-DATEN_NO_TEST=ON"}
101109
if package:config("python") then
102110
table.insert(configs, "-DBUILD_PYTHON=ON")
103111
os.vrun("python -m pip install numpy")
@@ -116,11 +124,17 @@ package("libtorch")
116124
elseif package:config("blas") == "openblas" then
117125
table.insert(configs, "-DBLAS=OpenBLAS")
118126
envs.OpenBLAS_HOME = package:dep("openblas"):installdir()
127+
elseif package:config("blas") == "eigen" then
128+
table.insert(configs, "-DBLAS=Eigen")
119129
end
120130
end
121-
envs.libuv_ROOT = package:dep("libuv"):installdir()
131+
if package:config("distributed") then
132+
envs.libuv_ROOT = package:dep("libuv"):installdir()
133+
end
122134
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
123135
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
136+
table.insert(configs, "-DUSE_CUDA=" .. (package:config("cuda") and "ON" or "OFF"))
137+
table.insert(configs, "-DUSE_DISTRIBUTED=" .. (package:config("distributed") and "ON" or "OFF"))
124138
if package:is_plat("windows") then
125139
table.insert(configs, "-DCAFFE2_USE_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
126140
end

packages/l/libuv/xmake.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package("libuv")
66

77
set_urls("https://github.com/libuv/libuv/archive/$(version).zip",
88
"https://github.com/libuv/libuv.git")
9+
add_versions("v1.44.1", "d233a9c522a9f4afec47b0d12f302d93d114a9e3ea104150e65f55fd931518e6")
910
add_versions("v1.42.0", "031130768b25ae18c4b9d4a94ba7734e2072b11c6fce3e554612c516c3241402")
1011
add_versions("v1.41.0", "cb89a8b9f686c5ccf7ed09a9e0ece151a73ebebc17af3813159c335b02181794")
1112
add_versions("v1.40.0", "61366e30d8484197dc9e4a94dbd98a0ba52fb55cb6c6d991af1f3701b10f322b")
@@ -39,19 +40,21 @@ package("libuv")
3940
if package:config("shared") then
4041
package:add("defines", "USING_UV_SHARED")
4142
end
42-
if package:version():ge("1.40.0") then
43+
if package:version():ge("1.40") and package:version():lt("1.44") then
4344
package:add("linkdirs", path.join("lib", package:debug() and "Debug" or "Release"))
4445
end
4546
end)
4647

4748
on_install("windows", function (package)
48-
local configs = {}
49+
local configs = {"-DLIBUV_BUILD_TESTS=OFF", "-DLIBUV_BUILD_BENCH=OFF"}
4950
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
5051
import("package.tools.cmake").install(package, configs)
51-
os.cp("include", package:installdir())
52+
if package:version():lt("1.40") then
53+
os.cp("include", package:installdir())
54+
end
5255
end)
5356

54-
on_install("macosx", "linux", "iphoneos", "android@linux,macosx", "mingw@linux,macosx", function (package)
57+
on_install("macosx", "linux", "android@linux,macosx", "mingw@linux,macosx", function (package)
5558
local configs = {}
5659
if package:config("shared") then
5760
table.insert(configs, "--enable-shared=yes")
@@ -61,7 +64,7 @@ package("libuv")
6164
if package:config("pic") ~= false then
6265
table.insert(configs, "--with-pic")
6366
end
64-
if package:version():ge("1.40.0") and package:is_plat("iphoneos") then
67+
if package:is_plat("iphoneos") and package:version():ge("1.40") and package:version():lt("1.44") then
6568
-- fix CoreFoundation type definition
6669
io.replace("src/unix/darwin.c", "!TARGET_OS_IPHONE", "1", {plain = true})
6770
end

0 commit comments

Comments
 (0)