Skip to content

Commit 5c12f87

Browse files
committed
fix compile on rust 1.83.0
1 parent 4d38190 commit 5c12f87

File tree

2 files changed

+62
-12
lines changed

2 files changed

+62
-12
lines changed

core/src/co_pool/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::common::ordered_work_steal::{OrderedLocalQueue, OrderedWorkStealQueue
66
use crate::common::{get_timeout_time, now, CondvarBlocker};
77
use crate::coroutine::suspender::Suspender;
88
use crate::scheduler::{SchedulableCoroutine, Scheduler};
9-
use crate::{impl_current_for, impl_display_by_debug, impl_for_named, trace};
9+
use crate::{error, impl_current_for, impl_display_by_debug, impl_for_named, trace};
1010
use dashmap::DashMap;
1111
use std::cell::Cell;
1212
use std::ffi::c_longlong;
@@ -70,10 +70,15 @@ impl Drop for CoroutinePool<'_> {
7070
self.get_running_size(),
7171
"There are still tasks in progress !"
7272
);
73-
assert!(
74-
self.task_queue.is_empty(),
75-
"There are still tasks to be carried out !"
76-
);
73+
if !self.task_queue.is_empty() {
74+
cfg_if::cfg_if!{
75+
if #[cfg(debug_assertions)] {
76+
panic!("There are still tasks to be carried out !");
77+
} else {
78+
error!("Forget some tasks when closing the pool");
79+
}
80+
}
81+
}
7782
}
7883
}
7984

open-coroutine/build.rs

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use cargo_metadata::MetadataCommand;
22
use std::env::var;
3+
use std::fs::{copy, read_dir};
34
use std::path::PathBuf;
45
use tracing::{info, Level};
56
use tracing_appender::rolling::{RollingFileAppender, Rotation};
@@ -74,7 +75,7 @@ fn main() {
7475
.join("registry")
7576
.join("src");
7677
let crates_parent_dirs = Vec::from_iter(
77-
std::fs::read_dir(dep_src_dir.clone())
78+
read_dir(dep_src_dir.clone())
7879
.expect("Failed to read deps")
7980
.flatten(),
8081
);
@@ -163,12 +164,56 @@ fn main() {
163164
{
164165
panic!("failed to build dylib {}", e);
165166
}
167+
// correct dylib path
168+
let hook_deps = out_dir
169+
.join(target)
170+
.join(if cfg!(debug_assertions) {
171+
"debug"
172+
} else {
173+
"release"
174+
})
175+
.join("deps");
176+
let deps = out_dir
177+
.parent()
178+
.expect("can not find deps dir")
179+
.parent()
180+
.expect("can not find deps dir")
181+
.parent()
182+
.expect("can not find deps dir")
183+
.join("deps");
184+
for entry in read_dir(hook_deps.clone())
185+
.expect("can not find deps dir")
186+
.flatten()
187+
{
188+
let file_name = entry.file_name().to_string_lossy().to_string();
189+
if !file_name.contains("open_coroutine_hook") {
190+
continue;
191+
}
192+
if cfg!(target_os = "linux") && file_name.ends_with(".so") {
193+
let from = hook_deps.join(file_name);
194+
let to = deps.join("libopen_coroutine_hook.so");
195+
copy(from.clone(), to.clone()).expect("copy to libopen_coroutine_hook.so failed!");
196+
info!("copy {:?} to {:?} success!", from, to);
197+
} else if cfg!(target_os = "macos") && file_name.ends_with(".dylib") {
198+
let from = hook_deps.join(file_name);
199+
let to = deps.join("libopen_coroutine_hook.dylib");
200+
copy(from.clone(), to.clone()).expect("copy to libopen_coroutine_hook.dylib failed!");
201+
info!("copy {:?} to {:?} success!", from, to);
202+
} else if cfg!(windows) {
203+
if file_name.ends_with(".dll") {
204+
let from = hook_deps.join(file_name);
205+
let to = deps.join("open_coroutine_hook.dll");
206+
copy(from.clone(), to.clone()).expect("copy to open_coroutine_hook.dll failed!");
207+
info!("copy {:?} to {:?} success!", from, to);
208+
} else if file_name.ends_with(".lib") {
209+
let from = hook_deps.join(file_name);
210+
let to = deps.join("open_coroutine_hook.lib");
211+
copy(from.clone(), to.clone()).expect("copy to open_coroutine_hook.lib failed!");
212+
info!("copy {:?} to {:?} success!", from, to);
213+
}
214+
}
215+
}
166216
// link dylib
167-
let hook_deps = out_dir.join(target).join(if cfg!(debug_assertions) {
168-
"debug"
169-
} else {
170-
"release"
171-
});
172-
println!("cargo:rustc-link-search=native={}", hook_deps.display());
217+
println!("cargo:rustc-link-search=native={}", deps.display());
173218
println!("cargo:rustc-link-lib=dylib=open_coroutine_hook");
174219
}

0 commit comments

Comments
 (0)