Skip to content

Commit e400585

Browse files
authored
Merge branch 'bytecodealliance:main' into fix/manual-filter-lint
2 parents 53d434f + 287214b commit e400585

32 files changed

Lines changed: 290 additions & 92 deletions

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
cargo update --package=half --precise=2.2.1
5555
cargo update --package=flate2 --precise=1.0.35
5656
cargo update --package=serde --precise=1.0.228
57+
cargo update --package=web-sys --precise=0.3.104
5758
cargo update --package=syn --precise=2.0.106
5859
cargo update --package=textwrap --precise=0.16.1
5960
cargo update --package=parking_lot --precise=0.12.4
@@ -596,6 +597,7 @@ jobs:
596597
cargo update --package=half --precise=2.2.1
597598
cargo update --package=flate2 --precise=1.0.35
598599
cargo update --package=serde --precise=1.0.228
600+
cargo update --package=web-sys --precise=0.3.104
599601
cargo update --package=syn --precise=2.0.106
600602
cargo update --package=textwrap --precise=0.16.1
601603
cargo update --package=parking_lot --precise=0.12.4

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustix"
3-
version = "1.1.4"
3+
version = "1.1.5"
44
authors = [
55
"Dan Gohman <dev@sunfishcode.online>",
66
"Jakub Konka <kubkon@jakubkonka.com>",
@@ -170,7 +170,7 @@ stdio = []
170170
# Enable `rustix::system::*`.
171171
system = ["linux-raw-sys/system"]
172172

173-
# Enable `rustix::runtime::*`. ⚠ This API is undocumented and unstable and
173+
# Enable `rustix::runtime_*::*`. ⚠ This API is undocumented and unstable and
174174
# experimental and not intended for general-purpose use. ⚠
175175
runtime = ["linux-raw-sys/prctl"]
176176

build.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ fn main() {
188188
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_USE_LIBC");
189189
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_RUSTC_DEP_OF_STD");
190190
println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");
191+
192+
// Remove the can_compile() probe artifact so OUT_DIR ends up empty.
193+
// The emitted metadata is not byte-reproducible, and a nondeterministic
194+
// OUT_DIR destabilizes the cache keys of some build systems like Bazel.
195+
let _ = std::fs::remove_file(probe_file());
191196
}
192197

193198
fn use_thumb_mode() -> bool {
@@ -219,6 +224,10 @@ fn has_feature(feature: &str) -> bool {
219224
))
220225
}
221226

227+
fn probe_file() -> PathBuf {
228+
PathBuf::from(var("OUT_DIR").unwrap()).join("rustix_test_can_compile")
229+
}
230+
222231
/// Test whether the rustc at `var("RUSTC")` can compile the given code.
223232
fn can_compile<T: AsRef<str>>(test: T) -> bool {
224233
use std::process::Stdio;
@@ -240,14 +249,12 @@ fn can_compile<T: AsRef<str>>(test: T) -> bool {
240249
std::process::Command::new(rustc)
241250
};
242251

243-
let out_dir = var("OUT_DIR").unwrap();
244-
let out_file = PathBuf::from(out_dir).join("rustix_test_can_compile");
245252
cmd.arg("--crate-type=rlib") // Don't require `main`.
246253
.arg("--emit=metadata") // Do as little as possible but still parse.
247254
.arg("--target")
248255
.arg(target)
249256
.arg("-o")
250-
.arg(out_file)
257+
.arg(probe_file())
251258
.stdout(Stdio::null()); // We don't care about the output (only whether it builds or not)
252259

253260
// If Cargo wants to set RUSTFLAGS, use that.

src/backend/libc/c.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -474,30 +474,27 @@ mod readwrite_pv64v2 {
474474
))]
475475
pub(super) use readwrite_pv64v2::{preadv64v2 as preadv2, pwritev64v2 as pwritev2};
476476

477-
// Rust's libc crate lacks statx for Non-glibc targets.
477+
// Rust's libc crate > v0.2.189 may also define these constants,
478+
// so we use an explicit import.
478479
#[cfg(feature = "fs")]
479480
#[cfg(all(
480481
linux_like,
481482
linux_raw_dep,
482483
not(any(
484+
target_os = "android",
483485
target_os = "emscripten",
484486
target_env = "gnu",
485487
all(target_arch = "loongarch64", target_env = "musl")
486488
))
487489
))]
488-
mod statx_flags {
489-
pub(crate) use linux_raw_sys::general::{
490-
STATX_ALL, STATX_ATIME, STATX_BASIC_STATS, STATX_BLOCKS, STATX_BTIME, STATX_CTIME,
491-
STATX_DIOALIGN, STATX_GID, STATX_INO, STATX_MNT_ID, STATX_MODE, STATX_MTIME, STATX_NLINK,
492-
STATX_SIZE, STATX_TYPE, STATX_UID,
493-
};
494-
495-
pub(crate) use linux_raw_sys::general::{
496-
STATX_ATTR_APPEND, STATX_ATTR_AUTOMOUNT, STATX_ATTR_COMPRESSED, STATX_ATTR_DAX,
497-
STATX_ATTR_ENCRYPTED, STATX_ATTR_IMMUTABLE, STATX_ATTR_MOUNT_ROOT, STATX_ATTR_NODUMP,
498-
STATX_ATTR_VERITY,
499-
};
500-
}
490+
pub(crate) use linux_raw_sys::general::{
491+
STATX_ALL, STATX_ATIME, STATX_BASIC_STATS, STATX_BLOCKS, STATX_BTIME, STATX_CTIME,
492+
STATX_DIOALIGN, STATX_GID, STATX_INO, STATX_MNT_ID, STATX_MODE, STATX_MTIME, STATX_NLINK,
493+
STATX_SIZE, STATX_TYPE, STATX_UID,
494+
};
495+
496+
// Rust's libc crate > v0.2.189 may also define these constants,
497+
// so we use an explicit import.
501498
#[cfg(feature = "fs")]
502499
#[cfg(all(
503500
linux_like,
@@ -509,7 +506,11 @@ mod statx_flags {
509506
all(target_arch = "loongarch64", target_env = "musl")
510507
))
511508
))]
512-
pub(crate) use statx_flags::*;
509+
pub(crate) use linux_raw_sys::general::{
510+
STATX_ATTR_APPEND, STATX_ATTR_AUTOMOUNT, STATX_ATTR_COMPRESSED, STATX_ATTR_DAX,
511+
STATX_ATTR_ENCRYPTED, STATX_ATTR_IMMUTABLE, STATX_ATTR_MOUNT_ROOT, STATX_ATTR_NODUMP,
512+
STATX_ATTR_VERITY,
513+
};
513514

514515
#[cfg(feature = "fs")]
515516
#[cfg(target_os = "android")]

src/backend/libc/conv.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
//! for converting between rustix's types and libc types.
44
55
use super::c;
6-
#[cfg(all(feature = "alloc", not(any(windows, target_os = "espidf"))))]
6+
#[cfg(all(
7+
feature = "alloc",
8+
not(any(windows, target_os = "espidf", target_os = "horizon"))
9+
))]
710
use super::fd::IntoRawFd as _;
811
use super::fd::{AsRawFd as _, BorrowedFd, FromRawFd as _, LibcFd, OwnedFd, RawFd};
912
#[cfg(not(windows))]
@@ -35,7 +38,12 @@ pub(super) fn borrowed_fd(fd: BorrowedFd<'_>) -> LibcFd {
3538

3639
#[cfg(all(
3740
feature = "alloc",
38-
not(any(windows, target_os = "espidf", target_os = "redox"))
41+
not(any(
42+
windows,
43+
target_os = "espidf",
44+
target_os = "horizon",
45+
target_os = "redox"
46+
))
3947
))]
4048
#[inline]
4149
pub(super) fn owned_fd(fd: OwnedFd) -> LibcFd {

src/backend/libc/event/poll_fd.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ use bitflags::bitflags;
88
use core::fmt;
99
use core::marker::PhantomData;
1010

11+
#[cfg(not(target_os = "horizon"))]
12+
pub(crate) type RawPollFlags = ffi::c_short;
13+
#[cfg(target_os = "horizon")]
14+
pub(crate) type RawPollFlags = ffi::c_int;
15+
1116
bitflags! {
1217
/// `POLL*` flags for use with [`poll`].
1318
///
1419
/// [`poll`]: crate::event::poll
1520
#[repr(transparent)]
1621
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
17-
pub struct PollFlags: ffi::c_short {
22+
pub struct PollFlags: RawPollFlags {
1823
/// `POLLIN`
1924
const IN = c::POLLIN;
2025
/// `POLLPRI`

src/backend/libc/event/syscalls.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,7 @@ pub(crate) unsafe fn select(
247247
let timeout_data;
248248
let timeout_ptr = match timeout {
249249
Some(timeout) => {
250-
// Convert from `Timespec` to `c::timeval`.
251-
timeout_data = c::timeval {
252-
tv_sec: timeout.tv_sec.try_into().map_err(|_| io::Errno::INVAL)?,
253-
tv_usec: ((timeout.tv_nsec + 999) / 1000) as _,
254-
};
250+
timeout_data = timeout.to_timeval()?;
255251
&timeout_data
256252
}
257253
None => null(),
@@ -324,11 +320,7 @@ pub(crate) unsafe fn select(
324320
let timeout_data;
325321
let timeout_ptr = match timeout {
326322
Some(timeout) => {
327-
// Convert from `Timespec` to `c::timeval`.
328-
timeout_data = c::timeval {
329-
tv_sec: timeout.tv_sec.try_into().map_err(|_| io::Errno::INVAL)?,
330-
tv_usec: ((timeout.tv_nsec + 999) / 1000) as _,
331-
};
323+
timeout_data = timeout.to_timeval()?;
332324
&timeout_data
333325
}
334326
None => null(),

src/backend/libc/event/windows_syscalls.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,7 @@ pub(crate) fn select(
5454
let timeout_data;
5555
let timeout_ptr = match timeout {
5656
Some(timeout) => {
57-
// Convert from `Timespec` to `TIMEVAL`.
58-
timeout_data = c::TIMEVAL {
59-
tv_sec: timeout
60-
.tv_sec
61-
.try_into()
62-
.map_err(|_| io::Errno::OPNOTSUPP)?,
63-
tv_usec: ((timeout.tv_nsec + 999) / 1000) as _,
64-
};
57+
timeout_data = timeout.to_timeval()?;
6558
&timeout_data
6659
}
6760
None => null(),

src/backend/libc/fs/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
#[cfg(all(feature = "alloc", not(any(target_os = "espidf", target_os = "redox"))))]
1+
#[cfg(all(
2+
feature = "alloc",
3+
not(any(target_os = "espidf", target_os = "horizon", target_os = "redox"))
4+
))]
25
pub(crate) mod dir;
36
#[cfg(linux_kernel)]
47
pub mod inotify;

src/backend/libc/fs/syscalls.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ use crate::fs::SealFlags;
4949
target_os = "wasi",
5050
)))]
5151
use crate::fs::StatFs;
52-
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
52+
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
5353
use crate::fs::Timestamps;
5454
#[cfg(not(any(
5555
apple,
5656
target_os = "espidf",
57+
target_os = "horizon",
5758
target_os = "redox",
5859
target_os = "vita",
5960
target_os = "wasi"
@@ -941,6 +942,7 @@ pub(crate) fn utimensat(
941942
c::c_int
942943
) -> c::c_int
943944
}
945+
#[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
944946
extern "C" {
945947
fn setattrlist(
946948
path: *const ffi::c_char,
@@ -950,6 +952,7 @@ pub(crate) fn utimensat(
950952
options: c::c_ulong,
951953
) -> c::c_int;
952954
}
955+
#[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
953956
const FSOPT_NOFOLLOW: c::c_ulong = 0x0000_0001;
954957

955958
// If we have `utimensat`, use it.
@@ -962,15 +965,22 @@ pub(crate) fn utimensat(
962965
));
963966
}
964967

968+
// Return `NOSYS` on platforms where `utimensat` cannot be emulated
969+
// because `fork` is unavailable.
970+
#[cfg(any(target_os = "tvos", target_os = "watchos"))]
971+
return Err(io::Errno::NOSYS);
972+
965973
// Convert `times`. We only need this in the child, but do it before
966974
// calling `fork` because it might fail.
975+
#[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
967976
let (attrbuf_size, times, attrs) = times_to_attrlist(times)?;
968977

969978
// `setattrlistat` was introduced in 10.13 along with `utimensat`, so
970979
// if we don't have `utimensat`, we don't have `setattrlistat` either.
971980
// Emulate it using `fork`, and `fchdir` and [`setattrlist`].
972981
//
973982
// [`setattrlist`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setattrlist.2.html
983+
#[cfg(not(any(target_os = "tvos", target_os = "watchos")))]
974984
match c::fork() {
975985
-1 => Err(io::Errno::IO),
976986
0 => {

0 commit comments

Comments
 (0)