Skip to content

Conversation

@extinguish
Copy link
Contributor

Summary

  1. Enable -ffunction-sections and -fdata-sections compiler options for Green Hills (GHS) toolchain builds when CONFIG_DEBUG_OPT_UNUSED_SECTIONS is configured.
  2. Adjust Toolchain.defs to apply these optimization flags consistently across all ARM toolchains (outside the GHS exception), improving linker garbage collection behavior.

Impact

  1. Allows Green Hills toolchain users to benefit from section-level dead code elimination, reducing final binary size through linker garbage collection.
  2. Ensures uniform optimization behavior across different ARM toolchains (GCC, Clang, GHS) when CONFIG_DEBUG_OPT_UNUSED_SECTIONS is enabled.

Testing

  1. Verified compilation with Green Hills toolchain using CONFIG_DEBUG_OPT_UNUSED_SECTIONS=y to ensure the flags are correctly added.
  2. Confirmed that the modified Toolchain.defs does not break existing GCC/Clang builds and still applies the optimization flags as expected.

the -ffunction-sections and -fdata-sections are also supported by
greenhills, and these two compile options can benefit with section
layout optimization, and thus reduce the final image size

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Size: XS The size of the change in this PR is very small labels Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants