Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[meta] update MSRV to 1.75, turn on asm support unconditionally #267

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 0 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,58 +225,6 @@ comes with significant tradeoffs. As such the current recommendation is:
function calling it), and document to their users that this function should be called to
guarantee that probes are registered.

## Notes

The `usdt` crate requires [inline asm][inline-asm], a feature stabilized in Rust 1.59.
Prior to that version, a nightly toolchain was required to import the feature. For legacy
convenience reasons, the crate contains also an empty, no-op implementation, which generates all the
same probe macros, but with empty bodies (thus not requiring inline asm). This may be selected by
passing the `--no-default-features` flag when building the crate, or by using `default-features =
false` in the [`[dependencies]` table][feature-deps] of one's `Cargo.toml`.

Library developers may use `usdt` as an optional dependency, gated by a feature, for example
named `usdt-probes` or similar. This feature would imply the `usdt/asm` feature, but the `usdt`
crate could be used with the no-op implementation by default. For example, your `Cargo.toml`
might contain

```
[dependencies]
usdt = { version = "*", optional = true, default-features = false }

# ... later

[features]
usdt-probes = ["usdt/asm"]
```

This allows users to opt into probes if they are using a suitably new toolchain, or and older
nightly with the `asm` feature enabled on their project.

### The Rust `asm` feature

On toolchains prior to 1.59, inline asm was [not available][asm-issue] without the feature being
enabled. This applies to code _calling_ the probe macros, in addition to `usdt` where they are
implemented. Those generated probe macros must be in a module that is either built with a >=1.59
toolchain or where the `feature(asm)` configuration is present.


#### Toolchain versions and the `asm_sym` feature

On macOS (where the linker is involved in USDT probe creation) on toolchains prior to 1.66, the
`asm_sym` feature is required (in addition to `asm` in nightly toolchains prior to November 2021;
see [this issue][asm-feature-flags]). For such a toolchain, this feature can be included just on
macOS e.g., with `#![cfg_attr(target_os = "macos", feature(asm_sym))]`, or unconditionally on all
platforms.

The addition of the `asm_sym` feature presents an unfortunate problem. It is no longer possible to
compile the `usdt` crate (or any crate defining probes) with a toolchain from before that feature
was added _and_ after its addition. In the former case, we'd get errors about an unknown feature
should we include the `asm_sym` feature, and we'd get errors about functionality behind a feature
gate from later compilers should we omit the feature.

Fortunately with the stabilization of `asm_sym` in 1.66, using this crate should become much
simpler.

## References

[1]: https://illumos.org/books/dtrace/chp-usdt.html#chp-usdt
Expand All @@ -285,7 +233,3 @@ simpler.
[4]: https://docs.rs/serde_json/1.0.68/serde_json/fn.to_string.html
[serde-json-error]: https://docs.serde.rs/serde_json/error/struct.Error.html
[serde-runtime-fail]: https://github.com/serde-rs/serde/issues/1307
[inline-asm]: https://github.com/rust-lang/rust/issues/72016
[feature-deps]: https://doc.rust-lang.org/cargo/reference/features.html#dependency-features
[asm-issue]: https://github.com/rust-lang/rust/issues/72016
[asm-feature-flags]: https://github.com/rust-lang/rust/pull/90348
27 changes: 0 additions & 27 deletions common-build.rs

This file was deleted.

2 changes: 1 addition & 1 deletion dusty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ publish = false
[dependencies]
clap = { version = "4.5.11", features = ["derive"] }
dof = { path = "../dof", features = ["des"] }
usdt = { path = "../usdt", features = ["asm"] }
usdt = { path = "../usdt" }
usdt-impl = { path = "../usdt-impl", features = ["des"] }
7 changes: 0 additions & 7 deletions probe-test-attr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,3 @@ publish = false
[dependencies]
usdt = { path = "../usdt", default-features = false }
serde = "1"

[build-dependencies]
version_check = "0.9.5"

[features]
default = ["asm"]
asm = ["usdt/asm"]
3 changes: 0 additions & 3 deletions probe-test-attr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(usdt_need_feat_asm, feature(asm))]
#![cfg_attr(usdt_need_feat_asm_sym, feature(asm_sym))]

use serde::Serialize;

/// By deriving the `serde::Serialize` trait, the `Arg` struct can be used as an argument to a
Expand Down
5 changes: 0 additions & 5 deletions probe-test-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,3 @@ usdt = { path = "../usdt", default-features = false }

[build-dependencies]
usdt = { path = "../usdt" }
version_check = "0.9.5"

[features]
default = ["asm"]
asm = ["usdt/asm"]
10 changes: 0 additions & 10 deletions probe-test-build/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ use usdt::Builder;
fn main() {
println!("cargo:rerun-if-changed=build.rs");

if !version_check::is_min_version("1.59").unwrap_or(false) {
println!("cargo:rustc-cfg=usdt_need_feat_asm");
}
#[cfg(target_os = "macos")]
if version_check::supports_feature("asm_sym").unwrap_or(false)
&& !version_check::is_min_version("1.67").unwrap_or(false)
{
println!("cargo:rustc-cfg=usdt_need_feat_asm_sym");
}

println!("cargo:rerun-if-changed=test.d");
Builder::new("test.d").build().unwrap();
}
3 changes: 0 additions & 3 deletions probe-test-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(usdt_need_feat_asm, feature(asm))]
#![cfg_attr(usdt_need_feat_asm_sym, feature(asm_sym))]

use std::thread::sleep;
use std::time::Duration;

Expand Down
7 changes: 0 additions & 7 deletions probe-test-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,3 @@ publish = false

[dependencies]
usdt = { path = "../usdt", default-features = false }

[build-dependencies]
version_check = "0.9.5"

[features]
default = ["asm"]
asm = ["usdt/asm"]
3 changes: 0 additions & 3 deletions probe-test-macro/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(usdt_need_feat_asm, feature(asm))]
#![cfg_attr(usdt_need_feat_asm_sym, feature(asm_sym))]

use std::thread::sleep;
use std::time::Duration;

Expand Down
3 changes: 0 additions & 3 deletions tests/argument-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ publish = false
[dependencies]
usdt = { path = "../../usdt" }
serde = "1"

[build-dependencies]
version_check = "0.9.5"
2 changes: 0 additions & 2 deletions tests/argument-types/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(usdt_need_feat_asm, feature(asm))]
#![cfg_attr(usdt_need_feat_asm_sym, feature(asm_sym))]
use serde::Serialize;

/// Most struct or tuple types implementing serde::Serialize may be used in probes.
Expand Down
3 changes: 0 additions & 3 deletions tests/compile-errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ serde_json = "*"

[dev-dependencies]
trybuild = "1.0.98"

[build-dependencies]
version_check = "0.9.5"
1 change: 0 additions & 1 deletion tests/does-it-work/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ usdt-tests-common = { path = "../../usdt-tests-common" }

[build-dependencies]
usdt = { path = "../../usdt" }
version_check = "0.9.5"
10 changes: 0 additions & 10 deletions tests/does-it-work/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ use usdt::Builder;
fn main() {
println!("cargo:rerun-if-changed=build.rs");

if !version_check::is_min_version("1.59").unwrap_or(false) {
println!("cargo:rustc-cfg=usdt_need_feat_asm");
}
#[cfg(target_os = "macos")]
if version_check::supports_feature("asm_sym").unwrap_or(false)
&& !version_check::is_min_version("1.67").unwrap_or(false)
{
println!("cargo:rustc-cfg=usdt_need_feat_asm_sym");
}

println!("cargo:rerun-if-changed=test.d");
Builder::new("test.d").build().unwrap();
}
2 changes: 0 additions & 2 deletions tests/does-it-work/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg_attr(usdt_need_feat_asm, feature(asm))]
#![cfg_attr(usdt_need_feat_asm_sym, feature(asm_sym))]
#![allow(non_snake_case)]

use usdt::register_probes;
Expand Down
7 changes: 0 additions & 7 deletions tests/empty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,3 @@ default-features = false
[build-dependencies.usdt]
path = "../../usdt"
default-features = false

[build-dependencies]
version_check = "0.9.5"

[features]
default = ["asm"]
asm = ["usdt/asm"]
Loading