-
-
Notifications
You must be signed in to change notification settings - Fork 39.4k
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
added support for compiling source with -flto option disabled. #7089
Conversation
Some source code (eg helix-serial.c) is sensitive to execution timing and will not work as expected when compiled with the -flto option. This commit adds the ability to specify the -fno-lto option for specific source code in tmk_core/rules.mk. Usage: file: keybaord,keymap,others rules.mk ``` SRC += timing_sensitive_code.c ``` change to ``` SRC += timing_sensitive_code.c/NO-LTO ``` There is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
There is no change in the build result.
@mtei as we currently use |
Of course, I know QUANTUM_LIB_SRC and LIB_SRC. Because it was my contribution. (#4522) LIB_SRC is for automatically selecting whether a link is required. Certainly, the source specified by LIB_SRC is compiled with -fno-lto. But that's just a side effect. It is not the main purpose of LIB_SRC. I believe there must be a way to explicitly specify compiling with -fno-lto. For example, when
|
Is there a specific/technical reason that I mean, if And to clarify, I'm not trying to be mean, shoot the contribution down, or anything like that. I want to understand why, since I don't have a clear understanding of some of this, and would like to be able to understand what is going on, so I can explain it to others, myself (if/when the need arises). |
Currently, the source specified by LIB_SRC is compiled with qmk_firmware/tmk_core/rules.mk Line 37 in f64d9b0
If we comment out this, it will look like this:
As you can see in the message above, avr-ar does not currently support lto objects. In the future, if avr-ar will support lto objects as standard, it will not be necessary to add This is why we need a way to explicitly specify |
There is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
When LINK_TIME_OPTIMIZATION_ENABLE=no, there is no change in the build result.
…-lto" This reverts commit 19dc347.
Okay, to see if I understand this correctly... The This makes the compilation cleaner, and more intelligent. RIght now, those also assume Ideally, stuff like the If that's correct, awesome, and I think this would be a good change. I was just having a hard time understanding why this was a good change, or why it was needed. Thank you for taking the time and effort to explain this! |
I'm glad you understood.
That is correct. In addition, in the following example, lib_d.a is linked if any of a.o, b.o or c.o calls a function in lib_d.a. Otherwise, lib_d.a will not be linked.
The link order is as follows.
|
|
This reverts commit 75da167.
Changed to use Currently, https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ffat-lto-objects |
This has merge conflicts. |
Now that I've looked at this closer
If this is the case, then the places where But it sounds like we don't have a If that's the case, that may be a blocker to getting this merged |
I'd like to break this PR down into a few PRs. This should make it easier to verify each one. I'm going to do it when I have more time. |
Sounds good! Smaller PRs are easier to review, especially for how complex MAKE stuff is! |
@mtei, would you like to leave this PR open or can it be closed? |
Now I'm getting ready to split up this PR and reopen a new one. Hold on a moment. |
Converted to draft so that someone doesn't decide to have a bright idea and attempt to merge. |
Description
Some source code (eg helix-serial.c) is sensitive to execution timing and will not work as expected when compiled with the -flto option.
This commit adds the ability to specify the -fno-lto option for specific source code in tmk_core/rules.mk.
Usage:
file: keybaord, keymap, others rules.mk
change to
This commit does not change the build results.Postscript
Currently there are keyboards that use LIB_SRC or QUANTUM_LIB_SRC to specify -fno-lto. But this is not correct.
Currently, the file specified in LIB_SRC and QUANTUM_LIB_SRC is compiled with -fno-lto, but this is only a workaround for the 'ar' command not supporting lto object. If the 'ar' command supports lto objects, this action is gone.With this PR change, LIB_SRC, QUANTUM_LIB_SRC no longer means adding
-fno-lto
.Types of Changes
Checklist