Skip to content
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

Bring LTO support to NCS #1535

Merged
merged 21 commits into from
Feb 27, 2024
Merged

Bring LTO support to NCS #1535

merged 21 commits into from
Feb 27, 2024

Conversation

kapi-no
Copy link
Contributor

@kapi-no kapi-no commented Feb 26, 2024

Cherry-pick attempt to bring the LTO feature from zephyr upstream to NCS

Base PRs:
zephyrproject-rtos/zephyr#66392
zephyrproject-rtos/zephyr#68530

  • Some additional fromtree commits added on top of the zephyr/scripts/build/gen_isr_tables.py script to avoid conflicts

rakons and others added 13 commits February 26, 2024 17:08
This commit adds missing __used attribute it int_list_header,
preventing it from being optimized out.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 717c583)
…RD_LVL_INTERRUPTS

The calculation of `THIRD_LVL_INTERRUPTS` bitmask in the
`update_masks()` function is wrong, the number of bits to shift
should be the sum of the first two levels.

Signed-off-by: Yong Cong Sin <[email protected]>
(cherry picked from commit 56570cc)
…sk variables

Rename the bitmask variables from `*_LVL_INTERRUPTS` to
`INTERRUPT_LVL_BITMASK[]` array to be consistent with
`INTERRUPT_BITS`, making it easier to loop over the bitmasks.

Signed-off-by: Yong Cong Sin <[email protected]>
(cherry picked from commit b4db285)
Add some debug prints for the interrupts bits and bitmasks
in each level.

Signed-off-by: Yong Cong Sin <[email protected]>
(cherry picked from commit 0884a33)
When using direct isrs, a vector table is needed. However, if none is
present , i.e. `CONFIG_GEN_IRQ_VECTOR_TABLE=n`, this script failed. The
given error message was not helpful (`'NoneType' has no len()`).
This change makes it clearer, where to look for the problem.

Signed-off-by: Greter Raffael <[email protected]>
(cherry picked from commit 7bcd069)
…entry as comment

Make it easier to debug by printing the index number at the
end, this is especially helpful when there's a lot of
interrupts.

Before:

```c
/* build/zephyr/isr_tables.c */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)},
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)},
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)},
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)},
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)},
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)},
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)},
```

After:

```c
/* build/zephyr/isr_tables.c */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)}, /* 0 */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)}, /* 1 */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)}, /* 2 */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)}, /* 3 */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)}, /* 4 */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)}, /* 5 */
{(const void *)0x0, (ISR)((uintptr_t)&z_irq_spurious)}, /* 6 */
```

Signed-off-by: Yong Cong Sin <[email protected]>
(cherry picked from commit 89fb8f8)
This commit cleans up the gen_isr_tables code for better clarity
and easier modification.
Changes include:
- Separate functions to load intList section.
- Replace spurious handlers in internal data with None.
  Now it is the output generator work to choose right function.
- All the work to generate vt and swt separated into its own functions.
- Remove the need for internal shared array - all the information
  is here in swt array.
- The update_masks function - more functionality moved here.
- Simplify bit_mask function.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 4360acb)
This commit breaks the code into functional classes.
This way the functionality is visibly splitted into
functional parts and it is easier to replace the
specific parser part to implement new code generators.

There is also common functionality to handle multi level interrupts
moved to configuration class.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 568cced)
This commit updates the definition of z_shared_isr_table_entry
to use _isr_table_entry instead of specially created z_shared_isr_client.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit b0c83f3)
…neration

This commit moves all the functionality related to the current
interrupt parser into gen_isr_tables_parser_carrays.py file.
The new parser file gen_isr_tables_parser_local.py file is
implemented with the new parser that.
Additional information added to the generated interrupt header
that contains data required by the new parser.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 0ae48ec)
…try creation

This commit implements the possibility to locally create an interrupt
table entry. This changes the way interrput table is created,
now it should not be created as an source file but rather it would be
constructed by the linker.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 13638a0)
…declaration

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 <[email protected]>
(cherry picked from commit 19bb21e)
…laration.

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 <[email protected]>
(cherry picked from commit 8174c7e)
This commit updates the arm and arm64 architecture files
to support the new ISR handlers creation parser.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 1ff24b3)
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 <[email protected]>
(cherry picked from commit 664319f)
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 <[email protected]>
(cherry picked from commit 8f98b8b)
…tables declaration

This commit adds configurations to test local ISR tables declaration.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 3799b93)
This commit adds option to enable Link Time Optimization.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 26c8776)
This commit enables some kernel tests with
Link Time Optimization enabled.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 53becb0)
…required

This commit removes the need of swi_tables.ld file if the
ISR table generator is not configured to use it.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit adaacef)
…ludes

This fix removes the zephyr/ prefix from linker included files.
With this prefix the build works only for Ninja and not for
other build tools.

Linking in Zephyr / CMake:
 - Ninja invokes linking directly from <build>.
 - Make invokes linking form <build>/zephyr.

The linker default uses cwd for looking up INCLUDE directives if not found
in list of includes.
Zephyr always adds <build>/zephyr as link include using CMake,
and this is passed to ld as -L<build>/zephyr therefore using
INCLUDE isr_tables_swi.ld ensures it will be correctly found in all cases.

Signed-off-by: Radosław Koppel <[email protected]>
(cherry picked from commit 08070fb)
@rakons
Copy link
Contributor

rakons commented Feb 27, 2024

This may be worth adding too: zephyrproject-rtos/zephyr#69519 -> @LuDuda

@kapi-no kapi-no requested a review from LuDuda February 27, 2024 14:28
@LuDuda
Copy link
Contributor

LuDuda commented Feb 27, 2024

Testing it right now. But if one more rebase / CI run is needed anyway, i would consider to include above commits :) Else we may need to do it in a subsequent PR.

Copy link
Contributor

@LuDuda LuDuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Let's merge this. And follow up with Radek's addition as it allows also to build Matter samples.

@kapi-no kapi-no added this to the ncs-2.6.0 milestone Feb 27, 2024
@carlescufi carlescufi merged commit efdefef into nrfconnect:main Feb 27, 2024
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants