Skip to content

Commit 8380c3b

Browse files
committed
runtime: use cargo feature for taskdump instead of cfg
Signed-off-by: ADD-SP <qiqi.zhang@konghq.com>
1 parent 95edd85 commit 8380c3b

File tree

24 files changed

+209
-107
lines changed

24 files changed

+209
-107
lines changed

.cirrus.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ task:
2525
rustc --version
2626
test_script:
2727
- . $HOME/.cargo/env
28-
- cargo test --all --features $TOKIO_STABLE_FEATURES
28+
# - cargo test --all --features $TOKIO_STABLE_FEATURES
2929
# Free the disk space before the next build,
3030
# otherwise cirrus-ci complains about "No space left on device".
3131
- cargo clean
32-
# Enable all unstable features, including io_uring, because it supports
33-
# x86_64 FreeBSD.
34-
- RUSTFLAGS="$RUSTFLAGS --cfg tokio_unstable" RUSTDOCFLAGS="$RUSTDOCFLAGS --cfg tokio_unstable" cargo test --all --all-features
32+
# Enable all unstable features except `taskdump`, which is Linux-only.
33+
- |
34+
RUSTFLAGS="$RUSTFLAGS --cfg tokio_unstable" \
35+
RUSTDOCFLAGS="$RUSTDOCFLAGS --cfg tokio_unstable" \
36+
cargo test \
37+
--verbose \
38+
--features $TOKIO_STABLE_FEATURES,io-uring,tracing
3539
3640
task:
3741
name: FreeBSD docs
@@ -48,7 +52,9 @@ task:
4852
rustc --version
4953
test_script:
5054
- . $HOME/.cargo/env
51-
- cargo doc --lib --no-deps --all-features --document-private-items
55+
# We use `--features $TOKIO_STABLE_FEATURES,io-uring,tracing` instead of
56+
# `--all-features` to exclude `taskdump`, which is Linux-only.
57+
- cargo doc --lib --no-deps --features $TOKIO_STABLE_FEATURES,io-uring,tracing --document-private-items
5258

5359
task:
5460
name: FreeBSD 32-bit

.github/workflows/ci.yml

Lines changed: 155 additions & 59 deletions
Large diffs are not rendered by default.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ unexpected_cfgs = { level = "warn", check-cfg = [
2727
'cfg(tokio_internal_mt_counters)',
2828
'cfg(tokio_no_parking_lot)',
2929
'cfg(tokio_no_tuning_tests)',
30-
'cfg(tokio_taskdump)',
3130
'cfg(tokio_unstable)',
3231
'cfg(target_os, values("cygwin"))',
3332
] }

examples/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ httparse = "1.0"
2424
httpdate = "1.0"
2525
once_cell = "1.5.2"
2626

27+
[target.'cfg(tokio_unstable)'.dev-dependencies]
28+
tokio = { version = "1.0.0", path = "../tokio", features = ["full", "tracing", "taskdump"] }
29+
2730
[target.'cfg(windows)'.dev-dependencies.windows-sys]
2831
version = "0.59"
2932

examples/dump.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
#[cfg(all(
66
tokio_unstable,
7-
tokio_taskdump,
87
target_os = "linux",
98
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
109
))]
@@ -82,7 +81,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
8281

8382
#[cfg(not(all(
8483
tokio_unstable,
85-
tokio_taskdump,
8684
target_os = "linux",
8785
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
8886
)))]

netlify.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
RUSTDOCFLAGS="""
1818
--cfg docsrs \
1919
--cfg tokio_unstable \
20-
--cfg tokio_taskdump \
2120
"""
22-
RUSTFLAGS="--cfg tokio_unstable --cfg tokio_taskdump --cfg docsrs"
21+
RUSTFLAGS="""
22+
--cfg docsrs \
23+
--cfg tokio_unstable
24+
"""
2325

2426
[[redirects]]
2527
from = "/"

tokio/Cargo.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ test-util = ["rt", "sync", "time"]
8686
time = []
8787
# Unstable feature. Requires `--cfg tokio_unstable` to enable.
8888
io-uring = ["dep:io-uring", "libc", "mio/os-poll", "mio/os-ext", "dep:slab"]
89+
# Unstable feature. Requires `--cfg tokio_unstable` to enable.
90+
taskdump = ["dep:backtrace"]
8991

9092
[dependencies]
9193
tokio-macros = { version = "~2.5.0", path = "../tokio-macros", optional = true }
@@ -112,11 +114,7 @@ io-uring = { version = "0.7.6", default-features = false, optional = true }
112114
libc = { version = "0.2.168", optional = true }
113115
mio = { version = "1.0.1", default-features = false, features = ["os-poll", "os-ext"], optional = true }
114116
slab = { version = "0.4.9", optional = true }
115-
116-
# Currently unstable. The API exposed by these features may be broken at any time.
117-
# Requires `--cfg tokio_unstable` to enable.
118-
[target.'cfg(tokio_taskdump)'.dependencies]
119-
backtrace = { version = "0.3.58" }
117+
backtrace = { version = "0.3.58", optional = true }
120118

121119
[target.'cfg(unix)'.dependencies]
122120
libc = { version = "0.2.168", optional = true }
@@ -169,10 +167,10 @@ tracing-mock = "= 0.1.0-beta.1"
169167
[package.metadata.docs.rs]
170168
all-features = true
171169
# enable unstable features in the documentation
172-
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tokio_unstable", "--cfg", "tokio_taskdump"]
173-
# it's necessary to _also_ pass `--cfg tokio_unstable` and `--cfg tokio_taskdump`
170+
rustdoc-args = ["--cfg", "docsrs", "--cfg", "tokio_unstable"]
171+
# it's necessary to _also_ pass `--cfg tokio_unstable`
174172
# to rustc, or else dependencies will not be enabled, and the docs build will fail.
175-
rustc-args = ["--cfg", "tokio_unstable", "--cfg", "tokio_taskdump"]
173+
rustc-args = ["--cfg", "tokio_unstable"]
176174

177175
[package.metadata.playground]
178176
features = ["full", "test-util"]

tokio/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,19 +483,19 @@ compile_error!("Only features sync,macros,io-util,rt,time are supported on wasm.
483483
#[cfg(all(not(tokio_unstable), feature = "io-uring"))]
484484
compile_error!("The `io-uring` feature requires `--cfg tokio_unstable`.");
485485

486-
#[cfg(all(not(tokio_unstable), tokio_taskdump))]
487-
compile_error!("The `tokio_taskdump` feature requires `--cfg tokio_unstable`.");
486+
#[cfg(all(not(tokio_unstable), feature = "taskdump"))]
487+
compile_error!("The `taskdump` feature requires `--cfg tokio_unstable`.");
488488

489489
#[cfg(all(
490-
tokio_taskdump,
490+
feature = "taskdump",
491491
not(doc),
492492
not(all(
493493
target_os = "linux",
494494
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
495495
))
496496
))]
497497
compile_error!(
498-
"The `tokio_taskdump` feature is only currently supported on \
498+
"The `taskdump` feature is only currently supported on \
499499
linux, on `aarch64`, `x86` and `x86_64`."
500500
);
501501

tokio/src/macros/cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ macro_rules! cfg_taskdump {
499499
$(
500500
#[cfg(all(
501501
tokio_unstable,
502-
tokio_taskdump,
502+
feature = "taskdump",
503503
feature = "rt",
504504
target_os = "linux",
505505
any(
@@ -518,7 +518,7 @@ macro_rules! cfg_not_taskdump {
518518
$(
519519
#[cfg(not(all(
520520
tokio_unstable,
521-
tokio_taskdump,
521+
feature = "taskdump",
522522
feature = "rt",
523523
target_os = "linux",
524524
any(

tokio/src/runtime/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct Context {
6666

6767
#[cfg(all(
6868
tokio_unstable,
69-
tokio_taskdump,
69+
feature = "taskdump",
7070
feature = "rt",
7171
target_os = "linux",
7272
any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")
@@ -107,7 +107,7 @@ tokio_thread_local! {
107107

108108
#[cfg(all(
109109
tokio_unstable,
110-
tokio_taskdump,
110+
feature = "taskdump",
111111
feature = "rt",
112112
target_os = "linux",
113113
any(

0 commit comments

Comments
 (0)