-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
cmake: Improve library dependencies by removing whole-archive, start/end-group #8441
Comments
Would you mind splitting the "many libraries causes noise in IDE's" out into it's own issue? EDIT: If we split that out then this issue will solely be about the problems that arise from the |
Fixes: zephyrproject-rtos#8851 zephyrproject-rtos#8441 This commit updates the handling of memory location for libraries in Zephyr during linking. This is needed in order to be able to add libraries after ZEPHYR_LIBS_PROPERTY has been used in CMake. It introduces a generic zephyr_set_property function which can be extended in future. At start is supports the property: - MEMORY_SPACE kernel which can be used to control memory space location for libraries when KConfig setting CONFIG_APPLICATION_MEMORY is enabled. Signed-off-by: Torsten Rasmussen <[email protected]>
Issues: zephyrproject-rtos#8441 zephyrproject-rtos#8851 As part of whole-archive removal it is important to specify correct library dependencies and link ordering for the core libraries, i.e kernel and arch libs. To facilitate and handling of circular dependencies an zephyr_app_linking INTERFACE library is constructed. Any library linked to the zephyr_app_linking interface lib will be use during final linking stage. Using an interface library over a list has the advantage that libraries can be added as dependency after the final link command is constructed and hence remove any parsing ordering in CMake. Signed-off-by: Torsten Rasmussen <[email protected]>
RFC for zephyrproject-rtos#8441 The RFC creates fewer libraries and uses CMake link libraries commands to utilize CMake dependency handling - subsys bluetooth has been converted into a single library - subsys network has been converted into a single library It uses the populate source list presented in: zephyrproject-rtos#8442 Signed-off-by: Torsten Rasmussen <[email protected]>
Issue: zephyrproject-rtos#8441 Setting memory space property on subsys_net and subsys_bluetooth libraries. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#8441 This commit merges the multiple sub libraries under soc_arm and arch_arm, e.g. arch_arm_Y_Z into a single arch_arm libraries. It also moves arch related stray files from libzephyr.a and places them inside the arch_${ARCH} and soc_${ARCH} library, see zephyrproject-rtos#8826. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#8441 This commit merges the multiple sub libraries under soc_arc and arch_arc, e.g. arch_arc_Y_Z into a single arch_arc libraries. It also moves arch related stray files from libzephyr.a and places them inside the soc_${ARCH} and arch_${ARCH} library, see zephyrproject-rtos#8826. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#8441 This commit merges the multiple sub libraries under soc_nios2 and arch_nios2, e.g. arch_nios2_Y_Z into a single arch_nios2 libraries. It also moves arch related stray files from libzephyr.a and places them inside the arch_${ARCH} library, see zephyrproject-rtos#8826. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#8441 This commit merges the multiple sub libraries under soc_posix and arch_posix, e.g. arch_posix_Y_Z into a single arch_posix libraries. It also moves arch related stray files from libzephyr.a and places them inside the arch_${ARCH} library, see zephyrproject-rtos#8826. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#8441 This commit merges the multiple sub libraries under soc_riscv32 and arch_riscv32, e.g. arch_riscv32_Y_Z into a single arch_riscv32 libraries. It also moves arch related stray files from libzephyr.a and places them inside the arch_${ARCH} library, see zephyrproject-rtos#8826. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#8441 This commit merges the multiple sub libraries under soc_xtense and arch_xtensa, e.g. arch_xtensa_Y_Z into a single arch_xtensa libraries. It also moves arch related stray files from libzephyr.a and places them inside the arch_${ARCH} library, see zephyrproject-rtos#8826. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#8441 This commit merges the multiple sub libraries under soc_x86 and arch_x86, e.g. arch_x86_Y_Z into a single arch_x86 libraries. It also moves arch related stray files from libzephyr.a and places them inside the arch_${ARCH} library, see zephyrproject-rtos#8826. Signed-off-by: Torsten Rasmussen <[email protected]>
Issue: zephyrproject-rtos#8441 Setting memory space property on arch_${ARCH} libraries. Signed-off-by: Torsten Rasmussen <[email protected]>
RFC for zephyrproject-rtos#8441 The RFC creates fewer libraries and uses CMake link libraries commands to utilize CMake dependency handling - drivers has been converted into a single library It uses the populate source list presented in: zephyrproject-rtos#8442 Signed-off-by: Torsten Rasmussen <[email protected]>
Issue: zephyrproject-rtos#8441 Setting memory space property on drivers library. Signed-off-by: Torsten Rasmussen <[email protected]>
Issue: zephyrproject-rtos#8441 To reduce number of libraries a libc library is created to which other libs can link to (default linked through zephyr_interface). Signed-off-by: Torsten Rasmussen <[email protected]>
Issue: zephyrproject-rtos#8441 This commit remove the app and zephyr libraries from the ZEPHYR_LIBS_PROPERTY. Signed-off-by: Torsten Rasmussen <[email protected]>
RFC for zephyrproject-rtos#8441 The commit creates a single board libary for sources under the board folder in Zephyr as part of zephyrproject-rtos#8441 It uses the populate source list presented in: zephyrproject-rtos#8442 Signed-off-by: Torsten Rasmussen <[email protected]>
Issue zephyrproject-rtos#8441 This commits updates the following areas a creates specific libraries. Libraries updated. - subsys usb has been converted into a single library - subsys mgmt has been converted into a single library - subsys fs has been converted into a single library - subsys app_memory has been converted into a single library - ztest update to single lib and specifying linker flag for test_main Signed-off-by: Torsten Rasmussen <[email protected]>
Issue zephyrproject-rtos#8441 This commits updates the following areas a creates specific libraries. Libraries updated. - lib/posix is a single library - lib/json is still a normal cmake constructed library - lib/cmsis_rtos is still a normal cmake constructed library Signed-off-by: Torsten Rasmussen <[email protected]>
RFC for zephyrproject-rtos#8441 The commit creates a single openthread_platform library for sources under net/lib/openthread/platform folder in Zephyr as part of zephyrproject-rtos#8441 It uses the populate source list presented in: zephyrproject-rtos#8442 Signed-off-by: Torsten Rasmussen <[email protected]>
Hi @tejlmand, This issue, marked as an Enhancement, was opened a while ago and did not get any traction. It was just assigned to you based on the labels. If you don't consider yourself the right person to address this issue, please re-assing it to the right person. Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason. @tejlmand you are also encouraged to help moving this issue forward by providing additional information and confirming this request/issue is still relevant to you. Thanks! |
Zephyr subsystems creates multiple (sub-)sublibraries, especially bluetooth and
net. Those subsystems also has internal dependencies to each other.
Multiple subsystems in Zephyr has a lot of sub libraries, which I believe
should be minimized, especially a KConfig is good for configuring the libraries.
Subsystem Bluetooth contains:
subsys_bluetooth, subsys__bluetooth__common, subsys__bluetooth__controller,
subsys__bluetooth__host__mesh, subsys__bluetooth__host
Subsystem net contains:
subsys__net, subsys__net_ip, subsys__net_ip_l2, subsys__net_ip_l2_ethernet,
subsys__net_ip_l2_ieee802154, subsys__net_ip_l2_openthread,
subsys__net__lib__app, subsys__net__lib__dns, subsys__net__lib__http,
subsys__net__lib__lwm2m, subsys__net__lib__mqtt, subsys__net__lib__websocket
Zephyr links everything together using -Wl,--start-group
-Wl,--end-group, as well as Zephyr build system uses
-Wl,--whole-archive.
This principle has several drawbacks;
The -Wl,--whole-archive drawback is also described in: #6961
Creating executables in this manner requires extra build scripts and
is non-standard for a CMake project. Instead of using the CMake API
to link together libraries into an executable with
target_link_libraries() one must have build scripts that ensures the
linker is passed this list of linker flags.
It introduces two kinds of libraries, instead of having just one kind.
Libraries which must be whole-archived, and libraries that should not.
There is also a theoretical code size performance impact. If
whole-archive is used and there exists an object file in a library
that happens to not be in use (dead code) the object file will still
be included in the executable, instead of being pruned as one would
want it to be. But if one links without '--whole- archive' only the
object files that have symbols needed by the link will be used.
In Zephyr, the handling of library content is well handled using
KConfig, and doesn't seem to suffer from this risk.
However, that doesn't mean the problem may not be present in certain
parts of Zephyr.
Finally, using a flat linking model where all libraries are included
means that we do not have readily available information about how
libraries depend on each other.
CMake list ${ZEPHYR_LIBS_PROPERTY} is furthermore a global variable
to which libraries are added and later used in the linking stage.
Use of global variables should be minimized whenever possible.
EDIT: This is part of umbrella issue: #8827
EDIT: Removed text covered by #8826
The text was updated successfully, but these errors were encountered: