-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
py/obj: Add requirement for 4-byte alignment #18194
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
base: master
Are you sure you want to change the base?
Conversation
36d3d0a to
3fbc357
Compare
|
Code size report: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18194 +/- ##
=======================================
Coverage 98.39% 98.39%
=======================================
Files 171 171
Lines 22276 22276
=======================================
Hits 21918 21918
Misses 358 358 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for the contribution. This check seems quite specific to m68k. Can it be done in a more general way? |
3fbc357 to
728d113
Compare
|
Yes, Updated changes: Add a compile-time static assertion to ensure uPy objects are aligned to at least a 4-byte boundary. Change the MICROPY_OBJ_BASE_ALIGNMENT macro to a numeric value, making it easier to define via CFLAGS in Makefiles. |
Add a compile-time static assertion to ensure uPy objects are aligned to at least a 4-byte boundary. Change the MICROPY_OBJ_BASE_ALIGNMENT macro to a numeric value, making it easier to define via CFLAGS in Makefiles. Signed-off-by: Mike Wang <[email protected]>
728d113 to
08219b5
Compare
|
I didn't expect that all MSVC builds failed due to the new added static assert. |
That might be fixed by #18145 |
I'm not surprised --- there's actually like a dozen cases you need to cover if you want anything to do with alignment in C to be totally portable across all the compilers MicroPython targets. I have a PR that adds proper portable macros for alignment, though, that I proposed a few days ago: Changing |
Summary
This change checks__BIGGEST_ALIGNMENT__and produces a compile-time error if the maximum alignment is less than 4 bytes. On m68k platforms, an additional message advises using-malign-intto enable 4-byte alignment.This ensures correct operation of object tagging schemes that require at least 4-byte alignment.Add a compile-time static assertion to ensure uPy objects are aligned to at least a 4-byte boundary.
Change the MICROPY_OBJ_BASE_ALIGNMENT macro to a numeric value, making it easier to define via CFLAGS in Makefiles.
Reference: https://wiki.debian.org/M68k/Alignment
Related issue: #18183
Testing
Tested on Linux, m68k-linux-gnu-gcc (Debian 14.2.0-19) 14.2.0
Successful build, REPL launched without errors.