1[package]
2name = "rustix"
3version = "1.0.5"
4authors = [
5 "Dan Gohman <dev@sunfishcode.online>",
6 "Jakub Konka <kubkon@jakubkonka.com>",
7]
8description = "Safe Rust bindings to POSIX/Unix/Linux/Winsock-like syscalls"
9documentation = "https://docs.rs/rustix"
10license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT"
11repository = "https://github.com/bytecodealliance/rustix"
12edition = "2021"
13keywords = ["api", "file", "network", "safe", "syscall"]
14categories = ["os::unix-apis", "date-and-time", "filesystem", "network-programming"]
15include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md", "benches"]
16rust-version = "1.63"
17
18[dependencies]
19bitflags = { version = "2.4.0", default-features = false }
20
21# Special dependencies used in rustc-dep-of-std mode.
22core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" }
23rustc-std-workspace-alloc = { version = "1.0.0", optional = true } # not aliased here but in lib.rs because of name collision with the alloc feature
24compiler_builtins = { version = '0.1.49', optional = true }
25
26# Dependencies for platforms where linux_raw is supported, in addition to libc:
27#
28# On Linux on selected architectures, the linux_raw backend is supported, in
29# addition to the libc backend. The linux_raw backend is used by default. The
30# libc backend can be selected via adding `--cfg=rustix_use_libc` to
31# `RUSTFLAGS` or enabling the `use-libc` cargo feature.
32[target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", any(target_endian = "little", any(target_arch = "s390x", target_arch = "powerpc")), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc"), all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), 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]
33linux-raw-sys = { version = "0.9.2", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
34libc_errno = { package = "errno", version = "0.3.10", default-features = false, optional = true }
35libc = { version = "0.2.168", default-features = false, optional = true }
36
37# Dependencies for platforms where only libc is supported:
38#
39# On all other Unix-family platforms, and under Miri, we always use the libc
40# backend, so enable its dependencies unconditionally.
41[target.'cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_endian = "little", any(target_arch = "s390x", target_arch = "powerpc")), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc"), all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), 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]
42libc_errno = { package = "errno", version = "0.3.10", default-features = false }
43libc = { version = "0.2.168", default-features = false }
44
45# Additional dependencies for Linux with the libc backend:
46#
47# Some syscalls do not have libc wrappers, such as in `io_uring`. For these,
48# the libc backend uses the linux-raw-sys ABI and `libc::syscall`.
49[target.'cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", any(target_endian = "little", any(target_arch = "s390x", target_arch = "powerpc")), any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc"), all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "s390x"), 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]
50linux-raw-sys = { version = "0.9.2", default-features = false, features = ["general", "ioctl", "no_std"] }
51
52# For the libc backend on Windows, use the Winsock API in windows-sys.
53[target.'cfg(windows)'.dependencies.windows-sys]
54version = ">=0.52, <0.60"
55features = [
56 "Win32_Foundation",
57 "Win32_Networking_WinSock",
58]
59
60# For the libc backend on Windows, also use the errno crate, which has Windows
61# support.
62[target.'cfg(windows)'.dependencies.libc_errno]
63version = "0.3.10"
64package = "errno"
65default-features = false
66
67[dev-dependencies]
68tempfile = "3.5.0"
69libc = "0.2.168"
70libc_errno = { package = "errno", version = "0.3.10", default-features = false }
71serial_test = "2.0.0"
72memoffset = "0.9.0"
73flate2 = "1.0"
74static_assertions = "1.1.0"
75
76# With Rust 1.70 this can be removed in favor of `std::sync::OnceLock`.
77[target.'cfg(windows)'.dev-dependencies]
78once_cell = "1.20.3"
79
80[target.'cfg(all(criterion, not(any(target_os = "emscripten", target_os = "wasi"))))'.dev-dependencies]
81criterion = "0.4"
82
83# Add Criterion configuration, as described here:
84# <https://bheisler.github.io/criterion.rs/book/getting_started.html#step-1---add-dependency-to-cargotoml>
85[[bench]]
86name = "mod"
87harness = false
88
89[package.metadata.docs.rs]
90features = ["all-apis"]
91targets = [
92 "x86_64-unknown-linux-gnu",
93 "i686-unknown-linux-gnu",
94 "x86_64-apple-darwin",
95 "x86_64-pc-windows-msvc",
96 "x86_64-unknown-freebsd",
97 "x86_64-unknown-openbsd",
98 "x86_64-unknown-netbsd",
99 "x86_64-unknown-dragonfly",
100 "x86_64-unknown-illumos",
101 "x86_64-unknown-redox",
102 "x86_64-unknown-haiku",
103 "wasm32-unknown-emscripten",
104 "wasm32-wasip1",
105]
106
107[features]
108
109# By default, use `std`.
110default = ["std"]
111
112# This enables use of std. Disabling this enables `#![no_std]`, and requires
113# Rust 1.77 or newer.
114std = ["bitflags/std", "alloc", "libc?/std", "libc_errno?/std"]
115
116# Enable this to request the libc backend.
117use-libc = ["libc_errno", "libc"]
118
119# Enable `rustix::event::*`.
120event = []
121
122# Enable `rustix::fs::*`.
123fs = []
124
125# Enable `rustix::io_uring::*` (on platforms that support it).
126io_uring = ["event", "fs", "net", "thread", "linux-raw-sys/io_uring"]
127
128# Enable `rustix::mount::*`.
129mount = []
130
131# Enable `rustix::net::*`.
132net = ["linux-raw-sys/net", "linux-raw-sys/netlink", "linux-raw-sys/if_ether", "linux-raw-sys/xdp"]
133
134# Enable `rustix::thread::*`.
135thread = ["linux-raw-sys/prctl"]
136
137# Enable `rustix::process::*`.
138process = ["linux-raw-sys/prctl"]
139
140# Enable `rustix::shm::*`.
141shm = ["fs"]
142
143# Enable `rustix::time::*`.
144time = []
145
146# Enable `rustix::param::*`.
147param = []
148
149# Enable `rustix::pty::*`.
150pty = ["fs"]
151
152# Enable `rustix::termios::*`.
153termios = []
154
155# Enable `rustix::mm::*`.
156mm = []
157
158# Enable `rustix::pipe::*`.
159pipe = []
160
161# Enable `rustix::rand::*`.
162rand = []
163
164# Enable `rustix::stdio::*`.
165stdio = []
166
167# Enable `rustix::system::*`.
168system = ["linux-raw-sys/system"]
169
170# Enable `rustix::runtime::*`. ⚠ This API is undocumented and unstable and
171# experimental and not intended for general-purpose use. ⚠
172runtime = ["linux-raw-sys/prctl"]
173
174# Enable all API features.
175#
176# This is primarily intended for rustix developers. Users are encouraged to
177# enable only those features they need.
178all-apis = [
179 "event",
180 "fs",
181 "io_uring",
182 "mm",
183 "mount",
184 "net",
185 "param",
186 "pipe",
187 "process",
188 "pty",
189 "rand",
190 "runtime",
191 "shm",
192 "stdio",
193 "system",
194 "termios",
195 "thread",
196 "time",
197]
198
199# When using the linux_raw backend, should we use `getauxval` for reading aux
200# vectors, instead of `PR_GET_AUXV` or "/proc/self/auxv"?
201use-libc-auxv = []
202
203# Enable "use-explicitly-provided-auxv" mode, with a public
204# `rustix::param::init` function that must be called before anything else in
205# rustix. This is unstable and experimental and not intended for
206# general-purpose use.
207use-explicitly-provided-auxv = []
208
209# OS compatibility features
210
211# Specialize for Linux 4.11 or later
212linux_4_11 = []
213
214# Specialize for Linux 5.1 or later
215linux_5_1 = ["linux_4_11"]
216
217# Specialize for Linux 5.11 or later
218linux_5_11 = ["linux_5_1"]
219
220# Enable all specializations for the latest Linux versions.
221linux_latest = ["linux_5_11"]
222
223# Enable features which depend on the Rust global allocator, such as functions
224# that return owned strings or `Vec`s.
225alloc = []
226
227# This is used in the port of std to rustix. This is experimental and not meant
228# for regular use.
229rustc-dep-of-std = [
230 "core",
231 "rustc-std-workspace-alloc",
232 "compiler_builtins",
233 "linux-raw-sys/rustc-dep-of-std",
234 "bitflags/rustc-dep-of-std",
235 "compiler_builtins?/rustc-dep-of-std",
236]
237
238# Enable `rustix::io::try_close`. The rustix developers do not intend the
239# existence of this feature to imply that anyone should use it.
240try_close = []
241
242[lints.rust.unexpected_cfgs]
243level = "warn"
244check-cfg = [
245 'cfg(alloc_c_string)',
246 'cfg(alloc_ffi)',
247 'cfg(apple)',
248 'cfg(asm_experimental_arch)',
249 'cfg(bsd)',
250 'cfg(core_c_str)',
251 'cfg(core_ffi_c)',
252 'cfg(core_intrinsics)',
253 'cfg(criterion)',
254 'cfg(document_experimental_runtime_api)',
255 'cfg(error_in_core)',
256 'cfg(fix_y2038)',
257 'cfg(freebsdlike)',
258 'cfg(libc)',
259 'cfg(linux_kernel)',
260 'cfg(linux_like)',
261 'cfg(linux_raw)',
262 'cfg(netbsdlike)',
263 'cfg(rustc_attrs)',
264 'cfg(solarish)',
265 'cfg(staged_api)',
266 'cfg(static_assertions)',
267 'cfg(thumb_mode)',
268 'cfg(wasi)',
269 'cfg(wasi_ext)',
270 'cfg(wasip2)',
271 'cfg(target_arch, values("xtensa"))',
272 'cfg(target_os, values("cygwin"))',
273]
274