From 80d0eaeb211d078b8935ea1f18bddd90faceeaae Mon Sep 17 00:00:00 2001 From: vasilito Date: Thu, 2 Jul 2026 08:25:51 +0300 Subject: [PATCH] libredox: make redox_syscall non-optional, fix O_CLOEXEC dup Three fixes for cross-recipe build: 1. O_CLOEXEC was already imported from libc at line 114, but the 0.1.18 backport added a duplicate 'pub const O_CLOEXEC' at line 173. E0255 ("name defined multiple times") error. Keep only the new F_DUPFD_CLOEXEC constant; O_CLOEXEC comes from libc. 2. pub mod acpi that re-exports AcPiVerb from redox_syscall is now correctly gated on '#[cfg(feature = "redox_syscall")]'. The 'redox_syscall' dep is currently optional in libredox's Cargo.toml, so recipes that don't enable the feature (e.g. base-initfs which uses default-features libredox) get an unresolved-import error. Move to making the dep non-optional so it's always available. 3. Make redox_syscall dep non-optional in Cargo.toml. This is safe because (a) the path override always points at the local fork which is always present, and (b) all downstream consumers of libredox already depend on redox_syscall transitively (or are the syscall consumers themselves, like the kernel). After these three changes, the libredox fork builds cleanly and the 'pub mod acpi { pub use redox_syscall::AcPiVerb; }' re-export is available to all consumers without feature flags. --- Cargo.toml.orig | 16 +++++++++------- src/lib.rs | 8 +++++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Cargo.toml.orig b/Cargo.toml.orig index c1d0e231cc..72d40e2b59 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,12 +1,14 @@ [package] name = "libredox" authors = ["4lDO2 <4lDO2@protonmail.com>"] -# Red Bear OS Phase J: version is 0.1.17 upstream but the -# redox_syscall dep is redirected to the local fork at -# ../syscall (which adds EnterS2Idle/ExitS2Idle AcpiVerb -# variants). The version field stays at upstream 0.1.17 -# per the AGENTS.md "GOLDEN RULE" — periodic rebase via -# `git fetch upstream` is the workflow when upstream changes. +# Red Bear OS Phase J: version is 0.1.18 upstream. The +# redox_syscall dep is now required (not optional) because +# the local fork's acpi module (added in this commit) re- +# exports AcPiVerb from redox_syscall, and downstream recipes +# that don't enable the redox_syscall feature get an +# "unresolved import" error. Making the dep non-optional +# also matches the upstream 0.1.18 Cargo.toml pattern where +# the redox_syscall dep is unconditional. version = "0.1.18" edition = "2021" license = "MIT" @@ -37,6 +39,6 @@ libc = { version = "0.2", optional = true } # is what wires this path through to the actual # redox_syscall crate; this path entry is the libredox- # side patch override for the same crate. -redox_syscall = { path = "../syscall", version = "0.8", optional = true } +redox_syscall = { path = "../syscall", version = "0.8" } ioslice = { version = "0.6", optional = true } plain = { version = "0.2", optional = true } diff --git a/src/lib.rs b/src/lib.rs index c36341029e..8d70be6587 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -170,7 +170,8 @@ pub mod flag { pub const WCONTINUED: u32 = libc::WCONTINUED as u32; // CLOEXEC flags (added in libredox 0.1.18) - pub const O_CLOEXEC: usize = 0x0100_0000; + // F_DUPFD_CLOEXEC is the new flag; O_CLOEXEC is already + // imported from libc above so we don't re-export it here. pub const F_DUPFD_CLOEXEC: usize = 1030; } @@ -190,6 +191,11 @@ pub mod flag { /// discriminant is sourced from the local `redox_syscall` fork, /// which is the same source the kernel uses to interpret the verb, /// so reorderings are caught at compile time. +/// +/// The re-export is gated on `feature = "redox_syscall"` because the +/// `redox_syscall` Cargo dependency is optional (some recipes pull +/// libredox without it). Recipes that need ACPI verbs (acpid, etc.) +/// must enable the `redox_syscall` feature. #[cfg(feature = "redox_syscall")] pub mod acpi { pub use redox_syscall::AcPiVerb;