From 74832bdc47d56bc37657ced23dc687c1464be985 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 19 May 2024 13:02:55 +0000 Subject: [PATCH] fix smoke from builds produced by --all-features Signed-off-by: Jason Volk --- Cargo.toml | 11 ++++++++++- src/core/Cargo.toml | 5 ----- src/core/debug.rs | 1 - src/core/mod.rs | 4 ++-- src/core/mods/mod.rs | 2 +- src/main/Cargo.toml | 2 -- src/main/main.rs | 4 ++-- src/main/mods.rs | 6 ++---- src/main/server.rs | 8 ++++---- 9 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 798cd0f2..4dc05d71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -526,7 +526,6 @@ inherits = "release" # To enable hot-reloading: # 1. Uncomment all of the rustflags here. # 2. Uncomment crate-type=dylib in src/*/Cargo.toml and deps/rust-rocksdb/Cargo.toml -# 2. Build with the 'mods' feature. # # opt-level, mir-opt-level, validate-mir are not known to interfere with reloading # and can be raised if build times are tolerable. @@ -540,6 +539,7 @@ incremental = true codegen-units = 64 rpath = true #rustflags = [ +# '--cfg', 'conduit_mods', # '-Ztime-passes', # '-Zmir-opt-level=0', # '-Zvalidate-mir=false', @@ -560,6 +560,7 @@ rpath = true inherits = "dev" incremental = false #rustflags = [ +# '--cfg', 'conduit_mods', # '-Ztime-passes', # '-Zmir-opt-level=0', # '-Ztls-model=initial-exec', @@ -580,6 +581,7 @@ incremental = false inherits = "dev" incremental = false #rustflags = [ +# '--cfg', 'conduit_mods', # '-Ztime-passes', # '-Zmir-opt-level=0', # '-Zvalidate-mir=false', @@ -601,6 +603,7 @@ incremental = false codegen-units = 1 opt-level = 'z' #rustflags = [ +# '--cfg', 'conduit_mods', # '-Ztls-model=initial-exec', # '-Cprefer-dynamic=true', # '-Zstaticlib-prefer-dynamic=true', @@ -621,6 +624,7 @@ incremental = false codegen-units = 1 opt-level = 'z' #rustflags = [ +# '--cfg', 'conduit_mods', # '-Ztls-model=global-dynamic', # '-Cprefer-dynamic=true', # '-Zstaticlib-prefer-dynamic=true', @@ -655,6 +659,11 @@ unreachable_pub = "warn" # this seems to suggest broken code and is not working correctly unused_braces = "allow" +# cfgs cannot be limited to features or cargo build --all-features panics for unsuspecting users. +# cfgs cannot be limited to expected cfgs or their de facto non-transitive/opt-in use-case e.g. +# tokio_unstable will warn. +unexpected_cfgs = "allow" + # some sadness missing_docs = "allow" diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index 89ec7248..6b700f1f 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -63,10 +63,6 @@ brotli_compression = [ ] perf_measurements = [] sentry_telemetry = [] -mods = [ - "dep:libloading" -] -panic_trap = [] [dependencies] async-trait.workspace = true @@ -86,7 +82,6 @@ infer.workspace = true ipaddress.workspace = true itertools.workspace = true libloading.workspace = true -libloading.optional = true log.workspace = true lru-cache.workspace = true parking_lot.optional = true diff --git a/src/core/debug.rs b/src/core/debug.rs index fa998265..6db9a4dd 100644 --- a/src/core/debug.rs +++ b/src/core/debug.rs @@ -62,7 +62,6 @@ fn panic_handler(info: &PanicInfo<'_>, next: &dyn Fn(&PanicInfo<'_>)) { } #[inline(always)] -#[allow(unexpected_cfgs)] pub fn trap() { #[cfg(core_intrinsics)] //SAFETY: embeds llvm intrinsic for hardware breakpoint diff --git a/src/core/mod.rs b/src/core/mod.rs index 8e0a481b..5911e027 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -14,8 +14,8 @@ pub use pducount::PduCount; pub use server::Server; pub use utils::conduwuit_version; -#[cfg(not(feature = "mods"))] -mod mods { +#[cfg(not(conduit_mods))] +pub mod mods { #[macro_export] macro_rules! mod_ctor { () => {}; diff --git a/src/core/mods/mod.rs b/src/core/mods/mod.rs index e60a0f5e..118bfc29 100644 --- a/src/core/mods/mod.rs +++ b/src/core/mods/mod.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "mods")] +#![cfg(conduit_mods)] pub(crate) use libloading::os::unix::{Library, Symbol}; diff --git a/src/main/Cargo.toml b/src/main/Cargo.toml index 282f6aac..a866b466 100644 --- a/src/main/Cargo.toml +++ b/src/main/Cargo.toml @@ -67,8 +67,6 @@ perf_measurements = [ jemalloc = [ "dep:tikv-jemallocator", ] -panic_trap = [] -mods = [] [dependencies] conduit-router.workspace = true diff --git a/src/main/main.rs b/src/main/main.rs index 0d049fcb..0f841563 100644 --- a/src/main/main.rs +++ b/src/main/main.rs @@ -37,7 +37,7 @@ fn main() -> Result<(), Error> { /// Operate the server normally in release-mode static builds. This will start, /// run and stop the server within the asynchronous runtime. -#[cfg(not(feature = "mods"))] +#[cfg(not(conduit_mods))] async fn async_main(server: Arc) -> Result<(), Error> { extern crate conduit_router as router; use tracing::error; @@ -64,7 +64,7 @@ async fn async_main(server: Arc) -> Result<(), Error> { /// Operate the server in developer-mode dynamic builds. This will start, run, /// and hot-reload portions of the server as-needed before returning for an /// actual shutdown. This is not available in release-mode or static builds. -#[cfg(feature = "mods")] +#[cfg(conduit_mods)] async fn async_main(server: Arc) -> Result<(), Error> { let mut starts = true; let mut reloads = true; diff --git a/src/main/mods.rs b/src/main/mods.rs index 404fa467..90a25f97 100644 --- a/src/main/mods.rs +++ b/src/main/mods.rs @@ -1,6 +1,4 @@ -#![cfg(feature = "mods")] -#[cfg(not(any(clippy, debug_assertions, doctest, test)))] -compile_error!("Feature 'mods' is only available in developer builds"); +#![cfg(conduit_mods)] use std::{ future::Future, @@ -26,7 +24,7 @@ const MODULE_NAMES: &[&str] = &[ "conduit_router", ]; -#[cfg(feature = "panic_trap")] +#[cfg(panic_trap)] conduit::mod_init! {{ conduit::debug::set_panic_trap(); }} diff --git a/src/main/server.rs b/src/main/server.rs index e63c0dc0..8b68d1c4 100644 --- a/src/main/server.rs +++ b/src/main/server.rs @@ -21,8 +21,8 @@ pub(crate) struct Server { #[cfg(feature = "sentry_telemetry")] _sentry_guard: Option, + #[cfg(conduit_mods)] // Module instances; TODO: move to mods::loaded mgmt vector - #[cfg(feature = "mods")] pub(crate) mods: tokio::sync::RwLock>, } @@ -52,7 +52,7 @@ impl Server { #[cfg(feature = "sentry_telemetry")] _sentry_guard: sentry_guard, - #[cfg(feature = "mods")] + #[cfg(conduit_mods)] mods: tokio::sync::RwLock::new(Vec::new()), })) } @@ -109,7 +109,7 @@ fn init_tracing(config: &Config) -> (LogLevelReloadHandles, TracingFlameGuard) { let mut reload_handles = Vec:: + Send + Sync>>::new(); let subscriber = registry; - #[cfg(feature = "tokio_console")] + #[cfg(all(feature = "tokio_console", tokio_unstable))] let subscriber = { let console_layer = console_subscriber::spawn(); subscriber.with(console_layer) @@ -176,7 +176,7 @@ fn init_tracing(config: &Config) -> (LogLevelReloadHandles, TracingFlameGuard) { tracing::subscriber::set_global_default(subscriber).unwrap(); - #[cfg(all(feature = "tokio_console", feature = "release_max_log_level"))] + #[cfg(all(feature = "tokio_console", feature = "release_max_log_level", tokio_unstable))] tracing::error!( "'tokio_console' feature and 'release_max_log_level' feature are incompatible, because console-subscriber \ needs access to trace-level events. 'release_max_log_level' must be disabled to use tokio-console."