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

Optimize Compilation #15

Draft
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

Xeratec
Copy link
Collaborator

@Xeratec Xeratec commented Dec 10, 2024

Changelog

This PR tries to reduce the binary size and improve the debugging functionality of the generated code. One aspect is to separate create function and data sections to allow garbage collection during linking, which significantly reduces the binary size.

Bugs

The separate section works on the object and library level, but somehow the linker merges everything into the .text or .data sections for the final executable and does not keep the individual subsections.

Added

  • Option to disassemble static libraries
  • Create function and data sections
  • Enable linker garbage collection

Changed

Fixed

ToDo

@Xeratec Xeratec self-assigned this Dec 10, 2024
@Xeratec Xeratec force-pushed the pr/optimize_compilation branch from 601b31d to e75301f Compare December 10, 2024 17:26
@Xeratec Xeratec added the enhancement New feature or request label Dec 12, 2024
@Xeratec Xeratec force-pushed the pr/optimize_compilation branch from e75301f to 37d16e0 Compare December 13, 2024 09:57
Copy link
Collaborator

@Scheremo Scheremo left a comment

Choose a reason for hiding this comment

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

Left some comments, looks reasonable overall.

@@ -32,6 +32,7 @@ project(chimera-sdk LANGUAGES C ASM)
set(ABI ilp32)
set(ISA_CLUSTER_SNITCH rv32im)
set(ISA_HOST rv32imc)
set(DISASSEMBLE_LIBRARIES CACHE BOOL OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd argue it almost always makes sense to just provide the objdump for all binaries. If you don't need it you won't feel the overhead, if you need it, you don't want to go digging in the make flow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Disassembling of the libraries is enabled per default. This flag only triggers to also disassemble the static libraries.


target_link_options(${TEST_NAME}
PUBLIC
-Wl,--print-memory-usage
Copy link
Collaborator

Choose a reason for hiding this comment

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

--print-memory-usage is GCC only, irc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since release 17.0.1 it is also would also be supported by the LLD linker. However, with the current flow, we use the LD linker for the LLVM and GCC build flow. Hence, I do not see an issue, and it is tested with the current setup, using toolchain_llvm.cmake.

References:

@Xeratec Xeratec force-pushed the pr/optimize_compilation branch from 37d16e0 to 7f199aa Compare December 19, 2024 08:28
@Xeratec Xeratec force-pushed the pr/optimize_compilation branch from 7f199aa to 96b4a66 Compare December 19, 2024 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants