GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/toplev.cc

gcc/toplev.cc: Output mangled function names with -fstack-usage

The -fstack-usage option now outputs mangled function names.

When using the -fstack-usage option in GCC, this commit modifies the output to include mangled function names instead of plain names. This provides more precise identification of functions, especially in the presence of overloading or name collisions. This makes the output more useful for automated stack checking tools like avstack.pl, which rely on unique function identifiers.

In Details

The -fstack-usage option causes GCC to output the stack usage of each function in the compiled code. The output_stack_usage_1 function in gcc/toplev.cc generates this output. This commit changes the function to use RINT_DECL_UNIQUE_NAME when printing the function name, which results in the mangled name being printed instead of the plain name. This change is intended to improve interoperability with tools that rely on unique function names.

For Context

When compiling code, the -fstack-usage option can be used to generate a report showing how much stack space each function uses. The stack is a region of memory used for temporary storage during function calls, and knowing the stack usage is important for preventing stack overflows. Mangled names are compiler-generated unique identifiers for functions, especially important in languages like C++ that support function overloading (having multiple functions with the same name but different arguments). This commit modifies the output of -fstack-usage to include these mangled names, making it easier to automatically analyze the stack usage of complex C++ programs.

Filed Under: gccstack usagemanglingdebugging