-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: https://gcc.gnu.org/wiki/LinkTimeOptimization Link Time Optimisation defers final compilation until the link stage, which allows more aggressive inlining and optimisations to occur, as more information is known at link time vs when each object is compiled. For the esp32dev platform, I have the following size reductions: Without LTO: 1313024 .pio/build/esp32dev/firmware.bin With LTO: 1214256 .pio/build/esp32dev/firmware.bin Signed-off-by: Alastair D'Silva <[email protected]>
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Import('env') | ||
|
||
env.Replace(AR=env['AR'].replace('elf-ar', 'elf-gcc-ar')) | ||
env.Replace(RANLIB=env['RANLIB'].replace('elf-ranlib', 'elf-gcc-ranlib')) | ||
|
||
# Something later clobbers AR & RANLIB, so until https://github.com/platformio/platform-espressif32/pull/1329 | ||
# is available, wrap the replace function to protect them | ||
|
||
# Save a reference to the original env.Replace() | ||
original_replace = env.Replace | ||
|
||
def create_replace_wrapper(env): | ||
def replace_wrapper(**kw): | ||
if 'AR' in kw: | ||
kw.pop("AR") | ||
if 'RANLIB' in kw: | ||
kw.pop("RANLIB") | ||
|
||
original_replace(**kw) | ||
|
||
return replace_wrapper | ||
|
||
# Replace the env.Replace with the wrapper | ||
env.Replace = create_replace_wrapper(env) | ||
|
||
print(f"Updated AR: {env['AR']}") | ||
print(f"Updated RANLIB: {env['RANLIB']}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters