blob: d0693efd81c6e1758ff0701114a43f2332e5ca67 [file] [log] [blame]
From 91eed6a7cfe8fa56777cccda65527d4a9ea25801 Mon Sep 17 00:00:00 2001
From: Marcin Radomski <marcin@mradomski.pl>
Date: Fri, 15 Mar 2024 23:08:44 +0100
Subject: [PATCH 1/3] Make linux-raw-sys dependency optional
See b/331344966 for status of the efforts to upstream this.
Replace minimal set of cfg(linux_kernel) with
cfg(feature = "linux-raw-sys") to keep the build working.
With this, quite a few features just work:
cargo build --no-default-features --features \
use-libc,use-libc-auxv,std,event,mount,time,pipe,rand,stdio
---
Cargo.toml | 4 ++--
Cargo.toml.orig | 5 +++--
src/backend/libc/io/syscalls.rs | 6 +++---
src/backend/libc/io/types.rs | 2 +-
src/io/read_write.rs | 6 +++---
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 8184720b..8f091a9a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -213,6 +213,7 @@ features = [
"no_std",
]
default-features = false
+optional = true
[target."cfg(all(criterion, not(any(target_os = \"emscripten\", target_os = \"wasi\"))))".dev-dependencies.criterion]
version = "0.4"
@@ -239,6 +240,7 @@ features = [
"elf",
]
default-features = false
+optional = true
[target."cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\")))))))".dependencies.libc]
version = "0.2.152"
diff --git a/src/backend/libc/io/types.rs b/src/backend/libc/io/types.rs
index 510206f9..a86dc261 100644
--- a/src/backend/libc/io/types.rs
+++ b/src/backend/libc/io/types.rs
@@ -17,7 +17,7 @@ bitflags! {
}
}
-#[cfg(linux_kernel)]
+#[cfg(feature = "linux-raw-sys")]
bitflags! {
/// `RWF_*` constants for use with [`preadv2`] and [`pwritev2`].
///
diff --git a/src/io/read_write.rs b/src/io/read_write.rs
index 2ed9dd71..d5296fa4 100644
--- a/src/io/read_write.rs
+++ b/src/io/read_write.rs
@@ -11,7 +11,7 @@ use core::mem::MaybeUninit;
#[cfg(not(windows))]
pub use crate::maybe_polyfill::io::{IoSlice, IoSliceMut};
-#[cfg(linux_kernel)]
+#[cfg(feature = "linux-raw-sys")]
pub use backend::io::types::ReadWriteFlags;
/// `read(fd, buf)`—Reads from a stream.
@@ -281,7 +281,7 @@ pub fn pwritev<Fd: AsFd>(fd: Fd, bufs: &[IoSlice<'_>], offset: u64) -> io::Resul
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/preadv2.2.html
-#[cfg(linux_kernel)]
+#[cfg(feature = "linux-raw-sys")]
#[inline]
pub fn preadv2<Fd: AsFd>(
fd: Fd,
@@ -300,7 +300,7 @@ pub fn preadv2<Fd: AsFd>(
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/pwritev2.2.html
-#[cfg(linux_kernel)]
+#[cfg(feature = "linux-raw-sys")]
#[inline]
pub fn pwritev2<Fd: AsFd>(
fd: Fd,
--
2.44.0.291.gc1ea87d7ee-goog