Skip to content

Remove WHOLE_ARCHIVE_LIBS in ZephyrΒ #82780

@tejlmand

Description

@tejlmand

Is your enhancement proposal related to a problem? Please describe.

WHOLE_ARCHIVE_LIBS was introduced in 321e395 but should not have been approved in the form it was proposed.

Especially Zephyr top-level CMake lists file should not contain deep knowledge of config settings like LLEXT and whether or not Zephyr's kernel lib should be whole-archived.

Generally Zephyr libs should be whole-archived, and vanilla CMake static libs should not.
Any adjustments to this should be handled by the subsystem / module which has requirements for adjusting this principle, for example the llext feature should be able to inform build system that kernel lib should be whole-archived.
For example by adjusting the lib into a zephyr lib, or setting a property on the library.

Relying on a CMake variable (list) is vulnerable to CMake configure time processing and thus is not a good and robust solution.

Describe the solution you'd like

The should not be a CMake list variable trying to contain libs for various reasons, incomplete example list:

  • CMake configure time processing vulnerability
  • List contains all libs, making it harder to adjust properties of a single lib
  • Multiple CMake vars with slight naming differences is general hard to keep track of.
  • Linking vulnerability in CMake as a vanilly CMake static lib being linked by other libs, but also included inside whole-archive may cause CMake to place the lib both inside and outside whole-archive flags.

Instead, each library should have the required knowledge that it needs to be whole-archive, and the link command should then handle proper placement of libs.

With improved linker handling from #78320 and #80621 this should now be easier.

Describe alternatives you've considered
None

Additional context
n/a

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions