-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Inline decarations need replacing by static declarations #2232
Comments
Right, I can reproduce this with |
@devsaurus Hi Arnim, AFAIK it's a foible of C89 vs C99. Up to C89 The current gcc generators just generate gobsmackingly good code in general and will often inline any non-forward referenced function if this results in a shorter / faster code sequence. So IMO, we should just substitute static for inline declarations in the few places that we use them. |
Oops sorry; closed in error. Finger trouble and clicked the wrong button. |
The compiler's obviously smart enough (even with the our -Os) to figure out that the vfs wrappers don't have any flesh and declaring them as inline wasn't needed after all 😄 |
|
Should we make |
@devsaurus, there is a increase in the Flash image size, a few % if I recall, but the typical count of unaligned exceptions goes down by over 5x so this is well worth doing. We've already touched on this in #1590 and #2146 (which is where we should address this). |
This patch has already been picked up be @devsaurus so there's no point in keeping this issue open. |
Expected behavior
The application should compile clean if the optimization level is set of O0
Actual behaviour
The link
app/lua
fails on undefinedvfs
references inluaxlib.c
andloadlib.c
Test code
Replace references to O2 by O0 in the root Makefile,
rm -R app/lua/.output
and remake.NodeMCU version
current dev
Root cause
See Stackoverflow: gcc fails to inline functions without -O2. The
app/platform/vfs.h
header uses theinline
, but in In C99, this means that function's definition is provided only for inlining and inlining is not carried out at O0 so the function isnot compiled in. These functions should be declaredstatic
instead ofinline
and the compile will inline them anyway at O2.One for @devsuarus
PS I note that
app/coap/coap.c
,app/coap/coap.c
, andapp/fatfs/myfatfs.c
have the same issue.The text was updated successfully, but these errors were encountered: