Skip to content

Commit 287509b

Browse files
authored
Fix compilation on macOS and FreeBSD with --no-default-features. (bytecodealliance#966)
1 parent 748a828 commit 287509b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/backend/libc/fs/syscalls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::backend::conv::ret_usize;
1010
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd};
1111
use crate::fd::{BorrowedFd, OwnedFd};
1212
use crate::ffi::CStr;
13-
#[cfg(apple)]
13+
#[cfg(all(apple, feature = "alloc"))]
1414
use crate::ffi::CString;
1515
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
1616
use crate::fs::Access;
@@ -73,7 +73,7 @@ use crate::io;
7373
use crate::timespec::LibcTimespec;
7474
#[cfg(not(target_os = "wasi"))]
7575
use crate::ugid::{Gid, Uid};
76-
#[cfg(apple)]
76+
#[cfg(all(apple, feature = "alloc"))]
7777
use alloc::vec;
7878
use core::mem::MaybeUninit;
7979
#[cfg(apple)]
@@ -2061,7 +2061,7 @@ pub(crate) unsafe fn copyfile_state_get(
20612061
nonnegative_ret(copyfile_state_get(state, flag, dst))
20622062
}
20632063

2064-
#[cfg(apple)]
2064+
#[cfg(all(apple, feature = "alloc"))]
20652065
pub(crate) fn getpath(fd: BorrowedFd<'_>) -> io::Result<CString> {
20662066
// The use of `PATH_MAX` is generally not encouraged, but it
20672067
// is inevitable in this case because macOS defines `fcntl` with

src/fs/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mod fcntl_apple;
2828
#[cfg(apple)]
2929
mod fcopyfile;
3030
pub(crate) mod fd;
31-
#[cfg(apple)]
31+
#[cfg(all(apple, feature = "alloc"))]
3232
mod getpath;
3333
#[cfg(not(target_os = "wasi"))] // WASI doesn't have get[gpu]id.
3434
mod id;
@@ -96,7 +96,7 @@ pub use fcntl_apple::*;
9696
#[cfg(apple)]
9797
pub use fcopyfile::*;
9898
pub use fd::*;
99-
#[cfg(apple)]
99+
#[cfg(all(apple, feature = "alloc"))]
100100
pub use getpath::getpath;
101101
#[cfg(not(target_os = "wasi"))]
102102
pub use id::*;

src/process/procctl.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
66
#![allow(unsafe_code)]
77

8-
use alloc::vec;
9-
use alloc::vec::Vec;
8+
#[cfg(feature = "alloc")]
9+
use alloc::{vec, vec::Vec};
1010
use core::mem::MaybeUninit;
1111
use core::ptr;
1212

@@ -342,6 +342,7 @@ pub struct PidInfo {
342342
/// - [FreeBSD: `procctl(PROC_REAP_GETPIDS,...)`]
343343
///
344344
/// [FreeBSD: `procctl(PROC_REAP_GETPIDS,...)`]: https://man.freebsd.org/cgi/man.cgi?query=procctl&sektion=2
345+
#[cfg(feature = "alloc")]
345346
pub fn get_reaper_pids(process: ProcSelector) -> io::Result<Vec<PidInfo>> {
346347
// Sadly no better way to guarantee that we get all the results than to
347348
// allocate ~8MB of memory..

0 commit comments

Comments
 (0)