Skip to content

Commit 1c1e1f1

Browse files
authored
Better detection of features for USDT (#295)
1 parent d1bf765 commit 1c1e1f1

File tree

7 files changed

+43
-8
lines changed

7 files changed

+43
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ tracing-bunyan-formatter = "0.3.3"
123123
tracing-subscriber = "0.3.14"
124124
usdt = "0.3.2"
125125
uuid = "1.0.0"
126+
version_check = "0.9"
126127
viona_api = { path = "crates/viona-api" }
127128
vte = "0.10.1"
128129

bin/propolis-server/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ slog = { workspace = true, features = [ "max_level_trace", "release_max_level_de
6060
expectorate.workspace = true
6161
mockall.workspace = true
6262

63+
[build-dependencies]
64+
version_check.workspace = true
65+
6366
[features]
6467
default = ["dtrace-probes"]
6568
dtrace-probes = ["propolis/dtrace-probes", "dropshot/usdt-probes"]

bin/propolis-server/build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2023 Oxide Computer Company
2+
3+
fn main() {
4+
println!("cargo:rerun-if-changed=build.rs");
5+
6+
if !version_check::is_min_version("1.59").unwrap_or(false) {
7+
println!("cargo:rustc-cfg=usdt_need_asm");
8+
}
9+
10+
#[cfg(target_os = "macos")]
11+
if version_check::supports_feature("asm_sym").unwrap_or(false)
12+
&& !version_check::is_min_version("1.67").unwrap_or(false)
13+
{
14+
println!("cargo:rustc-cfg=usdt_need_asm_sym");
15+
}
16+
}

bin/propolis-server/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Required for USDT
2-
#![cfg_attr(
3-
all(feature = "dtrace-probes", target_os = "macos"),
4-
feature(asm_sym)
5-
)]
2+
#![cfg_attr(usdt_need_asm, feature(asm))]
3+
#![cfg_attr(all(target_os = "macos", usdt_need_asm_sym), feature(asm_sym))]
64

75
use anyhow::anyhow;
86
use clap::Parser;

lib/propolis/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ slog-term.workspace = true
5151
slog-async.workspace = true
5252
rand.workspace = true
5353

54+
[build-dependencies]
55+
version_check.workspace = true
56+
5457
[features]
5558
default = ["dtrace-probes"]
5659
dtrace-probes = ["usdt/asm"]

lib/propolis/build.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2023 Oxide Computer Company
2+
3+
fn main() {
4+
println!("cargo:rerun-if-changed=build.rs");
5+
6+
if !version_check::is_min_version("1.59").unwrap_or(false) {
7+
println!("cargo:rustc-cfg=usdt_need_asm");
8+
}
9+
10+
#[cfg(target_os = "macos")]
11+
if version_check::supports_feature("asm_sym").unwrap_or(false)
12+
&& !version_check::is_min_version("1.67").unwrap_or(false)
13+
{
14+
println!("cargo:rustc-cfg=usdt_need_asm_sym");
15+
}
16+
}

lib/propolis/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#![allow(clippy::style)]
22
#![allow(clippy::drop_non_drop)]
3-
#![cfg_attr(
4-
all(feature = "dtrace-probes", target_os = "macos"),
5-
feature(asm_sym)
6-
)]
3+
#![cfg_attr(usdt_need_asm, feature(asm))]
4+
#![cfg_attr(all(target_os = "macos", usdt_need_asm_sym), feature(asm_sym))]
75

86
pub extern crate bhyve_api;
97
pub extern crate usdt;

0 commit comments

Comments
 (0)