time: use C altzone when available - #8357
Conversation
📝 WalkthroughWalkthroughThe host environment now detects CPython-compatible ChangesHost altzone support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Cargo
participant BuildScript as host_env build.rs
participant CCompiler as C compiler
participant HostTime as host_env time::tz
participant PythonTime as Python time module
Cargo->>BuildScript: Run build script
BuildScript->>CCompiler: Compile altzone probe
CCompiler-->>BuildScript: Return compilation status
BuildScript-->>Cargo: Emit has_altzone cfg when supported
PythonTime->>HostTime: Request altzone()
alt has_altzone
HostTime-->>PythonTime: Return native altzone
else fallback
HostTime-->>PythonTime: Return timezone() - 3600
end
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/host_env/build.rs`:
- Around line 21-25: Update the cross-compilation guard in build.rs to detect
target-specific compiler variables supported by cc::Build—CC_<target>,
CC_<target_with_underscores>, and TARGET_CC—before returning. Only skip the
altzone probe when host and target differ and none of these compiler settings
are present; preserve the existing cc::Build compiler resolution afterward.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8279beb4-35d7-49b8-bba8-4514bbf2f0a4
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
crates/host_env/Cargo.tomlcrates/host_env/build.rscrates/host_env/src/time.rscrates/vm/src/stdlib/time.rs
ShaharNaveh
left a comment
There was a problem hiding this comment.
lgtm overall!
tysm:)
youknowone
left a comment
There was a problem hiding this comment.
I like the way hiding dirty part inside hostenv crate.
Let's see if we can handle more flags in this way.
Summary
Fixed an issue where the existing
altzonewas simply calculated astimezone - 3600without checking for the presence ofaltzoneinlibc.During the build process, the code now checks for the existence of
altzoneand implements logic consistent with CPython.Summary by CodeRabbit
time.altzoneaccuracy by using the host-provided native daylight-saving offset when available.