diff --git a/Cargo.toml b/Cargo.toml index d69659e..8adf46c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,9 +12,12 @@ serde = "1" serde_json = "1" slog = "2" chrono = { version = "0.4", features = [ "serde" ] } -usdt = "0.2" +usdt = "0.3.2" [dev-dependencies] slog-async = "2" slog-term = "2" subprocess = "0.2" + +[build-dependencies] +version_check = "0.9.4" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..41e7da6 --- /dev/null +++ b/build.rs @@ -0,0 +1,28 @@ +// 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. +// +use version_check; + +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_stable_asm"); + } + + // Once asm_sym is stablilized, add an additional check so that those + // building on macos can use the stable toolchain with any hassle. + // + // A matching rust-cfg option named `usdt_stable_asm_sym` seems appropriate. +} diff --git a/src/lib.rs b/src/lib.rs index be2485f..0415f43 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,22 +53,22 @@ //! //! This crate inherits a reliance on a nightly toolchain from the `usdt` crate. -// Copyright 2021 Oxide Computer Company -// +// 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. -#![feature(asm)] -#![cfg_attr(target_os = "macos", feature(asm_sym))] +#![cfg_attr(not(usdt_stable_asm), feature(asm))] +#![cfg_attr(all(target_os = "macos", not(usdt_stable_asm_sym)), feature(asm_sym))] use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; diff --git a/tests/test-slog-dtrace.rs b/tests/test-slog-dtrace.rs index 20d9f27..6f131a0 100644 --- a/tests/test-slog-dtrace.rs +++ b/tests/test-slog-dtrace.rs @@ -1,20 +1,21 @@ //! Integration test for the `slog-dtrace` crate. // Copyright 2021 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. -#![feature(asm)] +#![cfg_attr(not(usdt_stable_asm), feature(asm))] +#![cfg_attr(all(target_os = "macos", not(usdt_stable_asm_sym)), feature(asm_sym))] fn main() {}