dual malloc feature check

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-04-10 20:30:40 -04:00 committed by June
parent f6e9c106aa
commit 10219a531b
2 changed files with 23 additions and 4 deletions

View file

@ -9,6 +9,13 @@ pub fn check(config: &Config) -> Result<(), Error> {
config.warn_deprecated();
config.warn_unknown_key();
if cfg!(feature = "hardened_malloc") && cfg!(feature = "jemalloc") {
warn!(
"hardened_malloc and jemalloc were built together, this causes neither to be used. Conduwuit will still \
function, but consider rebuilding and pick one as this is now no-op."
);
}
if config.unix_socket_path.is_some() && !cfg!(unix) {
return Err(Error::bad_config(
"UNIX socket support is only available on *nix platforms. Please remove \"unix_socket_path\" from your \

View file

@ -24,7 +24,7 @@ use ruma::api::client::{
error::{Error as RumaError, ErrorBody, ErrorKind},
uiaa::UiaaResponse,
};
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc", not(feature = "hardened_malloc")))]
use tikv_jemallocator::Jemalloc;
use tokio::{
signal,
@ -42,14 +42,26 @@ use tracing_subscriber::{prelude::*, reload, EnvFilter, Registry};
mod routes;
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc", not(feature = "hardened_malloc")))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
#[cfg(all(not(target_env = "msvc"), not(target_os = "macos"), feature = "hardened_malloc", target_os = "linux"))]
#[cfg(all(
not(target_env = "msvc"),
not(target_os = "macos"),
not(feature = "jemalloc"),
feature = "hardened_malloc",
target_os = "linux"
))]
use hardened_malloc_rs::HardenedMalloc;
#[cfg(all(not(target_env = "msvc"), not(target_os = "macos"), feature = "hardened_malloc", target_os = "linux"))]
#[cfg(all(
not(target_env = "msvc"),
not(target_os = "macos"),
feature = "hardened_malloc",
target_os = "linux",
not(feature = "jemalloc")
))]
#[global_allocator]
static GLOBAL: HardenedMalloc = HardenedMalloc;