diff --git a/Cargo.lock b/Cargo.lock index 5cbb1d8f..4a1c745d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,6 @@ version = "0.0.0" dependencies = [ "serde", "usdt", - "version_check", ] [[package]] @@ -200,7 +199,6 @@ dependencies = [ "serde_json", "trybuild", "usdt", - "version_check", ] [[package]] @@ -238,7 +236,6 @@ version = "0.0.0" dependencies = [ "usdt", "usdt-tests-common", - "version_check", ] [[package]] @@ -278,7 +275,6 @@ name = "empty" version = "0.0.0" dependencies = [ "usdt", - "version_check", ] [[package]] @@ -292,7 +288,6 @@ name = "fake-cmd" version = "0.0.0" dependencies = [ "fake-lib", - "version_check", ] [[package]] @@ -300,7 +295,6 @@ name = "fake-lib" version = "0.0.0" dependencies = [ "usdt", - "version_check", ] [[package]] @@ -529,7 +523,6 @@ version = "0.0.0" dependencies = [ "serde", "usdt", - "version_check", ] [[package]] @@ -645,7 +638,6 @@ version = "0.0.0" dependencies = [ "serde", "usdt", - "version_check", ] [[package]] @@ -653,7 +645,6 @@ name = "probe-test-build" version = "0.0.0" dependencies = [ "usdt", - "version_check", ] [[package]] @@ -661,7 +652,6 @@ name = "probe-test-macro" version = "0.0.0" dependencies = [ "usdt", - "version_check", ] [[package]] @@ -741,7 +731,6 @@ version = "0.0.0" dependencies = [ "serde", "usdt", - "version_check", ] [[package]] @@ -750,7 +739,6 @@ version = "0.0.0" dependencies = [ "serde", "usdt", - "version_check", ] [[package]] @@ -979,7 +967,6 @@ dependencies = [ "tokio", "usdt", "usdt-tests-common", - "version_check", ] [[package]] @@ -988,7 +975,6 @@ version = "0.0.0" dependencies = [ "subprocess", "usdt", - "version_check", ] [[package]] @@ -1132,7 +1118,6 @@ name = "usdt" version = "0.5.0" dependencies = [ "dof", - "dtrace-parser", "goblin", "memmap2", "serde", @@ -1169,7 +1154,6 @@ dependencies = [ "syn", "thiserror", "thread-id", - "version_check", ] [[package]] @@ -1195,7 +1179,6 @@ dependencies = [ "serde", "serde_json", "usdt", - "version_check", ] [[package]] @@ -1402,7 +1385,6 @@ name = "zero-arg-probe" version = "0.0.0" dependencies = [ "usdt", - "version_check", ] [[package]] diff --git a/README.md b/README.md index d438ae6d..7ebea767 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/common-build.rs b/common-build.rs deleted file mode 100644 index 15cb9897..00000000 --- a/common-build.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2022 Oxide Computer Company -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -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"); - } -} diff --git a/dusty/Cargo.toml b/dusty/Cargo.toml index faad6f90..c6984981 100644 --- a/dusty/Cargo.toml +++ b/dusty/Cargo.toml @@ -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"] } diff --git a/probe-test-attr/Cargo.toml b/probe-test-attr/Cargo.toml index 46bc1092..0163c1b8 100644 --- a/probe-test-attr/Cargo.toml +++ b/probe-test-attr/Cargo.toml @@ -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"] diff --git a/probe-test-attr/src/main.rs b/probe-test-attr/src/main.rs index 72de7905..b409c97a 100644 --- a/probe-test-attr/src/main.rs +++ b/probe-test-attr/src/main.rs @@ -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 diff --git a/probe-test-build/Cargo.toml b/probe-test-build/Cargo.toml index 0cde71bc..086ccf94 100644 --- a/probe-test-build/Cargo.toml +++ b/probe-test-build/Cargo.toml @@ -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"] diff --git a/probe-test-build/build.rs b/probe-test-build/build.rs index da15a410..5f5e6209 100644 --- a/probe-test-build/build.rs +++ b/probe-test-build/build.rs @@ -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(); } diff --git a/probe-test-build/src/main.rs b/probe-test-build/src/main.rs index 874415d9..21a29859 100644 --- a/probe-test-build/src/main.rs +++ b/probe-test-build/src/main.rs @@ -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; diff --git a/probe-test-macro/Cargo.toml b/probe-test-macro/Cargo.toml index 1668f51f..1414397b 100644 --- a/probe-test-macro/Cargo.toml +++ b/probe-test-macro/Cargo.toml @@ -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"] diff --git a/probe-test-macro/src/main.rs b/probe-test-macro/src/main.rs index 576b2511..4400e231 100644 --- a/probe-test-macro/src/main.rs +++ b/probe-test-macro/src/main.rs @@ -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; diff --git a/tests/argument-types/Cargo.toml b/tests/argument-types/Cargo.toml index 58196148..c0a54244 100644 --- a/tests/argument-types/Cargo.toml +++ b/tests/argument-types/Cargo.toml @@ -7,6 +7,3 @@ publish = false [dependencies] usdt = { path = "../../usdt" } serde = "1" - -[build-dependencies] -version_check = "0.9.5" diff --git a/tests/argument-types/src/main.rs b/tests/argument-types/src/main.rs index cd3fc5d8..ea6c31d6 100644 --- a/tests/argument-types/src/main.rs +++ b/tests/argument-types/src/main.rs @@ -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. diff --git a/tests/compile-errors/Cargo.toml b/tests/compile-errors/Cargo.toml index d5a0ef6c..ffd47acb 100644 --- a/tests/compile-errors/Cargo.toml +++ b/tests/compile-errors/Cargo.toml @@ -11,6 +11,3 @@ serde_json = "*" [dev-dependencies] trybuild = "1.0.98" - -[build-dependencies] -version_check = "0.9.5" diff --git a/tests/does-it-work/Cargo.toml b/tests/does-it-work/Cargo.toml index 55a76e15..cdb0d7e9 100644 --- a/tests/does-it-work/Cargo.toml +++ b/tests/does-it-work/Cargo.toml @@ -10,4 +10,3 @@ usdt-tests-common = { path = "../../usdt-tests-common" } [build-dependencies] usdt = { path = "../../usdt" } -version_check = "0.9.5" diff --git a/tests/does-it-work/build.rs b/tests/does-it-work/build.rs index da15a410..5f5e6209 100644 --- a/tests/does-it-work/build.rs +++ b/tests/does-it-work/build.rs @@ -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(); } diff --git a/tests/does-it-work/src/main.rs b/tests/does-it-work/src/main.rs index 0098dfca..a61ae54e 100644 --- a/tests/does-it-work/src/main.rs +++ b/tests/does-it-work/src/main.rs @@ -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; diff --git a/tests/empty/Cargo.toml b/tests/empty/Cargo.toml index 1d406ba2..bd59d742 100644 --- a/tests/empty/Cargo.toml +++ b/tests/empty/Cargo.toml @@ -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"] diff --git a/tests/empty/build.rs b/tests/empty/build.rs index 82d5a027..e8ec29f6 100644 --- a/tests/empty/build.rs +++ b/tests/empty/build.rs @@ -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=provider.d"); Builder::new("provider.d") .build() diff --git a/tests/empty/src/main.rs b/tests/empty/src/main.rs index 38399d9a..fc8d6134 100644 --- a/tests/empty/src/main.rs +++ b/tests/empty/src/main.rs @@ -12,8 +12,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))] #![deny(warnings)] use usdt::register_probes; diff --git a/tests/fake-cmd/Cargo.toml b/tests/fake-cmd/Cargo.toml index 7a960baa..0efecaca 100644 --- a/tests/fake-cmd/Cargo.toml +++ b/tests/fake-cmd/Cargo.toml @@ -6,6 +6,3 @@ publish = false [dependencies] fake-lib = { path = "../fake-lib" } - -[build-dependencies] -version_check = "0.9.5" diff --git a/tests/fake-cmd/src/main.rs b/tests/fake-cmd/src/main.rs index dfc4a453..25249f8a 100644 --- a/tests/fake-cmd/src/main.rs +++ b/tests/fake-cmd/src/main.rs @@ -12,8 +12,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))] #![deny(warnings)] fn main() { diff --git a/tests/fake-lib/Cargo.toml b/tests/fake-lib/Cargo.toml index 3dda08b3..0faf7136 100644 --- a/tests/fake-lib/Cargo.toml +++ b/tests/fake-lib/Cargo.toml @@ -5,8 +5,7 @@ edition = "2021" publish = false [dependencies] -usdt = { path = "../../usdt", features = ["asm"] } +usdt = { path = "../../usdt" } [build-dependencies] -usdt = { path = "../../usdt", features = ["asm"] } -version_check = "0.9.5" +usdt = { path = "../../usdt" } diff --git a/tests/fake-lib/build.rs b/tests/fake-lib/build.rs index da15a410..5f5e6209 100644 --- a/tests/fake-lib/build.rs +++ b/tests/fake-lib/build.rs @@ -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(); } diff --git a/tests/fake-lib/src/lib.rs b/tests/fake-lib/src/lib.rs index 697a29c0..5f859e79 100644 --- a/tests/fake-lib/src/lib.rs +++ b/tests/fake-lib/src/lib.rs @@ -12,8 +12,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))] #![deny(warnings)] pub use usdt::register_probes; diff --git a/tests/modules/Cargo.toml b/tests/modules/Cargo.toml index 09b8cf13..74c16222 100644 --- a/tests/modules/Cargo.toml +++ b/tests/modules/Cargo.toml @@ -7,6 +7,3 @@ publish = false [dependencies] usdt = { path = "../../usdt" } serde = "1" - -[build-dependencies] -version_check = "0.9.5" diff --git a/tests/modules/src/main.rs b/tests/modules/src/main.rs index 3c1abe10..ae9d8add 100644 --- a/tests/modules/src/main.rs +++ b/tests/modules/src/main.rs @@ -12,9 +12,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))] - mod inner; fn main() { diff --git a/tests/rename-builder/Cargo.toml b/tests/rename-builder/Cargo.toml index 555e3e42..04ddcf9b 100644 --- a/tests/rename-builder/Cargo.toml +++ b/tests/rename-builder/Cargo.toml @@ -10,4 +10,3 @@ serde = "1" [build-dependencies] usdt = { path = "../../usdt" } -version_check = "0.9.5" diff --git a/tests/rename-builder/build.rs b/tests/rename-builder/build.rs index f048054c..727ab734 100644 --- a/tests/rename-builder/build.rs +++ b/tests/rename-builder/build.rs @@ -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").module("still_test").build().unwrap(); } diff --git a/tests/rename-builder/src/main.rs b/tests/rename-builder/src/main.rs index eb3f96f8..18128205 100644 --- a/tests/rename-builder/src/main.rs +++ b/tests/rename-builder/src/main.rs @@ -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))] include!(concat!(env!("OUT_DIR"), "/test.rs")); fn main() { diff --git a/tests/rename/Cargo.toml b/tests/rename/Cargo.toml index a259776e..db8c30db 100644 --- a/tests/rename/Cargo.toml +++ b/tests/rename/Cargo.toml @@ -7,6 +7,3 @@ publish = false [dependencies] usdt = { path = "../../usdt" } serde = "1" - -[build-dependencies] -version_check = "0.9.5" diff --git a/tests/rename/src/main.rs b/tests/rename/src/main.rs index 854a7623..c08e886a 100644 --- a/tests/rename/src/main.rs +++ b/tests/rename/src/main.rs @@ -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))] - #[usdt::provider(provider = "something", probe_format = "probe_{probe}")] mod probes { fn something() {} diff --git a/tests/test-json/Cargo.toml b/tests/test-json/Cargo.toml index d483f6a8..185b134e 100644 --- a/tests/test-json/Cargo.toml +++ b/tests/test-json/Cargo.toml @@ -10,8 +10,5 @@ usdt-tests-common = { path = "../../usdt-tests-common" } serde = "*" serde_json = "*" -[build-dependencies] -version_check = "0.9.5" - [dev-dependencies] tokio = { version = "1.39.2", features = [ "full" ] } diff --git a/tests/test-json/src/main.rs b/tests/test-json/src/main.rs index e36283fe..a4bde438 100644 --- a/tests/test-json/src/main.rs +++ b/tests/test-json/src/main.rs @@ -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 serde::{Serialize, Serializer}; // Expected error message from serialization failure diff --git a/tests/test-unique-id/Cargo.toml b/tests/test-unique-id/Cargo.toml index 7a8eae29..20d783b1 100644 --- a/tests/test-unique-id/Cargo.toml +++ b/tests/test-unique-id/Cargo.toml @@ -9,6 +9,3 @@ usdt = { path = "../../usdt" } [dev-dependencies] subprocess = "0.2" - -[build-dependencies] -version_check = "0.9.5" diff --git a/tests/test-unique-id/src/main.rs b/tests/test-unique-id/src/main.rs index c03cf109..da70b888 100644 --- a/tests/test-unique-id/src/main.rs +++ b/tests/test-unique-id/src/main.rs @@ -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))] - #[usdt::provider] mod with_ids { use usdt::UniqueId; diff --git a/tests/usize/Cargo.toml b/tests/usize/Cargo.toml index f1986a48..17fa9db8 100644 --- a/tests/usize/Cargo.toml +++ b/tests/usize/Cargo.toml @@ -5,10 +5,9 @@ edition = "2021" publish = false [dependencies] -usdt = { path = "../../usdt", features = ["asm"] } +usdt = { path = "../../usdt" } serde = "*" serde_json = "*" [build-dependencies] -usdt = { path = "../../usdt", features = ["asm"] } -version_check = "0.9.5" +usdt = { path = "../../usdt" } diff --git a/tests/usize/src/main.rs b/tests/usize/src/main.rs index e9bfca02..b8dc7ca5 100644 --- a/tests/usize/src/main.rs +++ b/tests/usize/src/main.rs @@ -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))] - #[usdt::provider] mod usize__test { fn emit_usize(_: usize) {} diff --git a/tests/zero-arg-probe/Cargo.toml b/tests/zero-arg-probe/Cargo.toml index 04b634e4..9a614ce3 100644 --- a/tests/zero-arg-probe/Cargo.toml +++ b/tests/zero-arg-probe/Cargo.toml @@ -9,4 +9,3 @@ usdt = { path = "../../usdt" } [build-dependencies] usdt = { path = "../../usdt" } -version_check = "0.9.5" diff --git a/tests/zero-arg-probe/build.rs b/tests/zero-arg-probe/build.rs index da15a410..5f5e6209 100644 --- a/tests/zero-arg-probe/build.rs +++ b/tests/zero-arg-probe/build.rs @@ -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(); } diff --git a/tests/zero-arg-probe/src/main.rs b/tests/zero-arg-probe/src/main.rs index e8936f5b..7d2b134f 100644 --- a/tests/zero-arg-probe/src/main.rs +++ b/tests/zero-arg-probe/src/main.rs @@ -12,8 +12,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))] #![deny(warnings)] use usdt::register_probes; diff --git a/usdt-attr-macro/Cargo.toml b/usdt-attr-macro/Cargo.toml index 8e01c003..d4acc5ee 100644 --- a/usdt-attr-macro/Cargo.toml +++ b/usdt-attr-macro/Cargo.toml @@ -17,9 +17,5 @@ syn = { version = "2", features = ["full"] } quote = "1" usdt-impl = { path = "../usdt-impl", default-features = false, version = "=0.5.0" } -[features] -default = ["asm"] -asm = ["usdt-impl/asm"] - [dev-dependencies] rstest = "0.21.0" diff --git a/usdt-impl/Cargo.toml b/usdt-impl/Cargo.toml index dfea8f7b..d347c06e 100644 --- a/usdt-impl/Cargo.toml +++ b/usdt-impl/Cargo.toml @@ -18,9 +18,6 @@ syn = { version = "2", features = ["full", "extra-traits"] } thiserror = "1" thread-id = "4" -[build-dependencies] -version_check = "0.9.5" - [target.'cfg(target_os = "macos")'.dependencies] dof = { path = "../dof", optional = true, default-features = false, version = "=0.3.0" } @@ -28,8 +25,7 @@ dof = { path = "../dof", optional = true, default-features = false, version = "= dof = { path = "../dof", default-features = false, version = "=0.3.0" } [features] -default = ["asm"] -asm = [] +default = [] # The `des` feature enables `dof` and company to be able to deserialize special # sections emitted in the binary which describe the probes. Except on # platforms with linker integration for USDT probes (currently only MacOS), diff --git a/usdt-impl/build.rs b/usdt-impl/build.rs index 67e16249..5ace8226 100644 --- a/usdt-impl/build.rs +++ b/usdt-impl/build.rs @@ -28,57 +28,12 @@ enum Backend { fn main() { println!("cargo:rerun-if-changed=build.rs"); - // `asm` feature was stabilized in 1.59 - let have_stable_asm = version_check::is_min_version("1.59").unwrap_or(false); - // `asm_sym` feature was stabilized in 1.66 - let have_stable_asm_sym = version_check::is_min_version("1.66").unwrap_or(false); - - // Are we being built with a compiler which allows feature flags (nightly) - let is_nightly = version_check::is_feature_flaggable().unwrap_or(false); - - let feat_asm = env::var_os("CARGO_FEATURE_ASM").is_some(); - let feat_strict_asm = env::var_os("CARGO_FEATURE_STRICT_ASM").is_some(); - let backend = match env::var("CARGO_CFG_TARGET_OS").ok().as_deref() { - Some("macos") if feat_asm => { - if have_stable_asm && have_stable_asm_sym { - Backend::Linker - } else if feat_strict_asm || is_nightly { - if !have_stable_asm { - println!("cargo:rustc-cfg=usdt_need_feat_asm"); - } - if !have_stable_asm_sym { - println!("cargo:rustc-cfg=usdt_need_feat_asm_sym"); - } - Backend::Linker - } else { - Backend::NoOp - } - } - Some("illumos") | Some("solaris") if feat_asm => { - if have_stable_asm { - Backend::Standard - } else if feat_strict_asm || is_nightly { - println!("cargo:rustc-cfg=usdt_need_feat_asm"); - Backend::Standard - } else { - Backend::NoOp - } - } - _ => { - if !have_stable_asm { - println!("cargo:rustc-cfg=usdt_need_feat_asm"); - } - Backend::NoOp - } + Some("macos") => Backend::Linker, + Some("illumos") | Some("solaris") => Backend::Standard, + _ => Backend::NoOp, }; - // Since visibility of the `asm!()` macro differs between the nightly feature and the - // stabilized version, the consumer requires information about its availability - if have_stable_asm { - println!("cargo:rustc-cfg=usdt_stable_asm"); - } - match backend { Backend::NoOp => { println!("cargo:rustc-cfg=usdt_backend_noop"); diff --git a/usdt-impl/src/empty.rs b/usdt-impl/src/empty.rs index 2423fca6..9c3946df 100644 --- a/usdt-impl/src/empty.rs +++ b/usdt-impl/src/empty.rs @@ -1,6 +1,6 @@ //! The empty implementation of the USDT crate. //! -//! Used when the `asm` feature is disabled, or on platforms without DTrace. +//! Used on platforms without DTrace. // Copyright 2021 Oxide Computer Company // diff --git a/usdt-impl/src/lib.rs b/usdt-impl/src/lib.rs index 7a5decc2..0d035ae3 100644 --- a/usdt-impl/src/lib.rs +++ b/usdt-impl/src/lib.rs @@ -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 serde::Deserialize; use std::cell::RefCell; use thiserror::Error; diff --git a/usdt-impl/src/linker.rs b/usdt-impl/src/linker.rs index da75b255..668d7597 100644 --- a/usdt-impl/src/linker.rs +++ b/usdt-impl/src/linker.rs @@ -25,7 +25,6 @@ //! //! In rust, we'll want the probe site to look something like this: //! ```ignore -//! #![feature(asm, asm_sym)] //! extern "C" { //! #[link_name = "__dtrace_stability$foo$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0"] //! fn stability(); @@ -179,11 +178,6 @@ fn compile_probe( #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] compile_error!("USDT only supports x86_64 and AArch64 architectures"); - #[cfg(usdt_stable_asm)] - let asm_macro = quote! { std::arch::asm }; - #[cfg(not(usdt_stable_asm))] - let asm_macro = quote! { asm }; - let impl_block = quote! { extern "C" { #[allow(unused)] @@ -205,7 +199,7 @@ fn compile_probe( unsafe { if #is_enabled_fn() != 0 { #unpacked_args - #asm_macro!( + ::std::arch::asm!( ".reference {typedefs}", #call_instruction, ".reference {stability}", diff --git a/usdt-impl/src/no-linker.rs b/usdt-impl/src/no-linker.rs index 91d92b33..8c7a00fd 100644 --- a/usdt-impl/src/no-linker.rs +++ b/usdt-impl/src/no-linker.rs @@ -82,16 +82,12 @@ fn compile_probe( let (unpacked_args, in_regs) = common::construct_probe_args(&probe.types); let is_enabled_rec = emit_probe_record(&provider.name, &probe.name, None); let probe_rec = emit_probe_record(&provider.name, &probe.name, Some(&probe.types)); - #[cfg(usdt_stable_asm)] - let asm_macro = quote! { std::arch::asm }; - #[cfg(not(usdt_stable_asm))] - let asm_macro = quote! { asm }; let impl_block = quote! { { let mut is_enabled: u64; unsafe { - #asm_macro!( + ::std::arch::asm!( "990: clr rax", #is_enabled_rec, out("rax") is_enabled, @@ -102,7 +98,7 @@ fn compile_probe( if is_enabled != 0 { #unpacked_args unsafe { - #asm_macro!( + ::std::arch::asm!( "990: nop", #probe_rec, #in_regs diff --git a/usdt-macro/Cargo.toml b/usdt-macro/Cargo.toml index 6986e2ca..bf358e7b 100644 --- a/usdt-macro/Cargo.toml +++ b/usdt-macro/Cargo.toml @@ -14,9 +14,5 @@ syn = { version = "2", features = ["full"] } quote = "1" usdt-impl = { path = "../usdt-impl", default-features = false, version = "=0.5.0" } -[features] -default = ["asm"] -asm = ["usdt-impl/asm"] - [lib] proc-macro = true diff --git a/usdt/Cargo.toml b/usdt/Cargo.toml index b69c9e5b..04846e1f 100644 --- a/usdt/Cargo.toml +++ b/usdt/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" license = "Apache-2.0" description = "Dust your Rust with USDT probes" repository = "https://github.com/oxidecomputer/usdt.git" -rust-version = "1.63.0" +rust-version = "1.75.0" # NOTE: The use of path and version dependencies is deliberate and load-bearing. # @@ -15,7 +15,6 @@ rust-version = "1.63.0" # where the public-facing `usdt` crate may pick up different versions of the # internal implementation crates. [dependencies] -dtrace-parser = { path = "../dtrace-parser", optional = true, version = "=0.2.0" } serde = "1" usdt-impl = { path = "../usdt-impl", default-features = false, version = "=0.5.0", features = [ "des", @@ -28,9 +27,9 @@ memmap2 = { version = "0.9.4" } [features] default = ["asm"] -asm = [ - "usdt-impl/asm", - "usdt-macro/asm", - "usdt-attr-macro/asm", - "dtrace-parser", -] +# This feature used to be functional, but is now a no-op because inline `asm` is available on all +# supported versions of Rust. It's kept around for BC reasons, but whenever there's a breaking +# change to the `usdt` crate, this feature should be removed. +# +# There's also a comment about this in lib.rs -- remove it when this feature is removed. +asm = [] diff --git a/usdt/src/lib.rs b/usdt/src/lib.rs index 07c121bc..c2108397 100644 --- a/usdt/src/lib.rs +++ b/usdt/src/lib.rs @@ -275,73 +275,14 @@ //! purpose. It may be passed as any argument to a probe function, and is guaranteed to be unique //! between different invocations of the same probe. See the type's documentation for details. //! -//! Features -//! -------- +//! About the `asm` feature +//! ----------------------- +//! +//! Previous versions of `usdt` used the `asm` feature to enable inline assembly which used to +//! require nightly Rust with old versions of Rust. Currently, all supported versions of Rust +//! support inline assembly, and the `asm` feature is a no-op. //! -//! > **Note**: This section is only relevant prior to Rust 1.59 (or Rust 1.66 on macOS). -//! -//! The USDT crate relies on inline assembly to hook into DTrace. Prior to Rust 1.59, this is -//! unstable, and requires explicitly opting in with `#![feature(asm))]`. -//! -//! On macOS (only) an additional feature (`asm_sym`) is required prior to Rust 1.66 (but after Rust -//! 1.58.0-nightly). The macOS implementation relies on native linker support; it uses the `sym` -//! syntax of the `asm!` macro which was split into its own feature in Rust 1.58.0-nightly -//! (2021-10-29). -//! -//! Unfortunately, because of the way the features were added (see [this pull -//! request][asm-sym-feature-pr]), this version of Rust nightly is a Rubicon: the `usdt` crate, and -//! crates using it, _cannot be built with compilers both before and after this version._ -//! Specifically, it's not possible to write the set of features that would allow code to be -//! compiled with a nightly toolchain before and after this version. If we _include_ the -//! `feature(asm_sym)` directive with a toolchain of 1.57 or earlier, the compiler will generate an -//! error because that feature isn't known for those versions. If we _omit_ the directive, it will -//! compile with previous toolchains, but a newer one will generate an error because the feature is -//! required for opting into the functionality used in the `usdt` crate's implementation on macOS. -//! -//! There's no great solution here. If you're developing an application, i.e., something that you're -//! sure can be built with a specific toolchain such as with a `rust-toolchain` file, you can write -//! the correct feature attribute for that toolchain version. -//! -//! If you're building a library, things are more complicated, because you don't know what toolchain -//! a consuming application will choose to use. It's not possible to use a `build.rs` file or other -//! code-generation mechanism, because inner attributes must generally be written directly at the -//! top of the crate's root source file. A mechanism that _expands_ to the right tokens is not -//! sufficient. The only real approach is to specify which versions of the toolchain are supported -//! by your library in the documentation, as we've done here. -//! -//! Selecting the no-op implementation -//! ---------------------------------- -//! -//! It's possible to use the `usdt` crate in libraries without transitively requiring a nightly -//! compiler of one's users (prior to Rust 1.66). Though `asm` is a default feature of the `usdt` -//! crate, users can opt to build with `--no-default-features`, which uses a no-op implementation of -//! the internals. This generates the same probe macros, but with empty bodies, meaning the code can -//! be compiled unchanged. -//! -//! Library developers may choose to re-export this feature, with a name such as `probes`, which -//! implies the `asm` feature of the `usdt` crate. This feature-gating allows users to select a -//! nightly compiler in exchange for probes, but still allows the code to be compiled with a stable -//! toolchain. -//! -//! Note that prior to Rust 1.66, the appropriate features are required anywhere the generated -//! macros are _called_, rather than where they're defined. (Because they're macros-by-example, and -//! expand to an actual `asm!` macro call.) So library writers should probably gate the feature -//! directive on their own re-exported feature, e.g., `#![cfg_attr(feature = "probes", -//! feature(asm))]`, and instruct developers consuming their libraries to do the same. -//! -//! It's important to keep in mind how Cargo unifies features, however. Specifically, if `usdt` is -//! a dependency of two other dependencies in a package, it's possible to end up in a confusing -//! situation. Cargo takes the _union_ of all features in such a case. Thus if one crate is built -//! expecting to use the no-op implementation and another is built _using_ the real, `asm`-based -//! implementation, the latter will be chosen. This can be confusing or downright dangerous. First, -//! the former crate will fail at compile time, because the `asm!` macro will actually be emitted, -//! but the `#![feature(asm)]` flag will not be included. More troubling, the probes will actually -//! exist in the resulting object file, even if the user specifically opted to not use them. -//! -//! To handle this, library writers may place _all_ references to `usdt`-related code behind a -//! conditional compilation directive. This will ensure that the crate is not even used, rather -//! than it being used with an unexpected implementation. This is most relevant for crates whose -//! minimum supported Rust version is earlier than 1.66. +//! The next breaking change to `usdt` will remove the `asm` feature entirely. //! //! [dtrace]: https://illumos.org/books/dtrace/preface.html#preface //! [dtrace-usdt]: https://illumos.org/books/dtrace/chp-usdt.html#chp-usdt @@ -350,7 +291,6 @@ //! [probe_test_build]: https://github.com/oxidecomputer/usdt/tree/master/probe-test-build //! [probe_test_attr]: https://github.com/oxidecomputer/usdt/tree/master/probe-test-attr //! [serde]: https://serde.rs -//! [asm-sym-feature-pr]: https://github.com/rust-lang/rust/pull/90348 use dof::{extract_dof_sections, Section}; use goblin::Object;