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

Reduce bloat #1245

Open
DanRStevens opened this issue Feb 26, 2025 · 0 comments
Open

Reduce bloat #1245

DanRStevens opened this issue Feb 26, 2025 · 0 comments

Comments

@DanRStevens
Copy link
Collaborator

DanRStevens commented Feb 26, 2025

General case for investigating and reducing bloat.


Compiling using Clang with -ftime-trace produces .json files next to the object files (.o), which can be loaded in Chrome to investigate compile times.
chrome://tracing/


Using nm with --print-size we can examine object files (.o) to determine what symbols contribute the most space to the object file. This can be used to determine which source code elements produce the largest amount of code bloat. It may also be helpful to pass the --demangle flag.

nm --print-size --size-sort --demangle .build/Debug_Linux_nas2d/intermediate/Configuration.o

Potentially the whole build folder can be scanned and sorted by symbol size:

find .build/Debug_Linux_nas2d/intermediate/ -name '*.o' -exec nm --print-size --size-sort --demangle {} \; | cut -d' ' -f2- | sort | uniq

It may be helpful to leave off the uniq call, to get a better sense of how often a symbol may appear.


We can get much of the same information as nm from the linker (ld) by generating a map file. This can be done with the custom makefile variable LDFLAGS_EXTRA:

export LDFLAGS_EXTRA="-Wl,-Map=mapfile"

The -Wl, is used to pass a flag to the linker. The -Map=mapfile is the linker flag to generate the mapfile. Use % as the filename to get the output filename with .map added.


Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant