◐ Shell
clean mode source ↗

Update libc to `0.2.182` by ShaharNaveh · Pull Request #7247 · RustPython/RustPython

📝 Walkthrough

Walkthrough

Bumps the libc dependency, reorganizes and expands per-target libc symbol imports and cfg gating in the POSIX module, and replaces the hardcoded const-generation script with a TOML-driven, multi-target extraction pipeline that fetches upstream docs and formats generated Rust.

Changes

Cohort / File(s) Summary
Dependency Update
Cargo.toml
Bumped libc from 0.2.1800.2.182.
POSIX libc imports & cfgs
crates/vm/src/stdlib/posix.rs
Reorganized and split libc symbol imports into finer-grained #[cfg(...)] blocks, added/relocated many OS-specific constants (scheduling, file flags, spawn items), introduced FreeBSD SF_* exposures. No public API signatures changed.
Const-generation script
scripts/libc_posix.py
Replaced ad-hoc extraction with a data-driven pipeline: reads Cargo.toml for libc version, fetches upstream docs per-target, extracts constants, groups by cfgs, integrates extras, formats output with rustfmt. Added dataclasses Cfg, Target, helper functions (rustfmt, extract_consts, consts_from_url) and TARGETS configuration.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer / CI
    participant Script as scripts/libc_posix.py
    participant Cargo as Cargo.toml
    participant Remote as Upstream Docs
    participant Rustfmt as rustfmt
    participant Out as Generated Rust (posix.rs)

    Dev->>Script: invoke generation
    Script->>Cargo: read libc version from Cargo.toml
    Script->>Remote: fetch source pages for each TARGET
    Remote-->>Script: return HTML/text
    Script->>Script: extract constants, group by Cfg/Target, attach extras
    Script->>Rustfmt: format generated Rust code
    Rustfmt-->>Script: return formatted code
    Script->>Out: write cfg-tagged Rust blocks into posix.rs
    Script-->>Dev: exit (success or error)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

🐇 I nibble TOML, hop to fetch,
constants gathered, matched to each fetch.
Rustfmt tidies every cfg line,
flags aligned, platforms fine.
A joyful hop — generation's fresh! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update libc to 0.2.182' directly aligns with the main change—a dependency version bump of libc from 0.2.180 to 0.2.182. While the PR includes substantial refactoring of the posix.rs file and the libc_posix.py script, the title focuses on the primary motivating change (the version update), which is appropriate for a concise PR title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.