Files
third_party_rust_rustix/Cargo.toml
T
Dan Gohman 4eed038018 Switch from .init_array constructors to /proc/self/auxv. (#385)
* Switch from `.init_array` constructors to /proc/self/auxv.

In the linux_raw backend, switch from using a `.init_array` constructor
for obtaining the aux values to reading them from /proc/self/auxv. This avoids
problems in situation where other Rust code can run before the constructor,
potentially distrupting the `__environ` value.

Also, for the linux_raw backend, introduce a new "use-libc-auxv" feature,
which enables use of libc to read the aux values, instead of reading
them from /proc/self/auxv.

The "use-libc-auxv" option is enabled by default, because it's more
efficient and doesn't depend on /proc, so it's likely better for most
users.

Mustang, for its part, continues to be able to use the incoming auxv on
the stack because it controls program startup. Since it doesn't have to
worry about the hazards of /proc or QEMU, it can trust the incoming
values, and do less checking.

Fixes #382.

* Remove the param `init` function from the libc backend.

* Fix the no-std build.

* Fix the backends test to accept that the default options now depend on libc.

* Use `NonNull` in `check_raw_pointer`'s return type.

This allows it to pack the return value into a single pointer-sized
value.

* Update more code to the new `check_raw_pointer` API.

* Fix an unused-import warning.

* Fix copy+paste.

* Thread `check_elf_base` through `check_vdso_base` too.
2022-08-08 11:06:28 -07:00

192 lines
7.0 KiB
TOML

[package]
name = "rustix"
version = "0.35.7"
authors = [
"Dan Gohman <dev@sunfishcode.online>",
"Jakub Konka <kubkon@jakubkonka.com>",
]
description = "Safe Rust bindings to POSIX/Unix/Linux/Winsock2-like syscalls"
documentation = "https://docs.rs/rustix"
license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT"
repository = "https://github.com/bytecodealliance/rustix"
edition = "2018"
keywords = ["api", "file", "network", "safe", "syscall"]
categories = ["os::unix-apis", "date-and-time", "filesystem", "network-programming"]
include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md"]
[build-dependencies]
cc = { version = "1.0.68", optional = true }
[dependencies]
bitflags = "1.2.1"
itoa = { version = "1.0.1", default-features = false, optional = true }
io-lifetimes = { version = "0.7.0", default-features = false, optional = true }
# Special dependencies used in rustc-dep-of-std mode.
core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" }
alloc = { version = "1.0.0", optional = true, package = "rustc-std-workspace-alloc" }
compiler_builtins = { version = '0.1.49', optional = true }
# The procfs feature needs once_cell.
[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
once_cell = { version = "1.5.2", optional = true }
# Dependencies for platforms where linux_raw is supported, in addition to libc:
#
# On Linux on selected architectures, the linux_raw backend is supported, in
# addition to the libc backend. The linux_raw backend is used by default. The
# libc backend can be selected via adding `--cfg=rustix_use_libc` to
# `RUSTFLAGS` or enabling the `use-libc` cargo feature.
[target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", any(target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"), all(target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "mips", target_arch = "mips64")))))'.dependencies]
linux-raw-sys = { version = "0.0.46", default-features = false, features = ["general", "errno", "ioctl", "no_std"] }
libc_errno = { package = "errno", version = "0.2.8", default-features = false, optional = true }
libc = { version = "0.2.126", features = ["extra_traits"], 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(any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"), all(target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "mips", target_arch = "mips64")))))))'.dependencies]
libc_errno = { package = "errno", version = "0.2.8", default-features = false }
libc = { version = "0.2.126", features = ["extra_traits"] }
# Additional dependencies for Linux with the libc backend:
#
# Some syscalls do not have libc wrappers, such as in `io_uring`. For these,
# the libc backend uses the linux-raw-sys ABI and `libc::syscall`.
[target.'cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"), all(target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "powerpc64", target_arch = "riscv64", target_arch = "mips", target_arch = "mips64"))))))))'.dependencies]
linux-raw-sys = { version = "0.0.46", default-features = false, optional = true, features = ["general", "no_std"] }
# For the libc backend on Windows, use the Winsock2 API in windows-sys.
[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.36.0"
features = [
"Win32_Foundation",
"Win32_Networking_WinSock",
"Win32_NetworkManagement_IpHelper",
"Win32_System_Threading"
]
[dev-dependencies]
tempfile = "3.2.0"
libc = "0.2.126"
libc_errno = { package = "errno", version = "0.2.8", default-features = false }
io-lifetimes = { version = "0.7.0", default-features = false }
# Don't upgrade to serial_test 0.7 for now because it depends on a
# `parking_lot_core` version which is not compatible with our MSRV of 1.48.
serial_test = "0.6"
memoffset = "0.6.5"
[target.'cfg(not(target_os = "emscripten"))'.dev-dependencies]
criterion = "0.3"
[target.'cfg(windows)'.dev-dependencies]
ctor = "0.1.21"
# Add Criterion configuration, as described here:
# <https://bheisler.github.io/criterion.rs/book/getting_started.html#step-1---add-dependency-to-cargotoml>
[[bench]]
name = "mod"
harness = false
[package.metadata.docs.rs]
features = ["all-apis"]
rustdoc-args = ["--cfg", "doc_cfg"]
targets = [
"x86_64-unknown-linux-gnu",
"i686-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
]
[features]
# By default, use `std` and use libc for aux values.
#
# 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"]
# This enables use of std. Disabling this enables `#![no_std], and requires
# nightly Rust.
std = ["io-lifetimes"]
# This is used in the port of std to rustix.
rustc-dep-of-std = [
"core",
"alloc",
"compiler_builtins",
"linux-raw-sys/rustc-dep-of-std",
"bitflags/rustc-dep-of-std",
]
# Enable this to request the libc backend.
use-libc = ["libc_errno", "libc"]
# Enable `rustix::fs::*`.
fs = []
# Enable `rustix::io_uring::*` (on platforms that support it).
io_uring = ["linux-raw-sys", "fs", "net"]
# Enable `rustix::net::*`.
net = []
# Enable `rustix::thread::*`.
thread = []
# Enable `rustix::process::*`.
process = []
# Enable `rustix::time::*`.
time = []
# Enable `rustix::param::*`.
param = []
# Enable this to enable `rustix::io::proc_self_*` (on Linux) and `ttyname`.
procfs = ["once_cell", "itoa"]
# Enable `rustix::termios::*`.
termios = []
# Enable `rustix::mm::*`.
mm = ["linux-raw-sys"]
# Enable `rustix::rand::*`.
rand = []
# Enable `rustix::runtime::*`. This API is undocumented and unstable.
runtime = []
# Enable all API features.
all-apis = [
"fs",
"io_uring",
"mm",
"net",
"param",
"process",
"procfs",
"rand",
"runtime",
"termios",
"thread",
"time",
]
# When using the linux_raw backend, and not using Mustang, should we use libc
# for reading the aux vectors, instead of reading them ourselves from
# /proc/self/auxv?
use-libc-auxv = ["libc"]
# Expose io-lifetimes' features for third-party crate impls.
async-std = ["io-lifetimes/async-std"]
tokio = ["io-lifetimes/tokio"]
os_pipe = ["io-lifetimes/os_pipe"]
socket2 = ["io-lifetimes/socket2"]
mio = ["io-lifetimes/mio"]
fs-err = ["io-lifetimes/fs-err"]
all-impls = ["async-std", "tokio", "os_pipe", "socket2", "mio", "fs-err"]