Keil Logo

Technical Support

On-Line Manuals

Compiler User Guide

Preface Overview of the Compiler Getting Started with the Compiler Compiler command-line syntax Compiler command-line options listed by group Default compiler behavior Order of compiler command-line options Using stdin to input source code to the compiler Directing output to stdout Filename suffixes recognized by the compiler Compiler output files Factors influencing how the compiler searches for Compiler command-line options and search paths Compiler search rules and the current place The ARMCC5INC environment variable Code compatibility between separately compiled and Linker feedback during compilation Unused function code Minimizing code size by eliminating unused functio Compilation build time Compilation build time Minimizing compilation build time Minimizing compilation build time with a single ar Effect of --multifile on compilation build time Minimizing compilation build time with parallel ma Compilation build time on Windows Compiler Features Compiler Coding Practices Compiler Diagnostic Messages Using the Inline and Embedded Assemblers of the AR Compiler Command-line Options Language Extensions Compiler-specific Features C and C++ Implementation Details What is Semihosting? Via File Syntax Summary Table of GNU Language Extensions Standard C Implementation Definition Standard C++ Implementation Definition C and C++ Compiler Implementation Limits

Minimizing code size by eliminating unused functions during compilation

2.16 Minimizing code size by eliminating unused functions during compilation

Feedback from the linker to the compiler enables efficient elimination of unused functions.


  1. Compile your source code.
  2. Use the linker option --feedback=filename to create a feedback file.
  3. Use the linker option --feedback_type to control which feedback the linker generates.
    By default, the linker generates feedback to eliminate unused functions. This is equivalent to --feedback_type=unused,noiw. The linker can also generate feedback to avoid compiling functions for interworking that are never used in an interworking context. Use the linker option --feedback_type=unused,iw to eliminate both types of unused function.


    Reduction of compilation required for interworking is only applicable to ARMv4T architectures. ARMv5T and later processors can interwork without penalty.
  4. Re-compile using the compiler option --feedback=filename to feed the feedback file to the compiler.
The compiler uses the feedback file generated by the linker to compile the source code in a way that enables the linker to subsequently discard the unused functions.


To obtain maximum benefit from linker feedback, do a full compile and link at least twice. A single compile and link using feedback from a previous build is normally sufficient to obtain some benefit.


Always ensure that you perform a full clean build immediately before using the linker feedback file. This minimizes the risk of the feedback file becoming out of date with the source code it was generated from.
You can specify the --feedback=filename option even when no feedback file exists. This enables you to use the same build commands or makefile regardless of whether a feedback file exists, for example:
armcc -c --feedback=unused.txt test.c -o test.o
armlink --feedback=unused.txt test.o -o test.axf
The first time you build the application, it compiles normally but the compiler warns you that it cannot read the specified feedback file because it does not exist. The link command then creates the feedback file and builds the image. Each subsequent compilation step uses the feedback file from the previous link step to remove any unused functions that are identified.
Related concepts
Non-ConfidentialPDF file icon PDF versionARM DUI0375H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.