-
Notifications
You must be signed in to change notification settings - Fork 428
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
Don't clobber existing CMAKE_CXX_FLAGS_RELEASE #7742
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/7742
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 37114d8 with merge base cd0e584 (): NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") | ||
endif() | ||
|
||
option(OPTIMIZE_SIZE "Build executorch runtime optimizing for binary size" OFF) | ||
if(OPTIMIZE_SIZE) | ||
# -Os: Optimize for size | ||
set(CMAKE_CXX_FLAGS_RELEASE "-Os ${CMAKE_CXX_FLAGS_RELEASE}") |
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.
It's pretty typical to put the overridable CMAKE_CXX_FLAGS_RELEASE last so it can override -Os
/-O2
if users want to; the new order will always override whatever CMAKE_CXX_FLAGS_RELEASE says. But if that's the intent (like the PR description says), then this seems to do it.
But since this is an unusual pattern, please update the comments on these two cases to clarify that we're intentionally overriding the -O
flag so that someone doesn't come back and "fix" it.
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.
someone doesn't come back and "fix" it.
I would be happy for someone to come back and change this further; these two OPTIMIZE_SIZE
changes were to preserve existing behavior.
Before: we clobber all of CMAKE_CXX_FLAGS_RELEASE on line 152 above.
After: we only clobber the -O
setting with -Os
or -O2
.
I think our setup is deeply weird and OPTIMIZE_SIZE
shouldn't exist; I am just following general good practice by sending an incremental diff that makes a small amount of forward progress rather than attempting to fix everything all at once.
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.
After: we only clobber the -O setting with -Os or -O2.
Agreed that it's an improvement. But someone a year from now who's only looking at this line might think "why is -Os last? I'll move it back before the ${CMAKE_CXX_FLAGS_RELEASE}
". A comment would help avoid that.
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.
I'm hesitant to enshrine behavior I think is wrong and simply haven't gotten around to fixing yet.
We were likely losing -DNDEBUG. Preserve our current intent to clobber the -O flag in particular, though.
We were likely losing -DNDEBUG. Preserve our current intent to clobber the -O flag in particular, though.
We were likely losing -DNDEBUG. Preserve our current intent to clobber the -O flag in particular, though.