-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
lib,py,extmod: Fixes for GCC 15.1 unterminated string literal warning #17269
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
lib,py,extmod: Fixes for GCC 15.1 unterminated string literal warning #17269
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #17269 +/- ##
==========================================
- Coverage 98.54% 98.54% -0.01%
==========================================
Files 169 169
Lines 21898 21896 -2
==========================================
- Hits 21580 21578 -2
Misses 318 318 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Oh clang, why you gotta be so different! |
|
Code size report: |
3186816 to
370850d
Compare
|
Nice that this reduced code size! Not sure why... |
Have switched to use an array initialiser instead, it's too fiddly to keep clang happy and no lose |
Yeah... my best guess is that previously the string literal in moductypes wasn't being de-duplicated, or maybe wasn't de-duplicated during some earlier optimisation pass so less efficient asm was generated. 🤷 |
I think this is the right thing to do in this situation. We've done it in the past for lfs2 code, eg 9269835 |
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1. Also split out the duplicate string to a top-level array (probably the duplicate string literal was interned, so unlikely to have any impact.) This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
Avoids the new Wunterminated-string-literal when compiled with gcc 15.1. It would be preferable to just disable this warning, but Clang -Wunknown-warning-option kicks in even when disabling warnings so this becomes fiddly to apply. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
370850d to
bfd5a03
Compare
dpgeorge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Tested by building mpy-cross, and unix standard and coverage with GCC15.1.1.
I got interested and took a look. Indeed it's as you say, it wasn't deduplicated in an earlier phase and so less optimal machine code was generated. In Eg before this PR: And then with this PR: |
Summary
This PR is a collection of commits to fix MicroPython building under GCC 15.1 (host x86-64 toolchain, follow-up fixes may be necessary in the future for cross-toolchains).
Disable the same warning in LFS1, as that upstream is no longer maintained. (Thanks @DvdGiessen for noting this in py/emitinlinethumb: Use nonstring attribute to suppress compiler warnings #17215 (comment)).lib/littlefs/lfs1.cto use an array initialiser. Patching upstream source (even unmaintained upstream) seems drastic but Clang doesn't ignore-Wno-...warnings for purposes of-Wunknown-warning-option, so it's fiddly to disable it otherwise.Testing
Trade-offs and Alternatives
-Werrorby default (but leaving it on for CI and optionally for developers) would avoid end user build failures caused by newly added warnings. This seems like a good idea but it's a little fiddly to do in a uniform way across MicroPython's many build systems. In any case, addressing the warnings (as in this PR) is still necessary at some point.