mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-05 17:27:50 +00:00
[Lib/Optimizations] Garbage-collect unused functions
Somewhat similar in effect as LTO, but much less prone to bugs.
This commit is contained in:
parent
be2519d689
commit
3decd64dfd
1 changed files with 6 additions and 0 deletions
|
|
@ -17,6 +17,11 @@ let
|
|||
# Perform loop distribution of patterns that can be code generated with calls to a library (activated at O3 and more)
|
||||
"-ftree-loop-distribute-patterns"
|
||||
|
||||
# Put each function declaration in its own text section
|
||||
"-ffunction-sections"
|
||||
# Instruct the linker to garbage-collect unused sections, which combined with the above removes dead functions
|
||||
"-Wl,--gc-sections"
|
||||
|
||||
"-frecord-gcc-switches" # Record build flags in binary. Also supported by Clang
|
||||
];
|
||||
|
||||
|
|
@ -26,6 +31,7 @@ let
|
|||
];
|
||||
genericLinkerFlags = [
|
||||
"-Wl,-sort-common"
|
||||
"-Wl,--gc-sections"
|
||||
];
|
||||
ltoFlags = { threads ? 1, thin ? false }: [
|
||||
# Fat LTO objects are object files that contain both the intermediate language and the object code. This makes them usable for both LTO linking and normal linking.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue