Make build-config magic use memfd by default.
This commit is contained in:
@@ -703,7 +703,7 @@ impl MemoryPool {
|
||||
let mapping = Mmap::accessible_reserved(0, allocation_size)
|
||||
.context("failed to create memory pool mapping")?;
|
||||
|
||||
let num_memfd_slots = if cfg!(feature = "memfd-allocator") {
|
||||
let num_memfd_slots = if cfg!(memfd) {
|
||||
max_instances * max_memories
|
||||
} else {
|
||||
0
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
clippy::use_self
|
||||
)
|
||||
)]
|
||||
#![cfg_attr(feature = "memfd-allocator", allow(dead_code))]
|
||||
#![cfg_attr(memfd, allow(dead_code))]
|
||||
|
||||
use std::sync::atomic::AtomicU64;
|
||||
|
||||
@@ -67,14 +67,14 @@ pub use crate::vmcontext::{
|
||||
mod module_id;
|
||||
pub use module_id::{CompiledModuleId, CompiledModuleIdAllocator};
|
||||
|
||||
#[cfg(feature = "memfd-allocator")]
|
||||
#[cfg(memfd)]
|
||||
mod memfd;
|
||||
#[cfg(feature = "memfd-allocator")]
|
||||
#[cfg(memfd)]
|
||||
pub use crate::memfd::{MemFdSlot, MemoryMemFd, ModuleMemFds};
|
||||
|
||||
#[cfg(not(feature = "memfd-allocator"))]
|
||||
#[cfg(not(memfd))]
|
||||
mod memfd_disabled;
|
||||
#[cfg(not(feature = "memfd-allocator"))]
|
||||
#[cfg(not(memfd))]
|
||||
pub use crate::memfd_disabled::{MemFdSlot, MemoryMemFd, ModuleMemFds};
|
||||
|
||||
/// Version number of this crate.
|
||||
|
||||
@@ -37,11 +37,9 @@ impl ModuleMemFds {
|
||||
/// To allow MemFdSlot to be unconditionally passed around in various
|
||||
/// places (e.g. a `Memory`), we define a zero-sized type when memfd is
|
||||
/// not included in the build.
|
||||
#[cfg(not(feature = "memfd-allocator"))]
|
||||
#[derive(Debug)]
|
||||
pub struct MemFdSlot;
|
||||
|
||||
#[cfg(not(feature = "memfd-allocator"))]
|
||||
#[allow(dead_code)]
|
||||
impl MemFdSlot {
|
||||
pub(crate) fn create(_: *mut libc::c_void, _: usize) -> Self {
|
||||
|
||||
@@ -54,14 +54,7 @@ pub unsafe fn platform_init() {
|
||||
// Sometimes we need to handle SIGBUS too:
|
||||
// - On ARM, handle Unaligned Accesses.
|
||||
// - On Darwin, guard page accesses are raised as SIGBUS.
|
||||
// - With the MemFD allocator, heap growth is controlled by
|
||||
// ftruncate'ing an mmap'd file, and so out-of-bounds accesses
|
||||
// are raised as SIGBUS.
|
||||
if cfg!(target_arch = "arm")
|
||||
|| cfg!(target_os = "macos")
|
||||
|| cfg!(target_os = "freebsd")
|
||||
|| cfg!(feature = "memfd-allocator")
|
||||
{
|
||||
if cfg!(target_arch = "arm") || cfg!(target_os = "macos") || cfg!(target_os = "freebsd") {
|
||||
register(&mut PREV_SIGBUS, libc::SIGBUS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user