Skip to content

Commit

Permalink
Allow use of usdt probes with stable rust
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmooney committed Apr 7, 2022
1 parent f0399ff commit c9e009e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
28 changes: 28 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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.
}
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
9 changes: 5 additions & 4 deletions tests/test-slog-dtrace.rs
Original file line number Diff line number Diff line change
@@ -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() {}

Expand Down

0 comments on commit c9e009e

Please sign in to comment.