Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Commit 5441b78

Browse files
acfoltzertyler
authored andcommitted
Enable the uffd feature by default, but filter on OS
Notably, this should get us building and running uffd in Linux CI. It turns out to be a tremendous pain to enable a feature flag for just one crate within a workspace. The situation is [being addressed][1], but in the meantime I believe the best route forward is to just have uffd on by default for Linux. [1]: rust-lang/cargo#5364
1 parent a6da170 commit 5441b78

File tree

13 files changed

+24
-16
lines changed

13 files changed

+24
-16
lines changed

lucet-runtime/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ assets = [
4949
]
5050

5151
[features]
52-
default-features = []
52+
default = ["uffd"]
5353
uffd = ["lucet-runtime-internals/uffd"]
5454
concurrent_testpoints = []
5555

lucet-runtime/lucet-runtime-internals/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ rand = "0.7"
2828
raw-cpuid = "6.0.0"
2929
thiserror = "1.0.4"
3030
tracing = "0.1.12"
31+
32+
[target.'cfg(target_os = "linux")'.dependencies]
3133
userfaultfd = { version = "0.1.0", optional = true }
3234

3335
[dev-dependencies]
@@ -37,8 +39,7 @@ byteorder = "1.2"
3739
cc = "1.0"
3840

3941
[features]
40-
default-features = []
41-
42+
default = ["uffd"]
4243
uffd = ["userfaultfd"]
4344
concurrent_testpoints = []
4445

lucet-runtime/lucet-runtime-internals/src/region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub mod mmap;
22

3-
#[cfg(feature = "uffd")]
3+
#[cfg(all(target_os = "linux", feature = "uffd"))]
44
pub mod uffd;
55

66
use crate::alloc::{Alloc, AllocStrategy, Limits, Slot};

lucet-runtime/src/c_api.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(feature = "uffd")]
1+
#[cfg(all(target_os = "linux", feature = "uffd"))]
22
use crate::UffdRegion;
33
use crate::{DlModule, Instance, Limits, MmapRegion, Module, Region};
44
use libc::{c_char, c_int, c_void};
@@ -105,7 +105,7 @@ pub unsafe extern "C" fn lucet_uffd_region_create(
105105
region_out: *mut *mut lucet_region,
106106
) -> lucet_error {
107107
cfg_if::cfg_if! {
108-
if #[cfg(feature = "uffd")] {
108+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
109109
assert_nonnull!(region_out);
110110
let limits = limits
111111
.as_ref()

lucet-runtime/src/lib.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,14 @@
386386
//! `Instance`, reducing startup time. Instance stack pages can also be lazily initialized, reducing
387387
//! the memory footprint of instances that only use a small portion of their available stack space.
388388
//!
389-
//! To use `UffdRegion`, enable the `uffd` Cargo feature, which is off by default.
389+
//! `UffdRegion` is enabled by default on Linux platforms, but can be disabled by disabling default
390+
//! features for this crate and `lucet-runtime-internals`:
391+
//!
392+
//! ```toml
393+
//! [dependencies]
394+
//! lucet-runtime = { version = "0.6.1", default-features = false }
395+
//! lucet-runtime-internals = { version = "0.6.1", default-features = false }
396+
//! ```
390397
391398
#![deny(bare_trait_objects)]
392399

@@ -410,7 +417,7 @@ pub use lucet_runtime_internals::instance::{
410417
pub use lucet_runtime_internals::lucet_hostcalls;
411418
pub use lucet_runtime_internals::module::{DlModule, Module};
412419
pub use lucet_runtime_internals::region::mmap::MmapRegion;
413-
#[cfg(feature = "uffd")]
420+
#[cfg(all(target_os = "linux", feature = "uffd"))]
414421
pub use lucet_runtime_internals::region::uffd::UffdRegion;
415422
pub use lucet_runtime_internals::region::{InstanceBuilder, Region, RegionCreate};
416423
pub use lucet_runtime_internals::val::{UntypedRetVal, Val};

lucet-runtime/tests/entrypoint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lucet_runtime_tests::entrypoint_tests;
22

33
cfg_if::cfg_if! {
4-
if #[cfg(feature = "uffd")] {
4+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
55
entrypoint_tests!(
66
mmap => lucet_runtime::MmapRegion,
77
uffd => lucet_runtime::UffdRegion

lucet-runtime/tests/globals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lucet_runtime_tests::globals_tests;
22

33
cfg_if::cfg_if! {
4-
if #[cfg(feature = "uffd")] {
4+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
55
globals_tests!(
66
mmap => lucet_runtime::MmapRegion,
77
uffd => lucet_runtime::UffdRegion

lucet-runtime/tests/guest_fault.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use lucet_runtime_tests::{guest_fault_common_defs, guest_fault_tests};
33
guest_fault_common_defs!();
44

55
cfg_if::cfg_if! {
6-
if #[cfg(feature = "uffd")] {
6+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
77
guest_fault_tests!(
88
mmap => lucet_runtime::MmapRegion,
99
uffd => lucet_runtime::UffdRegion

lucet-runtime/tests/host.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lucet_runtime_tests::host_tests;
22

33
cfg_if::cfg_if! {
4-
if #[cfg(feature = "uffd")] {
4+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
55
host_tests!(
66
mmap => lucet_runtime::MmapRegion,
77
uffd => lucet_runtime::UffdRegion

lucet-runtime/tests/memory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lucet_runtime_tests::memory_tests;
22

33
cfg_if::cfg_if! {
4-
if #[cfg(feature = "uffd")] {
4+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
55
memory_tests!(
66
mmap => lucet_runtime::MmapRegion,
77
uffd => lucet_runtime::UffdRegion

lucet-runtime/tests/stack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lucet_runtime_tests::stack_tests;
22

33
cfg_if::cfg_if! {
4-
if #[cfg(feature = "uffd")] {
4+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
55
stack_tests!(
66
mmap => lucet_runtime::MmapRegion,
77
uffd => lucet_runtime::UffdRegion

lucet-runtime/tests/start.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lucet_runtime_tests::start_tests;
22

33
cfg_if::cfg_if! {
4-
if #[cfg(feature = "uffd")] {
4+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
55
start_tests!(
66
mmap => lucet_runtime::MmapRegion,
77
uffd => lucet_runtime::UffdRegion

lucet-runtime/tests/strcmp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lucet_runtime_tests::strcmp_tests;
22

33
cfg_if::cfg_if! {
4-
if #[cfg(feature = "uffd")] {
4+
if #[cfg(all(target_os = "linux", feature = "uffd"))] {
55
strcmp_tests!(
66
mmap => lucet_runtime::MmapRegion,
77
uffd => lucet_runtime::UffdRegion

0 commit comments

Comments
 (0)