Repository navigation
Conversation
Contributor
|
Did you try enabling compiler_rt? |
Contributor
Author
|
Yes. With .bundle_compiler_rt = true on the ATmega328P, compiler_rt itself fails to build with Zig 0.17.0 (address space 'flash' cannot cast into address space 'generic', ziglang/zig#37090, still open), which is why the AVR ports turn it off. |
Grazfather
reviewed
Oct 14, 2026
Grazfather
left a comment
Collaborator
There was a problem hiding this comment.
- This adds avr-specific comments in a generic driver. I would just say that it avoid using mult instructions. Please test against multiple targets (e.g. wch, esp32c3, rp2040, and atmega328) + disassemble and provide evidence
- Do you see evidence of the
mswasting time storing to the stack and then copying to an arg. I wonder if using a bunch of@as(u64...might avoid this. Again, please test against those targets.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ClockDevice.sleep_mscomputedtime_ms * 1000inu32, which overflows from 4,294,968 ms (about 71.6 minutes): a panic in Debug/ReleaseSafe and illegal behavior in ReleaseFast/ReleaseSmall. This converts inu64instead, still with a singlesleep_uscall.The conversion uses shifts (
1000 = 1024 - 16 - 8) rather than a multiply: on AVR, which doesn't link compiler_rt, a runtimeu32multiply needs__mulsi3and au64one__muldi3, sosleep_mswith a runtime argument (e.g.TLV493D) didn't link there. Checked with Zig 0.17.0, ReleaseSmall, on the ATmega328P: the shift version links and has no multiply calls.Adds a test for 0, 1, the last value that fit, the first that overflowed, and
maxInt(u32); it fails on the current code withinteger overflow.