-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add LTO cache, customize LTO settings for tests #1513
Conversation
simone-gaia
commented
May 10, 2022
- The LTO cache seems to give good results.
- The custom params for tests seem not working for now, but is good to leave the option there for when this question is answered: https://stackoverflow.com/questions/72190379/lld-runs-lto-even-if-fno-lto-is-passed
production/cmake/gaia_internal.cmake
Outdated
|
||
# Enable Thin LTO only on non-test targets. | ||
if(ENABLE_LTO) | ||
if (IS_TEST) |
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.
Remove space after if
.
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.
Also on line 38 above.
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.
Done.
production/cmake/gaia_internal.cmake
Outdated
set(IS_TEST true) | ||
endif() | ||
|
||
# TODO: this is currently useless because LLD perform LTO on tests even with -fno-lto |
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.
Shouldn't this comment be placed inside the if (IS_TEST)
block below? Otherwise, it's confusing what "this" is supposed to refer to.
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.
Done.
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.
Left some notes on small issues.
So I wonder if the problem with Did you verify the order of |
The test compile/link commands do not have the lto setting at all, besides |
Also, have you looked at using the |
Hmm, looks like |
Oh, one more thing I forgot to ask before: shouldn't we enable LTO only in release builds? At least I can't think of any reason to enable it for debug builds... |
Just tried and seems to be the same as
Done. |
@@ -48,6 +48,14 @@ if (NOT ENABLE_CLANG_TIDY) | |||
endif() | |||
endif() | |||
|
|||
if (NOT DEFINED ENABLE_LTO) | |||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
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.
This reads strangely. Why would clang-tidy settings ever be dependent on LTO settings?
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.
Oops.
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.
Fixed.
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, as long as disabling LTO behaves as expected. If not, we can just leave LTO off by default and use it only for SDK builds or perf tests (possibly combining ENABLE_LTO=ON
with DISABLE_ASSERTS=ON
).
Not much to add except if you want to go ahead and make the change for building the SDK with LTO I suggest adding the following:
Or something similar to that. |
Will do it in a separate PR. Thanks for the tip. |