-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed as not planned
Closed as not planned
Copy link
Labels
C-bugCategory: bugCategory: bug
Description
Problem
There are some APIs of tokio requiring a special --cfg tokio_unstable
, like the tokio console with the feature tracing
. By putting this rustflag in [build]
or [target.<triple>]
session, it works well. However, when I put the flag in the [target.<cfg>]
(like [target.'cfg(all())']
), tokio
cannot compile.
i.e., this works,
[target.'cfg(all())']
rustflags = [
"--cfg", "always",
# "--cfg", "tokio_unstable"
]
[target.aarch64-apple-darwin]
rustflags = [
"--cfg", "apple",
"--cfg", "tokio_unstable"
]
but this doesn't.
[target.'cfg(all())']
rustflags = [
"--cfg", "always",
"--cfg", "tokio_unstable"
]
[target.aarch64-apple-darwin]
rustflags = [
"--cfg", "apple",
# "--cfg", "tokio_unstable"
]
By comparing the cargo check --verbose
, I found that the --extern
option for tracing
passing to rustc
is missing. This caused the compiler to fail to resolve the tracing
crate.
- --extern tracing=/Users/bugenzhao/Developer/Works/profile-rustflags/target/debug/deps/libtracing-5ca025473bc6506d.rmeta --cap-lints allow --cfg mac --cfg tokio_unstable
+ --cap-lints allow --cfg mac --cfg tokio_unstable
error[E0433]: failed to resolve: use of undeclared crate or module `tracing`
--> /Users/bugenzhao/.cargo/registry/src/gitproxy.zycloud.tk-1ecc6299db9ec823/tokio-1.21.1/src/macros/trace.rs:4:13
|
4 | tracing::trace!(
| ^^^^^^^ use of undeclared crate or module `tracing`
Steps
- Initialize an empty crate.
- Add the tokio dependency.
tokio = { version = "*", features = ["full", "tracing"] }
- In
.cargo/config.toml
:
[target.'cfg(all())']
rustflags = [
"--cfg", "tokio_unstable"
]
- Run
cargo check --verbose
.
Possible Solution(s)
No response
Notes
I've also tried to specify it in the profile.<profile>.rustflags
, and it does not work either. :(
Version
cargo 1.64.0-nightly (85b500cca 2022-07-24)
release: 1.64.0-nightly
commit-hash: 85b500ccad8cd0b63995fd94a03ddd4b83f7905b
commit-date: 2022-07-24
host: aarch64-apple-darwin
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.79.1 (sys:0.4.55+curl-7.83.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.5.0 [64-bit]
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug