Skip to content

Commit

Permalink
Make the libc "extra_traits" feature optional.
Browse files Browse the repository at this point in the history
Make "libc/extra_traits" optional and enabled by default, so that it can
be disabled by --no-default-features. This fixes rustc-dep-of-std
builds, because extra_traits depends on std.
  • Loading branch information
sunfishcode committed Apr 21, 2024
1 parent 63dd84a commit 475d135
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ once_cell = { version = "1.5.2", optional = true }
[target.'cfg(all(not(rustix_use_libc), not(miri), 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]
linux-raw-sys = { version = "0.4.12", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
libc_errno = { package = "errno", version = "0.3.8", default-features = false, optional = true }
libc = { version = "0.2.153", default-features = false, features = ["extra_traits"], optional = true }
libc = { version = "0.2.153", default-features = false, optional = true }

# Dependencies for platforms where only libc is supported:
#
# On all other Unix-family platforms, and under Miri, we always use the libc
# backend, so enable its dependencies unconditionally.
[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_errno = { package = "errno", version = "0.3.8", default-features = false }
libc = { version = "0.2.153", default-features = false, features = ["extra_traits"] }
libc = { version = "0.2.153", default-features = false }

# Additional dependencies for Linux with the libc backend:
#
Expand Down Expand Up @@ -119,14 +119,18 @@ targets = [
# It turns out to be bizarrely awkward to obtain the aux values reliably and
# efficiently on Linux from anywhere other than libc. We can do it, but most
# users are better served by just using libc for this.
default = ["std", "use-libc-auxv"]
default = ["std", "use-libc-auxv", "libc-extra-traits"]

# Enable `extra_traits` in libc types, to provide `Debug`, `Hash`, and other
# trait impls for libc types.
libc-extra-traits = ["libc?/extra_traits"]

# This enables use of std. Disabling this enables `#![no_std]`, and requires
# Rust 1.64 or newer.
std = ["bitflags/std", "alloc", "libc?/std", "libc_errno?/std"]

# Enable this to request the libc backend.
use-libc = ["libc_errno", "libc"]
use-libc = ["libc_errno", "libc", "libc-extra-traits"]

# Enable `rustix::event::*`.
event = []
Expand Down

0 comments on commit 475d135

Please sign in to comment.