Skip to content

[0.2] Backports #4468

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

Merged
merged 29 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e70b031
chore: add clippy CI tests
nyurik Apr 15, 2025
2aba854
simplify clippy ci
nyurik Apr 15, 2025
c544ee4
run clippy on 3 major platforms
nyurik Apr 15, 2025
d716b80
chore: inline format args
nyurik Apr 15, 2025
b21e075
chore: lint `libc-test/build.rs`
nyurik Apr 15, 2025
a598506
chore: apply some clippy lints
nyurik Apr 15, 2025
2bb4cea
Add constants and types for nsfs ioctls
rusty-snake May 1, 2025
e9fc580
musl: loongarch64: Define MADV_SOFT_OFFLINE constant
heiher May 7, 2025
f1e459f
Add MADV_SOFT_OFFLINE definition for RISC-V musl targets
mnissler-rivos May 6, 2025
c469a85
ci: install-musl: upgrade to 1.2.3
xbjfk May 4, 2025
a28ee2b
libc-test: update conditions for workarounds for musl <1.2.3
xbjfk May 3, 2025
b553d1f
musl: Fix O_LARGEFILE constant value.
xbjfk May 3, 2025
a485516
Add musl_v1_2_3 feature
xbjfk May 3, 2025
d63132d
musl: fix utmpx struct layout
xbjfk May 3, 2025
37cde5a
musl: struct tcp_info: add new fields since 1.2.0/1.2.2
xbjfk May 3, 2025
f5d4b07
musl: update RLIM_NLIMITS
xbjfk May 3, 2025
53a99ed
musl: struct ipc_perm: rename `__ipc_perm_key` to `__key`
xbjfk May 3, 2025
a066096
musl: aarch64: update type of ipc_perm->__seq to match upstream
xbjfk May 3, 2025
5c17c0d
ci: add quotes to URL in install-musl.sh script
xbjfk May 5, 2025
e3c6d0d
triagebot: Set `issue-links.check-commits = false`
tgross35 May 4, 2025
3db74e3
linux: add new flags for pwritev2/preadv2
the8472 May 11, 2025
40c1f31
adding SO_SPLICE socket option support for freebsd >= 14.2
devnexen May 10, 2025
28e6ae2
Run `cargo fmt` from the workspace root
tgross35 May 13, 2025
a2189ad
ci: Run `cargo fmt` for the entire workspace
tgross35 May 13, 2025
3b98e7d
ci: Don't exclude `ctest/`
tgross35 May 13, 2025
6e35339
Enable libc-test for AIX and fix definitions/declarations.
Mar 18, 2025
b697133
Cleanup IOCTL definitions in linux_like tree
jjanowsk Apr 15, 2025
a64612f
Add arc4random and arc4random_buf to NuttX
no1wudi May 28, 2025
00c1999
Add constants from linux/cn_proc.h and linux/connector.h
Bben01 Apr 30, 2025
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
31 changes: 30 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ jobs:
- name: Check style
run: ./ci/style.sh

clippy:
name: Clippy on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-14, windows-2022]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@v2
# Here we use the latest stable Rust toolchain already installed by GitHub
# Ideally we should run it for every target, but we cannot rely on unstable toolchains
# due to Clippy not being consistent between them.
- run: cargo clippy --workspace --exclude libc-test --exclude ctest-test --all-targets -- -D warnings

# This runs `cargo build --target ...` for all T1 and T2 targets`
verify_build:
name: Verify build
Expand Down Expand Up @@ -180,6 +196,18 @@ jobs:
env:
RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64
artifact-tag: offset-bits64
- target: aarch64-unknown-linux-musl
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
- target: arm-unknown-linux-musleabihf
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
- target: i686-unknown-linux-musl
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
- target: loongarch64-unknown-linux-musl
env:
RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1
# FIXME(ppc): SIGILL running tests, see
# https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713
# - target: powerpc-unknown-linux-gnu
Expand Down Expand Up @@ -258,7 +286,8 @@ jobs:
- test_tier2
- test_tier2_vm
- verify_build
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
- clippy
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
if: always() # make sure this is never "skipped"
Expand Down
27 changes: 27 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,30 @@ members = [
"ctest",
"libc-test",
]

# FIXME(msrv): These should be renamed as `[workspace.lints.*]` once MSRV is above 1.64
# This way all crates can use it with `[lints] workspace=true` section

[lints.rust]
# FIXME(cleanup): make ident usage consistent in each file
unused_qualifications = "allow"

[lints.clippy]
# Enable pedantic lints - use this manually once in a while, but don't enable by default
# pedantic = { level = "warn", priority = -1 }

# We are okay with the current state of these lints
explicit_iter_loop = "warn"
identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops
manual_assert = "warn"
map_unwrap_or = "warn"
missing_safety_doc = "allow" # safety? in libc? seriously?
non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this
ptr_as_ptr = "warn"
unnecessary_semicolon = "warn"

# FIXME(clippy): these should be fixed if possible
expl_impl_clone_on_copy = "allow"
uninlined_format_args = "allow"
unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets
used_underscore_binding = "allow"
54 changes: 32 additions & 22 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{env, str};
// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we
// need to know all the possible cfgs that this script will set. If you need to set another cfg
// make sure to add it to this list as well.
const ALLOWED_CFGS: &'static [&'static str] = &[
const ALLOWED_CFGS: &[&str] = &[
"emscripten_old_stat_abi",
"espidf_time32",
"freebsd10",
Expand All @@ -22,10 +22,11 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
"libc_ctest",
// Corresponds to `__USE_TIME_BITS64` in UAPI
"linux_time_bits64",
"musl_v1_2_3",
];

// Extra values to allow for check-cfg.
const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[
(
"target_os",
&[
Expand Down Expand Up @@ -89,6 +90,13 @@ fn main() {
_ => (),
}

let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok();
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3");
// loongarch64 and ohos have already updated
if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" {
// FIXME(musl): enable time64 api as well
set_cfg("musl_v1_2_3");
}
let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok();
println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64");
if linux_time_bits64 {
Expand Down Expand Up @@ -130,17 +138,17 @@ fn main() {
if rustc_minor_ver >= 80 {
for cfg in ALLOWED_CFGS {
if rustc_minor_ver >= 75 {
println!("cargo:rustc-check-cfg=cfg({})", cfg);
println!("cargo:rustc-check-cfg=cfg({cfg})");
} else {
println!("cargo:rustc-check-cfg=values({})", cfg);
println!("cargo:rustc-check-cfg=values({cfg})");
}
}
for &(name, values) in CHECK_CFG_EXTRA {
let values = values.join("\",\"");
if rustc_minor_ver >= 75 {
println!("cargo:rustc-check-cfg=cfg({},values(\"{}\"))", name, values);
println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))");
} else {
println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values);
println!("cargo:rustc-check-cfg=values({name},\"{values}\")");
}
}
}
Expand Down Expand Up @@ -169,12 +177,11 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output {

let output = cmd.output().expect("Failed to get rustc version");

if !output.status.success() {
panic!(
"failed to run rustc: {}",
String::from_utf8_lossy(output.stderr.as_slice())
);
}
assert!(
output.status.success(),
"failed to run rustc: {}",
String::from_utf8_lossy(output.stderr.as_slice())
);

output
}
Expand All @@ -201,9 +208,11 @@ fn rustc_minor_nightly() -> (u32, bool) {

let mut pieces = version.split('.');

if pieces.next() != Some("rustc 1") {
panic!("Failed to get rustc version");
}
assert_eq!(
pieces.next(),
Some("rustc 1"),
"Failed to get rustc version"
);

let minor = pieces.next();

Expand All @@ -213,9 +222,9 @@ fn rustc_minor_nightly() -> (u32, bool) {
// since a nightly build should either come from CI
// or a git checkout
let nightly_raw = otry!(pieces.next()).split('-').nth(1);
let nightly = nightly_raw
.map(|raw| raw.starts_with("dev") || raw.starts_with("nightly"))
.unwrap_or(false);
let nightly = nightly_raw.map_or(false, |raw| {
raw.starts_with("dev") || raw.starts_with("nightly")
});
let minor = otry!(otry!(minor).parse().ok());

(minor, nightly)
Expand Down Expand Up @@ -266,8 +275,9 @@ fn emcc_version_code() -> Option<u64> {
}

fn set_cfg(cfg: &str) {
if !ALLOWED_CFGS.contains(&cfg) {
panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg);
}
println!("cargo:rustc-cfg={}", cfg);
assert!(
ALLOWED_CFGS.contains(&cfg),
"trying to set cfg {cfg}, but it is not in ALLOWED_CFGS",
);
println!("cargo:rustc-cfg={cfg}");
}
4 changes: 2 additions & 2 deletions ci/install-musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ case ${1} in
musl_version=1.2.5
;;
*)
musl_version=1.1.24
[ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && musl_version=1.2.3 || musl_version=1.1.24
;;
esac

musl="musl-${musl_version}"

# Download, configure, build, and install musl:
curl --retry 5 https://www.musl-libc.org/releases/${musl}.tar.gz | tar xzf -
curl --retry 5 "https://www.musl-libc.org/releases/${musl}.tar.gz" | tar xzf -

cd "$musl"
case ${1} in
Expand Down
4 changes: 2 additions & 2 deletions ci/ios/deploy_and_run_on_ios_simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::process::Command;
macro_rules! t {
($e:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with: {}", stringify!($e), e),
Err(e) => panic!("{} failed with: {e}", stringify!($e)),
})
}

Expand Down Expand Up @@ -143,7 +143,7 @@ trait CheckStatus {

impl CheckStatus for Command {
fn check_status(&mut self) {
println!("\trunning: {:?}", self);
println!("\trunning: {self:?}");
assert!(t!(self.status()).success());
}
}
Expand Down
4 changes: 2 additions & 2 deletions ci/runtest-android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ fn main() {
let stderr = String::from_utf8_lossy(&output.stderr);

println!(
"status: {}\nstdout ---\n{}\nstderr ---\n{}",
output.status, stdout, stderr
"status: {}\nstdout ---\n{stdout}\nstderr ---\n{stderr}",
output.status,
);

if !stderr.lines().any(|l| {
Expand Down
18 changes: 11 additions & 7 deletions ci/style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ while IFS= read -r file; do

# Turn all braced macro `foo! { /* ... */ }` invocations into
# `fn foo_fmt_tmp() { /* ... */ }`.
perl -pi -e 's/(?!macro_rules)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file"
perl -pi -e 's/(?!macro_rules|c_enum)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file"

# Replace `if #[cfg(...)]` within `cfg_if` with `if cfg_tmp!([...])` which
# `rustfmt` will format. We put brackets within the parens so it is easy to
Expand Down Expand Up @@ -59,12 +59,9 @@ done < "$tmpfile"

rm "$tmpfile"

if shellcheck --version ; then
find . -name '*.sh' -print0 | xargs -0 shellcheck
else
echo "shellcheck not found"
exit 1
fi
# Run once from workspace root to get everything that wasn't handled as an
# individual file.
cargo fmt

# Ensure that `sort` output is not locale-dependent
export LC_ALL=C
Expand All @@ -87,3 +84,10 @@ for file in libc-test/semver/*.txt; do
exit 1
fi
done

if shellcheck --version ; then
find . -name '*.sh' -print0 | xargs -0 shellcheck
else
echo "shellcheck not found"
exit 1
fi
7 changes: 7 additions & 0 deletions libc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@ harness = true
name = "style_tests"
path = "test/style_tests.rs"
harness = true

# FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]`
# once MSRV is above 1.64 and replaced with `[lints] workspace=true`

[lints.rust]

[lints.clippy]
Loading
Loading