Skip to content

Commit 293ac61

Browse files
committed
fix: compile pthreadpool successfully on Windows
1 parent 494fa1d commit 293ac61

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

WORKSPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ http_archive(
218218
# pthreadpool is a dependency of XNNPACK, from 2025-04-02
219219
http_archive(
220220
name = "pthreadpool",
221+
patch_args = [
222+
"-p1",
223+
],
224+
patches = [
225+
"@//third_party:pthreadpool.patch",
226+
],
221227
# `curl -L <url> | shasum -a 256`
222228
sha256 = "745e56516d6a58d183eb33d9017732d87cff43ce9f78908906f9faa52633e421",
223229
strip_prefix = "pthreadpool-b92447772365661680f486e39a91dfe6675adafc",

third_party/mediapipe_workaround.diff

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/mediapipe/framework/output_stream_handler.cc b/mediapipe/framework/output_stream_handler.cc
2-
index e27d1c68..55f2f3bd 100644
2+
index e27d1c688..55f2f3bd3 100644
33
--- a/mediapipe/framework/output_stream_handler.cc
44
+++ b/mediapipe/framework/output_stream_handler.cc
55
@@ -143,9 +143,7 @@ OutputStreamHandler::GetMonitoringInfo() {
@@ -14,7 +14,7 @@ index e27d1c68..55f2f3bd 100644
1414
return monitoring_info_vector;
1515
}
1616
diff --git a/mediapipe/framework/port/opencv_core_inc.h b/mediapipe/framework/port/opencv_core_inc.h
17-
index 12862472..1a409417 100644
17+
index 128624725..1a4094173 100644
1818
--- a/mediapipe/framework/port/opencv_core_inc.h
1919
+++ b/mediapipe/framework/port/opencv_core_inc.h
2020
@@ -20,7 +20,7 @@
@@ -27,7 +27,7 @@ index 12862472..1a409417 100644
2727
#endif
2828

2929
diff --git a/mediapipe/tasks/cc/core/task_api_factory.h b/mediapipe/tasks/cc/core/task_api_factory.h
30-
index a11a23fc..dbb5fe6c 100644
30+
index a11a23fcf..dbb5fe6ca 100644
3131
--- a/mediapipe/tasks/cc/core/task_api_factory.h
3232
+++ b/mediapipe/tasks/cc/core/task_api_factory.h
3333
@@ -76,15 +76,17 @@ class TaskApiFactory {
@@ -50,7 +50,7 @@ index a11a23fc..dbb5fe6c 100644
5050
std::move(graph_config), std::move(resolver),
5151
std::move(packets_callback), std::move(default_executor),
5252
diff --git a/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc b/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc
53-
index 2ff140c0..128a4326 100644
53+
index 2ff140c07..128a43263 100644
5454
--- a/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc
5555
+++ b/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc
5656
@@ -387,6 +387,13 @@ class HolisticLandmarkerGraph : public core::ModelTaskGraph {
@@ -67,3 +67,17 @@ index 2ff140c0..128a4326 100644
6767
}
6868
}
6969

70+
diff --git a/mediapipe/util/tflite/tflite_model_loader.cc b/mediapipe/util/tflite/tflite_model_loader.cc
71+
index 4809cdc92..acc97a980 100644
72+
--- a/mediapipe/util/tflite/tflite_model_loader.cc
73+
+++ b/mediapipe/util/tflite/tflite_model_loader.cc
74+
@@ -71,7 +71,7 @@ TfLiteModelLoader::LoadFromPathAndGetResource(
75+
delete model;
76+
res.reset();
77+
});
78+
- return TfLiteModelWithResource{.model_packet = std::move(model_packet),
79+
- .resource = std::move(model_resource)};
80+
+ return TfLiteModelWithResource{/*.model_packet = */ std::move(model_packet),
81+
+ /*.resource = */ std::move(model_resource)};
82+
}
83+
} // namespace mediapipe

third_party/pthreadpool.patch

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index 396537f..081a0a2 100644
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -67,9 +67,11 @@ cc_library(
6+
hdrs = [
7+
"include/pthreadpool.h",
8+
],
9+
- copts = [
10+
- "-std=c11",
11+
- ] + select({
12+
+ copts = select({
13+
+ ":windows_x86_64": ["/std:c11", "/experimental:c11atomics"],
14+
+ ":windows_arm64": ["/std:c11", "/experimental:c11atomics"],
15+
+ "//conditions:default": ["-std=c11"],
16+
+ }) + select({
17+
":optimized_build": ["-O2"],
18+
"//conditions:default": [],
19+
}) + select({

0 commit comments

Comments
 (0)