From be1bc511c19baaf79e333b957e936176e79f3f22 Mon Sep 17 00:00:00 2001 From: hankertrix <91734413+hankertrix@users.noreply.github.com> Date: Tue, 3 Sep 2024 12:36:42 +0800 Subject: [PATCH] specs: Add option to print memory usage --- avr-specs/avr-atmega1280.json | 6 ++++-- avr-specs/avr-atmega1284p.json | 6 ++++-- avr-specs/avr-atmega128a.json | 6 ++++-- avr-specs/avr-atmega164pa.json | 6 ++++-- avr-specs/avr-atmega168.json | 6 ++++-- avr-specs/avr-atmega2560.json | 6 ++++-- avr-specs/avr-atmega328.json | 6 ++++-- avr-specs/avr-atmega328p.json | 6 ++++-- avr-specs/avr-atmega32a.json | 6 ++++-- avr-specs/avr-atmega32u4.json | 6 ++++-- avr-specs/avr-atmega48p.json | 6 ++++-- avr-specs/avr-atmega8.json | 6 ++++-- avr-specs/avr-attiny167.json | 6 ++++-- avr-specs/avr-attiny2313.json | 6 ++++-- avr-specs/avr-attiny85.json | 6 ++++-- avr-specs/avr-attiny88.json | 6 ++++-- avr-specs/sync-from-upstream.py | 1 + 17 files changed, 65 insertions(+), 32 deletions(-) diff --git a/avr-specs/avr-atmega1280.json b/avr-specs/avr-atmega1280.json index c38dd3de5a..1791c43f48 100644 --- a/avr-specs/avr-atmega1280.json +++ b/avr-specs/avr-atmega1280.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega1280" + "-mmcu=atmega1280", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega1280" + "-mmcu=atmega1280", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega1284p.json b/avr-specs/avr-atmega1284p.json index ff893550da..38c916259f 100644 --- a/avr-specs/avr-atmega1284p.json +++ b/avr-specs/avr-atmega1284p.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega1284p" + "-mmcu=atmega1284p", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega1284p" + "-mmcu=atmega1284p", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega128a.json b/avr-specs/avr-atmega128a.json index b19b62c1fd..2707faba03 100644 --- a/avr-specs/avr-atmega128a.json +++ b/avr-specs/avr-atmega128a.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega128a" + "-mmcu=atmega128a", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega128a" + "-mmcu=atmega128a", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega164pa.json b/avr-specs/avr-atmega164pa.json index 7baac670cd..256a2222e6 100644 --- a/avr-specs/avr-atmega164pa.json +++ b/avr-specs/avr-atmega164pa.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega164pa" + "-mmcu=atmega164pa", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega164pa" + "-mmcu=atmega164pa", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega168.json b/avr-specs/avr-atmega168.json index efb933476b..7fbd579a7b 100644 --- a/avr-specs/avr-atmega168.json +++ b/avr-specs/avr-atmega168.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega168" + "-mmcu=atmega168", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega168" + "-mmcu=atmega168", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega2560.json b/avr-specs/avr-atmega2560.json index f48d69c201..252b54f16a 100644 --- a/avr-specs/avr-atmega2560.json +++ b/avr-specs/avr-atmega2560.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega2560" + "-mmcu=atmega2560", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega2560" + "-mmcu=atmega2560", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega328.json b/avr-specs/avr-atmega328.json index beadb0e61d..77c64f366c 100644 --- a/avr-specs/avr-atmega328.json +++ b/avr-specs/avr-atmega328.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega328" + "-mmcu=atmega328", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega328" + "-mmcu=atmega328", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega328p.json b/avr-specs/avr-atmega328p.json index 8215d1c07a..461daa7a67 100644 --- a/avr-specs/avr-atmega328p.json +++ b/avr-specs/avr-atmega328p.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega328p" + "-mmcu=atmega328p", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega328p" + "-mmcu=atmega328p", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega32a.json b/avr-specs/avr-atmega32a.json index f99654109b..9ffda7dbdd 100644 --- a/avr-specs/avr-atmega32a.json +++ b/avr-specs/avr-atmega32a.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega32a" + "-mmcu=atmega32a", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega32a" + "-mmcu=atmega32a", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega32u4.json b/avr-specs/avr-atmega32u4.json index e8a7fd3604..a1632146b1 100644 --- a/avr-specs/avr-atmega32u4.json +++ b/avr-specs/avr-atmega32u4.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega32u4" + "-mmcu=atmega32u4", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega32u4" + "-mmcu=atmega32u4", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega48p.json b/avr-specs/avr-atmega48p.json index 4285f9919f..508677e347 100644 --- a/avr-specs/avr-atmega48p.json +++ b/avr-specs/avr-atmega48p.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega48p" + "-mmcu=atmega48p", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega48p" + "-mmcu=atmega48p", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-atmega8.json b/avr-specs/avr-atmega8.json index 961b58766e..b2c0c5cf08 100644 --- a/avr-specs/avr-atmega8.json +++ b/avr-specs/avr-atmega8.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=atmega8" + "-mmcu=atmega8", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=atmega8" + "-mmcu=atmega8", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-attiny167.json b/avr-specs/avr-attiny167.json index a8d23df759..3cbdbe47d1 100644 --- a/avr-specs/avr-attiny167.json +++ b/avr-specs/avr-attiny167.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=attiny167" + "-mmcu=attiny167", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=attiny167" + "-mmcu=attiny167", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-attiny2313.json b/avr-specs/avr-attiny2313.json index bfba5bbcd8..aa8fffb4d5 100644 --- a/avr-specs/avr-attiny2313.json +++ b/avr-specs/avr-attiny2313.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=attiny2313" + "-mmcu=attiny2313", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=attiny2313" + "-mmcu=attiny2313", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-attiny85.json b/avr-specs/avr-attiny85.json index 6d68928e5e..d5334aa5de 100644 --- a/avr-specs/avr-attiny85.json +++ b/avr-specs/avr-attiny85.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=attiny85" + "-mmcu=attiny85", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=attiny85" + "-mmcu=attiny85", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/avr-attiny88.json b/avr-specs/avr-attiny88.json index d5a3c63fa7..1af5e8d338 100644 --- a/avr-specs/avr-attiny88.json +++ b/avr-specs/avr-attiny88.json @@ -27,10 +27,12 @@ "no-default-libraries": false, "pre-link-args": { "gnu-cc": [ - "-mmcu=attiny88" + "-mmcu=attiny88", + "-Wl,--as-needed,--print-memory-usage" ], "gnu-lld-cc": [ - "-mmcu=attiny88" + "-mmcu=attiny88", + "-Wl,--as-needed,--print-memory-usage" ] }, "relocation-model": "static", diff --git a/avr-specs/sync-from-upstream.py b/avr-specs/sync-from-upstream.py index 7c27f1dc85..62a6c5fea6 100755 --- a/avr-specs/sync-from-upstream.py +++ b/avr-specs/sync-from-upstream.py @@ -98,6 +98,7 @@ def main(): for pre_link_args in spec["pre-link-args"].values(): pre_link_args[0] = f"-mmcu={settings['cpu']}" + pre_link_args.append("-Wl,--as-needed,--print-memory-usage") with open(f"avr-specs/avr-{mcu}.json", "w") as f: json.dump(spec, f, sort_keys=True, indent=2)