-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
LTO-compatible ISRs #66392
LTO-compatible ISRs #66392
Conversation
8bf86a3
to
e57a80a
Compare
Added alignments to generated linker script. |
thanks @rakons for the effort here. I'll be a bit slow to review just due to outside constraints. First brief look this appears to be going in the right direction, so thanks again for the effort here! |
Currently I am including zephyr/isr_tables.ld when we are on final build step. This is not correct. I suppose I should include in any step beyond pre0.
And having 3 passes I get:
Then having 2 passes I get:
What surprises me is the LINKER_DEVICE_DEPS_PASS1 definition for pre0 file. Is that correct? How should I handle it to include the required file in compiler command script excluding pre0? |
e57a80a
to
99649d8
Compare
Last push - split the generated linker files to hardware vectors and swi (+shared) related parts. Include it in the right (?) places in the build system. |
99649d8
to
0e61f60
Compare
Script errors fixes |
0e61f60
to
607986a
Compare
Another fix of the script errors |
607986a
to
53e3326
Compare
Rebase (with a lot of manual work). |
53e3326
to
98966ea
Compare
Fix code issues reported during Compliance checks |
e322894
to
7a1c55a
Compare
@rakons would you mind adding a section in the PR description explaining why this rework is required for LTO? Essentially a problem statement. |
a93adda
to
4de4efa
Compare
Fixed the issue of data alignment in intList section when 64bit architecture is selected without optimization. |
Last commit makes it even worse - using file name and the line number would not work as expected for the interrupts that are connected by DT_INST_FOREACH_STATUS_OKAY - and we are doing it all around the code. |
Now it seems that I am still experiencing an issue that there appear the properly placed interrupt vectors from sections that we required, but also - the vectors from arch/common/isr_tables.c - that is reported as an error on some compilations as the space for interrupt vectors is overflowed. |
d49fa9d
to
cd2fefc
Compare
This commit adds a documentation about the new parser of the interrupt vectors tables that is using linker to construct the arrays with all the runtime required data. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit changes the way how ARCH_IRQ_DIRECT_CONNECT is defined. Now it uses Z_ISR_DECLARE_DIRECT internally. That is a requirement for local isr declaration. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit updates the arm and arm64 architecture files to support the new ISR handlers creation parser. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
Make IDT_LIST section bigger to fit bigger interrupt description. Note: This section would be removed from final build. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit updates nordic lll controller to use IRQ_DIRECT_CONNECT where applicable instead of using IRQ_CONNECT with ISR_FLAG_DIRECT. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit adds configurations to test local ISR tables declaration. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit adds option to enable Link Time Optimization. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
This commit enables some kernel tests with Link Time Optimization enabled. Signed-off-by: Radosław Koppel <radoslaw.koppel@nordicsemi.no>
eb4d9f6
to
2f86480
Compare
Rebase - west.yml no longer needs to be updated as now current hal_nxp contains the required commit. |
The compliance check, the one error here is false positive. Too much similar lines in two parsers. |
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.
Still gives me the ick to be rushing on this, but I can't see a reason not to merge. Holding my breath and clicking +1.
Git bisect for the breakage on |
@rakons This has already been merged, but please raise a separate PR clearly describing these changes in the release notes. It's an important change and needs highlighting. |
@@ -805,6 +810,10 @@ target_include_directories(${OFFSETS_LIB} PRIVATE | |||
kernel/include | |||
${ARCH_DIR}/${ARCH}/include | |||
) | |||
|
|||
# Make sure that LTO will never be enabled when compiling offsets.c | |||
set_source_files_properties(${OFFSETS_C_PATH} PROPERTIES COMPILE_OPTIONS $<TARGET_PROPERTY:compiler,prohibit_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.
This breaks old compilers:
xt-xcc ERROR parsing -fno-lto: unknown flag
@tejlmand how can we test this flag first, any good example to follow?
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.
Tentative fix submitted in #69058
Hi @rakons, |
A big rebuild of the zephyr interrupt system.
Things that was done:
How it works:
NOTE:
The implementation is mostly functional, but there are still a few things to do:
But anyway - it is good enough to be used as long as you are not using shared interrupts. The code relocation for secure build may fail also.
For the time being please treat it as a proof of concept that I wish to finalize.
To compile the code using new parser please add
-DCONFIG_ISR_TABLES_LOCAL_DECLARATION=y
parameter to the build. For example, from samples/hello_world directory:Why do we need this change
Currently for the ISR handlers generation, before zephyr_final stage (in single or in both pre linking stages), the gen_isr_tables.py script is used (zephyr/scripts/build/gen_isr_tables.py) that is using the data from “.isrList” sections and creates required interrupt tables into [build]/zephyr/isr_tables.c that usually looks similar to the code below:
Then the generated isr_tables.c file is compiled and linked together with the rest of the code to get zephyr_final binaries.
The main problem with the approach above is that the creates arrays is composed mainly from the direct addresses of the interrupt functions. Also the argument for software interrupt table is provided as a number that may be any type - it might be and address of IO register or may be pointer to the function or address of some object in the code. This makes it very hard to translate it into usable handler to let the linker the knowledge what object is really used.
As during linking with LTO enabled the addresses of the objects may change this approach is unusable in such configuration.
This does not mean that using LTO directly with current solution would not work. It is just risky. It means - it might work, but small change in the code may break it.
Solid solution does not lost information during compilation - in this case, such lost information is the connection between objects. Changing the object into a raw address makes linker not conciseness about the connection. The goal of the proposed solution is to preserve this information during the whole process of generation of the binary file.