Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport patches to 0.35 #878

Merged
merged 12 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 11 additions & 118 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
rust: stable
- build: nightly
os: ubuntu-latest
rust: nightly-2023-07-03
rust: nightly
- build: 1.48
os: ubuntu-latest
rust: 1.48
Expand Down Expand Up @@ -61,12 +61,9 @@ jobs:
i686-unknown-linux-gnu
i686-unknown-linux-musl
wasm32-unknown-emscripten
riscv64gc-unknown-linux-gnu
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
powerpc64le-unknown-linux-gnu
mipsel-unknown-linux-gnu
mips64el-unknown-linux-gnuabi64
armv5te-unknown-linux-gnueabi
s390x-unknown-linux-gnu
arm-linux-androideabi
Expand All @@ -83,7 +80,7 @@ jobs:
run: |
set -ex
sudo apt-get update
sudo apt-get install -y gcc-i686-linux-gnu gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu gcc-arm-linux-gnueabi musl-tools
sudo apt-get install -y gcc-i686-linux-gnu gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi musl-tools

- name: Use specific dependency versions for Rust 1.48 compatibility.
if: matrix.rust == '1.48'
Expand Down Expand Up @@ -112,13 +109,10 @@ jobs:
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=all-apis
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl --features=use-libc,all-apis
- run: cargo check --workspace --release -vv --target=wasm32-unknown-emscripten --features=all-apis
- run: cargo check --workspace --release -vv --target=riscv64gc-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=all-apis
- run: cargo check --workspace --release -vv --target=aarch64-unknown-linux-musl --features=use-libc,all-apis
- run: cargo check --workspace --release -vv --target=powerpc64le-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=mipsel-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=mips64el-unknown-linux-gnuabi64 --features=all-apis
- run: cargo check --workspace --release -vv --target=armv5te-unknown-linux-gnueabi --features=all-apis
- run: cargo check --workspace --release -vv --target=s390x-unknown-linux-gnu --features=all-apis
- run: cargo check --workspace --release -vv --target=arm-linux-androideabi --features=all-apis
Expand All @@ -136,7 +130,7 @@ jobs:
include:
- build: nightly
os: ubuntu-latest
rust: nightly-2023-07-03
rust: nightly

env:
# -D warnings is commented out in our install-rust action; re-add it here.
Expand All @@ -159,7 +153,7 @@ jobs:
include:
- build: nightly
os: ubuntu-latest
rust: nightly-2023-07-03
rust: nightly

steps:
- uses: actions/checkout@v3
Expand All @@ -186,7 +180,7 @@ jobs:
include:
- build: nightly
os: ubuntu-latest
rust: nightly-2023-07-03
rust: nightly

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -215,7 +209,7 @@ jobs:
QEMU_BUILD_VERSION: 7.0.0
strategy:
matrix:
build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, riscv64-linux, s390x-linux, arm-linux, ubuntu-stable, i686-linux-stable, aarch64-linux-stable, riscv64-linux-stable, s390x-linux-stable, mipsel-linux-stable, mips64el-linux-stable, powerpc64le-linux-stable, arm-linux-stable, macos-latest, macos-10.15, windows, windows-2019]
build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, s390x-linux, arm-linux, ubuntu-stable, i686-linux-stable, aarch64-linux-stable, s390x-linux-stable, powerpc64le-linux-stable, arm-linux-stable, macos-latest, macos-10.15, windows, windows-2019]
include:
- build: ubuntu
os: ubuntu-latest
Expand Down Expand Up @@ -245,33 +239,6 @@ jobs:
qemu: qemu-ppc64le
qemu_args: -L /usr/powerpc64le-linux-gnu
qemu_target: ppc64le-linux-user
- build: mips64el-linux
os: ubuntu-latest
rust: nightly-2023-07-03
target: mips64el-unknown-linux-gnuabi64
gcc_package: gcc-mips64el-linux-gnuabi64
gcc: mips64el-linux-gnuabi64-gcc
qemu: qemu-mips64el
qemu_args: -L /usr/mips64el-linux-gnuabi64
qemu_target: mips64el-linux-user
- build: mipsel-linux
os: ubuntu-latest
rust: nightly-2023-07-03
target: mipsel-unknown-linux-gnu
gcc_package: gcc-mipsel-linux-gnu
gcc: mipsel-linux-gnu-gcc
qemu: qemu-mipsel
qemu_args: -L /usr/mipsel-linux-gnu
qemu_target: mipsel-linux-user
- build: riscv64-linux
os: ubuntu-latest
rust: nightly-2023-07-03
target: riscv64gc-unknown-linux-gnu
gcc_package: gcc-riscv64-linux-gnu
gcc: riscv64-linux-gnu-gcc
qemu: qemu-riscv64
qemu_args: -L /usr/riscv64-linux-gnu
qemu_target: riscv64-linux-user
- build: s390x-linux
os: ubuntu-latest
rust: nightly-2023-07-03
Expand Down Expand Up @@ -309,15 +276,6 @@ jobs:
qemu: qemu-aarch64
qemu_args: -L /usr/aarch64-linux-gnu
qemu_target: aarch64-linux-user
- build: riscv64-linux-stable
os: ubuntu-latest
rust: stable
target: riscv64gc-unknown-linux-gnu
gcc_package: gcc-riscv64-linux-gnu
gcc: riscv64-linux-gnu-gcc
qemu: qemu-riscv64
qemu_args: -L /usr/riscv64-linux-gnu
qemu_target: riscv64-linux-user
- build: s390x-linux-stable
os: ubuntu-latest
rust: stable
Expand All @@ -336,24 +294,6 @@ jobs:
qemu: qemu-ppc64le
qemu_args: -L /usr/powerpc64le-linux-gnu
qemu_target: ppc64le-linux-user
- build: mips64el-linux-stable
os: ubuntu-latest
rust: stable
target: mips64el-unknown-linux-gnuabi64
gcc_package: gcc-mips64el-linux-gnuabi64
gcc: mips64el-linux-gnuabi64-gcc
qemu: qemu-mips64el
qemu_args: -L /usr/mips64el-linux-gnuabi64
qemu_target: mips64el-linux-user
- build: mipsel-linux-stable
os: ubuntu-latest
rust: stable
target: mipsel-unknown-linux-gnu
gcc_package: gcc-mipsel-linux-gnu
gcc: mipsel-linux-gnu-gcc
qemu: qemu-mipsel
qemu_args: -L /usr/mipsel-linux-gnu
qemu_target: mipsel-linux-user
- build: arm-linux-stable
os: ubuntu-latest
rust: stable
Expand All @@ -371,10 +311,10 @@ jobs:
rust: stable
- build: windows
os: windows-latest
rust: nightly-2023-07-03
rust: nightly
- build: windows-2019
os: windows-2019
rust: nightly-2023-07-03
rust: nightly
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -457,7 +397,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, mips64el-linux, mipsel-linux, riscv64-linux, arm-linux]
build: [ubuntu, i686-linux, aarch64-linux, powerpc64le-linux, arm-linux]
include:
- build: ubuntu
os: ubuntu-latest
Expand Down Expand Up @@ -487,33 +427,6 @@ jobs:
qemu: qemu-ppc64le
qemu_args: -L /usr/powerpc64le-linux-gnu
qemu_target: ppc64le-linux-user
- build: mips64el-linux
os: ubuntu-latest
rust: stable
target: mips64el-unknown-linux-gnuabi64
gcc_package: gcc-mips64el-linux-gnuabi64
gcc: mips64el-linux-gnuabi64-gcc
qemu: qemu-mips64el
qemu_args: -L /usr/mips64el-linux-gnuabi64
qemu_target: mips64el-linux-user
- build: mipsel-linux
os: ubuntu-latest
rust: stable
target: mipsel-unknown-linux-gnu
gcc_package: gcc-mipsel-linux-gnu
gcc: mipsel-linux-gnu-gcc
qemu: qemu-mipsel
qemu_args: -L /usr/mipsel-linux-gnu
qemu_target: mipsel-linux-user
- build: riscv64-linux
os: ubuntu-latest
rust: stable
target: riscv64gc-unknown-linux-gnu
gcc_package: gcc-riscv64-linux-gnu
gcc: riscv64-linux-gnu-gcc
qemu: qemu-riscv64
qemu_args: -L /usr/riscv64-linux-gnu
qemu_target: riscv64-linux-user
- build: arm-linux
os: ubuntu-latest
rust: stable
Expand Down Expand Up @@ -599,42 +512,22 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [powerpc64le-linux, mipsel-linux, mips64el-linux]
build: [powerpc64le-linux]
include:
- build: powerpc64le-linux
os: ubuntu-latest
rust: nightly-2023-07-03
rust: nightly
target: powerpc64le-unknown-linux-gnu
gcc_package: gcc-powerpc64le-linux-gnu
gcc: powerpc64le-linux-gnu-gcc
qemu: qemu-ppc64le
qemu_args: -L /usr/powerpc64le-linux-gnu
qemu_target: ppc64le-linux-user
- build: mips64el-linux
os: ubuntu-latest
rust: nightly-2023-07-03
target: mips64el-unknown-linux-gnuabi64
gcc_package: gcc-mips64el-linux-gnuabi64
gcc: mips64el-linux-gnuabi64-gcc
qemu: qemu-mips64el
qemu_args: -L /usr/mips64el-linux-gnuabi64
qemu_target: mips64el-linux-user
- build: mipsel-linux
os: ubuntu-latest
rust: nightly-2023-07-03
target: mipsel-unknown-linux-gnu
gcc_package: gcc-mipsel-linux-gnu
gcc: mipsel-linux-gnu-gcc
qemu: qemu-mipsel
qemu_args: -L /usr/mipsel-linux-gnu
qemu_target: mipsel-linux-user
env:
# -D warnings is commented out in our install-rust action; re-add it here.
RUSTFLAGS: --cfg rustix_use_experimental_asm -D warnings
RUSTDOCFLAGS: --cfg rustix_use_experimental_asm
CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUSTFLAGS: --cfg rustix_use_experimental_asm
CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUSTFLAGS: --cfg rustix_use_experimental_asm
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUSTFLAGS: --cfg rustix_use_experimental_asm
QEMU_BUILD_VERSION: 7.0.0
steps:
- uses: actions/checkout@v3
Expand Down
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ tempfile = "3.2.0"
libc = "0.2.133"
libc_errno = { package = "errno", version = "0.2.8", default-features = false }
io-lifetimes = { version = "0.7.0", default-features = false, features = ["close"] }
# 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(windows)'.dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ by default. The rest of the API is conditional with cargo feature flags:

## Similar crates

`rustix` is similar to [`nix`], [`simple_libc`], [`unix`], [`nc`], and
[`uapi`]. `rustix` is architected for [I/O safety] with most APIs using
`rustix` is similar to [`nix`], [`simple_libc`], [`unix`], [`nc`], [`uapi`],
and [`rusl`]. `rustix` is architected for [I/O safety] with most APIs using
[`OwnedFd`] and [`AsFd`] to manipulate file descriptors rather than `File` or
even `c_int`, and supporting multiple backends so that it can use direct
syscalls while still being usable on all platforms `libc` supports. Like `nix`,
Expand Down Expand Up @@ -136,6 +136,7 @@ version of this crate.
[`nc`]: https://crates.io/crates/nc
[`simple_libc`]: https://crates.io/crates/simple_libc
[`uapi`]: https://crates.io/crates/uapi
[`rusl`]: https://lib.rs/crates/rusl
[`relibc`]: https://github.com/redox-os/relibc
[`syscall`]: https://crates.io/crates/syscall
[`sc`]: https://crates.io/crates/sc
Expand Down
46 changes: 40 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ fn main() {
}

println!("cargo:rerun-if-env-changed=CARGO_CFG_RUSTIX_USE_EXPERIMENTAL_ASM");
println!("cargo:rerun-if-env-changed=CARGO_CFG_RUSTIX_USE_LIBC");

// Rerun this script if any of our features or configuration flags change,
// or if the toolchain we used for feature detection changes.
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_USE_LIBC");
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_RUSTC_DEP_OF_STD");
println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");
}

/// Link in the desired version of librustix_outline_{arch}.a, containing the
Expand Down Expand Up @@ -180,26 +187,53 @@ fn has_feature(feature: &str) -> bool {
}

/// Test whether the rustc at `var("RUSTC")` can compile the given code.
fn can_compile(code: &str) -> bool {
fn can_compile<T: AsRef<str>>(test: T) -> bool {
use std::process::Stdio;

let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();

let mut child = std::process::Command::new(rustc)
.arg("--crate-type=rlib") // Don't require `main`.
// Use `RUSTC_WRAPPER` if it's set, unless it's set to an empty string,
// as documented [here].
// [here]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads
let wrapper = var("RUSTC_WRAPPER")
.ok()
.and_then(|w| if w.is_empty() { None } else { Some(w) });

let mut cmd = if let Some(wrapper) = wrapper {
let mut cmd = std::process::Command::new(wrapper);
// The wrapper's first argument is supposed to be the path to rustc.
cmd.arg(rustc);
cmd
} else {
std::process::Command::new(rustc)
};

cmd.arg("--crate-type=rlib") // Don't require `main`.
.arg("--emit=metadata") // Do as little as possible but still parse.
.arg("--target")
.arg(target)
.arg("--out-dir")
.arg(out_dir) // Put the output somewhere inconsequential.
.arg(out_dir); // Put the output somewhere inconsequential.

// If Cargo wants to set RUSTFLAGS, use that.
if let Ok(rustflags) = var("CARGO_ENCODED_RUSTFLAGS") {
if !rustflags.is_empty() {
for arg in rustflags.split('\x1f') {
cmd.arg(arg);
}
}
}

let mut child = cmd
.arg("-") // Read from stdin.
.stdin(Stdio::piped()) // Stdin is a pipe.
.stderr(Stdio::null())
.stderr(Stdio::null()) // Errors from feature detection aren't interesting and can be confusing.
.spawn()
.unwrap();

writeln!(child.stdin.take().unwrap(), "{}", code).unwrap();
writeln!(child.stdin.take().unwrap(), "{}", test.as_ref()).unwrap();

child.wait().unwrap().success()
}
Loading
Loading