diff --git a/public/og/where-did-my-flash-go.png b/public/og/where-did-my-flash-go.png new file mode 100644 index 00000000..f6a36f70 Binary files /dev/null and b/public/og/where-did-my-flash-go.png differ diff --git a/scripts/schedule_doubles.py b/scripts/schedule_doubles.py index 88135824..97ab88fd 100644 --- a/scripts/schedule_doubles.py +++ b/scripts/schedule_doubles.py @@ -249,6 +249,10 @@ "why": "lvgl26 size finding on contracts, beside the RAII ffmpeg post"}, "2026-12-16": {"slug": "options-struct-links-every-setter", "hour": 16, "why": "lvgl26 size finding on options structs, beside the constexpr assembler flagship"}, + # The method flagship of the lvgl26 size findings, after the contracts + # (13 Dec) and options-struct (16 Dec) posts it links. + "2026-12-20": {"slug": "where-did-my-flash-go", "hour": 16, + "why": "size-method flagship, beside the from_chars short"}, } diff --git a/social/facebook/where-did-my-flash-go/README.md b/social/facebook/where-did-my-flash-go/README.md new file mode 100644 index 00000000..85dc2af2 --- /dev/null +++ b/social/facebook/where-did-my-flash-go/README.md @@ -0,0 +1,130 @@ +# LinkedIn Square Post (1200x1200) + +Standard LinkedIn feed post at 1:1 square aspect ratio. Works well as a scroll-stopping image in the LinkedIn feed. + +## Usage + +```bash +brand-gen init social/linkedin-post my-post +cd my-post +# edit content.md +brand-gen build # -> index.html +brand-gen image # -> my-post.png (2400x2400 at 2x DPR) +``` + +## Directives + +All templates use one of four post types. Each uses the same directive pattern: + +### Quote + +```markdown +::::post{type=quote theme=dark logo=top-left} + +:::quote{author="Filip Sajdak" role="Founder & CEO, ScudoAI"} + +Sovereign AI is not a feature you bolt on later. It is the architecture. + +::: + +:::: +``` + +### Stat + +```markdown +::::post{type=stat theme=light accent=brand} + +:::stat{value="USD 80B" label="Worldwide sovereign cloud spend" context="Europe is the fastest-growing region at 83% YoY." source="Gartner, Feb 2026"} +::: + +:::: +``` + +### Announcement + +```markdown +::::post{type=announcement theme=light} + +:::announcement{kind="launch" date="April 2026"} + +# ScudoAI joins NVIDIA Inception + +We are thrilled to join the NVIDIA Inception program to accelerate sovereign AI deployment across European regulated industries. + +::: + +:::: +``` + +### Insight + +```markdown +::::post{type=insight theme=dark} + +:::insight{citation="EU AI Act full enforcement: 2 August 2026"} + +# The AI compliance deadline most companies are missing + +Full EU AI Act enforcement for high-risk AI systems begins in 2 August 2026. Most regulated enterprises are not ready for the documentation and audit requirements. Teams running cloud AI will face the hardest transition. + +::: + +:::: +``` + +## Attributes reference + +### `::::post` attributes + +- `type` - quote | stat | announcement | insight (required) +- `theme` - dark | light (default light) +- `accent` - brand | amber | nv (optional colored gradient background) +- `logo` - top-left | top-right | bottom-left | bottom-right (default bottom-right) + +### `:::quote` attributes + +- `author` - attribution name (appears below the quote) +- `role` - attribution role/title (appears under the author) + +### `:::stat` attributes + +- `value` - the big number (e.g. "USD 80B", "3/4", "Hours to minutes") +- `label` - short label under the value +- `context` - 1-2 sentences providing context +- `source` - small citation + +### `:::announcement` attributes + +- `kind` - launch | milestone | event | hire | partnership +- `date` - free-form date string + +### `:::insight` attributes + +- `citation` - small footer citation (e.g. regulation reference) + +## Character limits + +- **Quote body**: ~120 characters for maximum readability at thumbnail size +- **Stat label**: ~40 characters +- **Stat context**: ~200 characters +- **Announcement headline**: ~80 characters +- **Announcement body**: ~250 characters +- **Insight hook**: ~100 characters +- **Insight body**: ~300 characters + +Posts that exceed these limits will still render but typography may shrink or content may clip. + +## Media + +Add a `media/` directory to the project and reference local files: + +```markdown +:::background{image="nvidia-thor.jpg" overlay="dark"} +::: + +:::image{src="product-screenshot.png" alt="ScudoAI compliance dashboard" position="top"} +::: +``` + +Paths are relative to the project's `media/` directory. diff --git a/social/facebook/where-did-my-flash-go/assets/brand-kit.json b/social/facebook/where-did-my-flash-go/assets/brand-kit.json new file mode 100644 index 00000000..c7af1d75 --- /dev/null +++ b/social/facebook/where-did-my-flash-go/assets/brand-kit.json @@ -0,0 +1,11 @@ +{ + "template": "social/linkedin-post", + "bundleSource": "scudoai-social.css", + "brandKitVersion": "0.1.0", + "vendoredAt": "2026-11-29T14:10:31.631Z", + "files": [ + "scudoai.css", + "layout.css", + "logo-symbol.svg" + ] +} diff --git a/social/facebook/where-did-my-flash-go/assets/layout.css b/social/facebook/where-did-my-flash-go/assets/layout.css new file mode 100644 index 00000000..e69de29b diff --git a/social/facebook/where-did-my-flash-go/assets/logo-symbol.svg b/social/facebook/where-did-my-flash-go/assets/logo-symbol.svg new file mode 100644 index 00000000..1fc44966 --- /dev/null +++ b/social/facebook/where-did-my-flash-go/assets/logo-symbol.svg @@ -0,0 +1,22 @@ + diff --git a/social/facebook/where-did-my-flash-go/assets/scudoai.css b/social/facebook/where-did-my-flash-go/assets/scudoai.css new file mode 100644 index 00000000..612b5a12 --- /dev/null +++ b/social/facebook/where-did-my-flash-go/assets/scudoai.css @@ -0,0 +1,343 @@ +/* ============================================================ + * wro.cpp social card -- standalone stylesheet + * + * Self-contained styling for brand-gen's `social/linkedin-post` + * output. Replaces (does NOT extend) the scudoai-social.css that + * brand-gen ships with -- the design language here is the + * wro.cpp 'Editorial Magnet' look used by src/styles/global.css, + * not the scudoai blue-indigo deck aesthetic. + * + * Source of truth for tokens: src/styles/global.css:12-30 in the + * wrocpp.github.io repo. + * + * Brand-gen markup we style: + *
+ *
(decorative, hidden) + *
(decorative, hidden) + *
+ *

...

+ *

...

+ *
...
+ *
+ *
+ * + * ScudoAI (hidden; replaced via ::after) + *
+ *
+ * + * Other card types (card-quote, card-stat, card-announcement) + * get analogous rules at the bottom. + * ============================================================ */ + +@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=JetBrains+Mono:wght@400;500;700&display=swap'); + +:root { + --paper: #FCFAF5; + --paper-2: #F3EFE6; + --paper-3: #E8E1D0; + --ink: #1B1B1D; + --ink-muted:#55555A; + --ink-faint:#8A8A90; + --rule: #D7D2C4; + --orange: #EA541E; + --orange-2: #D6481A; + --blue: #3EB5E9; + --blue-deep:#2E8FB8; + + --font-display: 'Quicksand', system-ui, -apple-system, sans-serif; + --font-body: 'Source Serif 4', Georgia, serif; + --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; +} + +html, body { + margin: 0; + padding: 0; + background: var(--paper); + color: var(--ink); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-family: var(--font-body); + font-size: 18px; + line-height: 1.6; +} + +/* Hide brand-gen decorative noise -- the wro.cpp aesthetic is calm + * and editorial, not a dark deck with glow + grid backgrounds. */ +.grid-bg, .glow { display: none !important; } + +/* ---------------- Card frame (1200x1200) ---------------- */ +.card { + position: relative; + width: 1200px; + height: 1200px; + background: var(--paper); + /* Faint warm radial wash, mirrors body { background-image } in + * src/styles/global.css:44-49 -- gives the paper texture without + * looking flat. */ + background-image: + radial-gradient(900px 700px at 80% -10%, rgba(234, 84, 30, 0.06), transparent 60%), + radial-gradient(800px 600px at -10% 110%, rgba(62, 181, 233, 0.05), transparent 60%); + overflow: hidden; + box-sizing: border-box; + padding: 130px 110px 130px 110px; + display: flex; + flex-direction: column; + /* Faint inner border gives the card a printed-page feel. */ + border-bottom: 6px solid var(--orange); +} + +/* Override: theme=dark cards still use paper. We keep the editorial + * light look across the board so the wro.cpp brand stays consistent. + * If the user really wants a dark variant later, this is the hook. */ +.card.dark { background: var(--paper) !important; color: var(--ink) !important; } +.card.dark h1, .card.dark h2, .card.dark p, +.card.dark blockquote { color: var(--ink) !important; } + +/* ---------------- INSIGHT card ---------------- */ +.card-insight { + justify-content: center; + padding-top: 200px; /* reserve space for logo watermark (top:90px + 64px + safety) */ +} +.card-insight .insight-content { + display: flex; + flex-direction: column; + gap: 60px; + max-width: 980px; +} +.card-insight h1 { + font-family: var(--font-display); + font-weight: 700; + font-size: 92pt; + line-height: 1.02; + letter-spacing: -0.025em; + color: var(--ink); + margin: 0; +} +.card-insight h1.title-long { + font-size: 72pt; + line-height: 1.06; + letter-spacing: -0.02em; + max-height: 420px; +} +.card-insight h1.title-xlong { + font-size: 56pt; + line-height: 1.10; + letter-spacing: -0.015em; + max-height: 440px; +} +/* Auto-accent: ++ in C++/C++26 turns orange, sentence-final period + * (when wrapped in ) turns blue. The skill writes + * the heading with these spans for the wro.cpp signature look. */ +.card-insight h1 .accent { color: var(--orange); } +.card-insight h1 .dot { color: var(--blue-deep); } +.card-insight p { + font-family: var(--font-body); + font-size: 30pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 0; + max-width: 920px; +} +.card-insight .insight-citation { + font-family: var(--font-mono); + font-size: 18pt; + letter-spacing: 0.04em; + color: var(--ink-faint); + margin-top: 40px; + padding-top: 30px; + border-top: 1px solid var(--rule); + text-transform: lowercase; +} +.card-insight .insight-citation::before { + content: '// '; + color: var(--orange); + font-weight: 700; +} + +/* ---------------- QUOTE card ---------------- */ +.card-quote { justify-content: center; padding: 140px 110px; } +.card-quote .quote-content { display: flex; flex-direction: column; align-items: flex-start; } +.card-quote .quote-mark { + font-family: var(--font-display); + font-weight: 700; + font-size: 200pt; + line-height: 0.8; + color: var(--orange); + opacity: 0.20; + /* In-flow above the text (not floated in the corner) with a negative + * bottom margin so the mark nearly touches the first quote line. */ + margin: 0 0 -0.62em; +} +.card-quote .quote-body { + font-family: var(--font-display); + font-weight: 600; + font-size: 64pt; + line-height: 1.15; + letter-spacing: -0.02em; + color: var(--ink); + max-width: 980px; + margin: 0; +} +.card-quote .quote-attribution { + margin-top: 50px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-muted); +} +.card-quote .quote-attribution::before { content: '-- '; color: var(--orange); } +/* author and role are adjacent spans with no separator in the markup; + * add one so they do not run together ("wro.cppC++26 ..."). */ +.card-quote .quote-attribution .role::before { content: ' / '; color: var(--ink-faint); } + +/* ---------------- STAT card ---------------- */ +.card-stat { justify-content: center; } +/* Value and label sit side by side (label wraps to stacked lines whose + * combined height roughly matches the value); context + source span the + * full width underneath. */ +.card-stat .stat-content { + display: grid; + grid-template-columns: auto 1fr; + grid-template-areas: + "value label" + "context context" + "source source"; + column-gap: 64px; + align-items: center; +} +.card-stat .stat-value { + grid-area: value; + font-family: var(--font-display); + font-weight: 700; + font-size: 240pt; + line-height: 0.82; + letter-spacing: -0.04em; + color: var(--orange); + margin: 0; +} +.card-stat .stat-label { + grid-area: label; + font-family: var(--font-display); + font-weight: 700; + font-size: 90pt; + line-height: 1.0; + letter-spacing: -0.02em; + color: var(--ink); + /* min-content forces a per-word wrap, so "codegen steps" stacks into + * two lines next to the value instead of running on one long line. */ + width: min-content; + margin: 0; +} +.card-stat .stat-context { + grid-area: context; + font-family: var(--font-body); + font-size: 26pt; + line-height: 1.45; + color: var(--ink-muted); + margin: 56px 0 0; + max-width: 880px; +} +.card-stat .stat-source { + grid-area: source; + margin-top: 44px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-faint); +} +.card-stat .stat-source::before { content: '// '; color: var(--orange); } + +/* ---------------- ANNOUNCEMENT card ---------------- */ +.card-announcement { justify-content: center; } +.card-announcement .announcement-meta { + font-family: var(--font-mono); + font-size: 20pt; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--orange); + margin-bottom: 30px; +} +.card-announcement .announcement-content h1, +.card-announcement .announcement-content h2 { + font-family: var(--font-display); + font-weight: 700; + font-size: 78pt; + line-height: 1.05; + letter-spacing: -0.02em; + color: var(--ink); + margin: 0; +} +.card-announcement .announcement-content p { + font-family: var(--font-body); + font-size: 28pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 40px 0 0; + max-width: 900px; +} + +/* ---------------- LOGO WATERMARK ---------------- */ +/* brand-gen hard-codes "ScudoAI" in .logo-wordmark; we hide it and + * draw "wro.cpp" via ::after on the watermark. The orange ".cpp" mirrors + * the brand-mark in the site header. */ +.logo-watermark { + position: absolute; + display: flex; + align-items: center; + gap: 18px; + height: 64px; + z-index: 10; + color: var(--ink); +} +.logo-watermark.top-left { top: 90px; left: 110px; } +.logo-watermark.top-right { top: 90px; right: 110px; } +.logo-watermark.bottom-left { bottom: 60px; left: 110px; } +.logo-watermark.bottom-right { bottom: 60px; right: 110px; } +.logo-watermark svg { + width: 64px; + height: 64px; + flex-shrink: 0; + /* Magnet logo PNG already has transparent paper-tone background; + * no rounded box needed -- it sits on the paper card directly. */ +} +.logo-wordmark { + font-size: 0 !important; + line-height: 0 !important; + /* Hide the upstream "ScudoAI" text node entirely. */ +} +.logo-watermark::after { + content: 'wro.cpp'; + font-family: var(--font-display); + font-weight: 700; + font-size: 28pt; + letter-spacing: -0.025em; + color: var(--ink); + line-height: 1; + /* The .cpp portion is given orange via a ::first-line trick below + * isn't reliable for inline -- so the SKILL writes the wordmark + * with explicit spans when it owns the markup. For this default + * rendering, the whole wordmark is ink and the orange comes through + * the bottom border + eyebrow. */ +} +.logo-watermark.top-right::after, +.logo-watermark.bottom-right::after { order: -1; margin-right: 18px; } + +/* ---------------- AI DISCLOSURE BADGE ---------------- */ +/* A small, honest "AI-GENERATED" label so the disclosure rides with the + * card image on social. Bottom-right corner (logo is top-left, citation is + * center-bottom, so this corner is free). Injected into index.html by + * inject.sh. See the /ai policy page. */ +.ai-badge { + position: absolute; + bottom: 74px; /* clears the 6px orange accent bar; sits in the bottom padding band */ + right: 110px; /* matches the card side padding / logo inset */ + z-index: 10; + font-family: var(--font-mono); + font-size: 14pt; + font-weight: 500; + letter-spacing: 0.10em; + text-transform: uppercase; + color: var(--ink-faint); +} + +/* ---------------- Defensive overrides ---------------- */ +/* Anything brand-gen might have set inline using its tokens. */ +* { box-sizing: border-box; } diff --git a/social/facebook/where-did-my-flash-go/caption.md b/social/facebook/where-did-my-flash-go/caption.md new file mode 100644 index 00000000..025c8701 --- /dev/null +++ b/social/facebook/where-did-my-flash-go/caption.md @@ -0,0 +1,16 @@ +# Where did my flash go? Finding 36 KB in a C++ firmware + +## Body +A C++ GUI screen on a Cortex-M4 took 39,252 bytes more flash than the same screen in C. Seven steps with binutils and four small scripts found why: function names from contract checks, and one template that linked every setter of a widget. After six fixes the gap is 2,528 bytes. The post shows each command and what it printed, and the scripts come with a sample firmware you can try without an ARM toolchain. + +https://wrocpp.github.io/posts/where-did-my-flash-go/ + +## Hashtags +#cpp #embedded #firmware #wrocpp + +## Alt-text +wro.cpp card with the magnet logo. Headline reads "Seven steps found 36 KB of flash" with a subtitle about a C++ GUI program on a Cortex-M4 that was 39,252 B larger than C and is now 2,528 B larger. Citation footer: wro.cpp, 2026-12-20. + +## Suggested post time +Sunday 2026-12-20, 16:00 UTC +Reason: the second slot of the day, beside the 08:00 UTC from_chars short, after the 13 and 16 December posts it links. diff --git a/social/facebook/where-did-my-flash-go/config.yaml b/social/facebook/where-did-my-flash-go/config.yaml new file mode 100644 index 00000000..de79ee57 --- /dev/null +++ b/social/facebook/where-did-my-flash-go/config.yaml @@ -0,0 +1,12 @@ +template: social/linkedin-post + +size: + width: 1200 + height: 1200 + dpr: 2 + +project: + name: "where-did-my-flash-go" + author: "Filip Sajdak, Founder & CEO" + email: "office@scudoai.com" + date: "2026-12-20" diff --git a/social/facebook/where-did-my-flash-go/content.md b/social/facebook/where-did-my-flash-go/content.md new file mode 100644 index 00000000..911a8c85 --- /dev/null +++ b/social/facebook/where-did-my-flash-go/content.md @@ -0,0 +1,12 @@ +--- +template: social/linkedin-post +--- + +::::post{type=insight theme=dark logo=top-left} + +:::insight{citation="wro.cpp -- 2026-12-20"} +# Seven steps found 36 KB of flash +A C++ GUI program on a Cortex-M4 was 39,252 B larger than the same screen in C. Sizes per object, the link map, nm, a call graph and one A/B build per change found why. The gap is now 2,528 B. +::: + +:::: diff --git a/social/facebook/where-did-my-flash-go/image.png b/social/facebook/where-did-my-flash-go/image.png new file mode 100644 index 00000000..3ebf3404 Binary files /dev/null and b/social/facebook/where-did-my-flash-go/image.png differ diff --git a/social/facebook/where-did-my-flash-go/index.html b/social/facebook/where-did-my-flash-go/index.html new file mode 100644 index 00000000..9497dc5d --- /dev/null +++ b/social/facebook/where-did-my-flash-go/index.html @@ -0,0 +1,28 @@ + + + + + + where-did-my-flash-go + + + + + + + + + + +

Seven steps found 36 KB of flash

A C++ GUI program on a Cortex-M4 was 39,252 B larger than the same screen in C. Sizes per object, the link map, nm, a call graph and one A/B build per change found why. The gap is now 2,528 B.

wro.cpp -- 2026-12-20
ScudoAI
AI-generated
+ + \ No newline at end of file diff --git a/social/facebook/where-did-my-flash-go/media/.gitkeep b/social/facebook/where-did-my-flash-go/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/social/facebook/where-did-my-flash-go/media/README.md b/social/facebook/where-did-my-flash-go/media/README.md new file mode 100644 index 00000000..bb81c7fa --- /dev/null +++ b/social/facebook/where-did-my-flash-go/media/README.md @@ -0,0 +1,9 @@ +# Media directory + +Drop images here (PNG, JPG, SVG) for use in your post. + +Reference them in your content.md with: + + :::image{src="screenshot.png" alt="Alt text" position="top"} + +The renderer resolves paths relative to this media/ directory. diff --git a/social/linkedin/where-did-my-flash-go/README.md b/social/linkedin/where-did-my-flash-go/README.md new file mode 100644 index 00000000..85dc2af2 --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/README.md @@ -0,0 +1,130 @@ +# LinkedIn Square Post (1200x1200) + +Standard LinkedIn feed post at 1:1 square aspect ratio. Works well as a scroll-stopping image in the LinkedIn feed. + +## Usage + +```bash +brand-gen init social/linkedin-post my-post +cd my-post +# edit content.md +brand-gen build # -> index.html +brand-gen image # -> my-post.png (2400x2400 at 2x DPR) +``` + +## Directives + +All templates use one of four post types. Each uses the same directive pattern: + +### Quote + +```markdown +::::post{type=quote theme=dark logo=top-left} + +:::quote{author="Filip Sajdak" role="Founder & CEO, ScudoAI"} + +Sovereign AI is not a feature you bolt on later. It is the architecture. + +::: + +:::: +``` + +### Stat + +```markdown +::::post{type=stat theme=light accent=brand} + +:::stat{value="USD 80B" label="Worldwide sovereign cloud spend" context="Europe is the fastest-growing region at 83% YoY." source="Gartner, Feb 2026"} +::: + +:::: +``` + +### Announcement + +```markdown +::::post{type=announcement theme=light} + +:::announcement{kind="launch" date="April 2026"} + +# ScudoAI joins NVIDIA Inception + +We are thrilled to join the NVIDIA Inception program to accelerate sovereign AI deployment across European regulated industries. + +::: + +:::: +``` + +### Insight + +```markdown +::::post{type=insight theme=dark} + +:::insight{citation="EU AI Act full enforcement: 2 August 2026"} + +# The AI compliance deadline most companies are missing + +Full EU AI Act enforcement for high-risk AI systems begins in 2 August 2026. Most regulated enterprises are not ready for the documentation and audit requirements. Teams running cloud AI will face the hardest transition. + +::: + +:::: +``` + +## Attributes reference + +### `::::post` attributes + +- `type` - quote | stat | announcement | insight (required) +- `theme` - dark | light (default light) +- `accent` - brand | amber | nv (optional colored gradient background) +- `logo` - top-left | top-right | bottom-left | bottom-right (default bottom-right) + +### `:::quote` attributes + +- `author` - attribution name (appears below the quote) +- `role` - attribution role/title (appears under the author) + +### `:::stat` attributes + +- `value` - the big number (e.g. "USD 80B", "3/4", "Hours to minutes") +- `label` - short label under the value +- `context` - 1-2 sentences providing context +- `source` - small citation + +### `:::announcement` attributes + +- `kind` - launch | milestone | event | hire | partnership +- `date` - free-form date string + +### `:::insight` attributes + +- `citation` - small footer citation (e.g. regulation reference) + +## Character limits + +- **Quote body**: ~120 characters for maximum readability at thumbnail size +- **Stat label**: ~40 characters +- **Stat context**: ~200 characters +- **Announcement headline**: ~80 characters +- **Announcement body**: ~250 characters +- **Insight hook**: ~100 characters +- **Insight body**: ~300 characters + +Posts that exceed these limits will still render but typography may shrink or content may clip. + +## Media + +Add a `media/` directory to the project and reference local files: + +```markdown +:::background{image="nvidia-thor.jpg" overlay="dark"} +::: + +:::image{src="product-screenshot.png" alt="ScudoAI compliance dashboard" position="top"} +::: +``` + +Paths are relative to the project's `media/` directory. diff --git a/social/linkedin/where-did-my-flash-go/assets/brand-kit.json b/social/linkedin/where-did-my-flash-go/assets/brand-kit.json new file mode 100644 index 00000000..3ad6323b --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/assets/brand-kit.json @@ -0,0 +1,11 @@ +{ + "template": "social/linkedin-post", + "bundleSource": "scudoai-social.css", + "brandKitVersion": "0.1.0", + "vendoredAt": "2026-11-29T14:10:31.478Z", + "files": [ + "scudoai.css", + "layout.css", + "logo-symbol.svg" + ] +} diff --git a/social/linkedin/where-did-my-flash-go/assets/layout.css b/social/linkedin/where-did-my-flash-go/assets/layout.css new file mode 100644 index 00000000..e69de29b diff --git a/social/linkedin/where-did-my-flash-go/assets/logo-symbol.svg b/social/linkedin/where-did-my-flash-go/assets/logo-symbol.svg new file mode 100644 index 00000000..1fc44966 --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/assets/logo-symbol.svg @@ -0,0 +1,22 @@ + diff --git a/social/linkedin/where-did-my-flash-go/assets/scudoai.css b/social/linkedin/where-did-my-flash-go/assets/scudoai.css new file mode 100644 index 00000000..612b5a12 --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/assets/scudoai.css @@ -0,0 +1,343 @@ +/* ============================================================ + * wro.cpp social card -- standalone stylesheet + * + * Self-contained styling for brand-gen's `social/linkedin-post` + * output. Replaces (does NOT extend) the scudoai-social.css that + * brand-gen ships with -- the design language here is the + * wro.cpp 'Editorial Magnet' look used by src/styles/global.css, + * not the scudoai blue-indigo deck aesthetic. + * + * Source of truth for tokens: src/styles/global.css:12-30 in the + * wrocpp.github.io repo. + * + * Brand-gen markup we style: + *
+ *
(decorative, hidden) + *
(decorative, hidden) + *
+ *

...

+ *

...

+ *
...
+ *
+ *
+ * + * ScudoAI (hidden; replaced via ::after) + *
+ *
+ * + * Other card types (card-quote, card-stat, card-announcement) + * get analogous rules at the bottom. + * ============================================================ */ + +@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=JetBrains+Mono:wght@400;500;700&display=swap'); + +:root { + --paper: #FCFAF5; + --paper-2: #F3EFE6; + --paper-3: #E8E1D0; + --ink: #1B1B1D; + --ink-muted:#55555A; + --ink-faint:#8A8A90; + --rule: #D7D2C4; + --orange: #EA541E; + --orange-2: #D6481A; + --blue: #3EB5E9; + --blue-deep:#2E8FB8; + + --font-display: 'Quicksand', system-ui, -apple-system, sans-serif; + --font-body: 'Source Serif 4', Georgia, serif; + --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; +} + +html, body { + margin: 0; + padding: 0; + background: var(--paper); + color: var(--ink); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + font-family: var(--font-body); + font-size: 18px; + line-height: 1.6; +} + +/* Hide brand-gen decorative noise -- the wro.cpp aesthetic is calm + * and editorial, not a dark deck with glow + grid backgrounds. */ +.grid-bg, .glow { display: none !important; } + +/* ---------------- Card frame (1200x1200) ---------------- */ +.card { + position: relative; + width: 1200px; + height: 1200px; + background: var(--paper); + /* Faint warm radial wash, mirrors body { background-image } in + * src/styles/global.css:44-49 -- gives the paper texture without + * looking flat. */ + background-image: + radial-gradient(900px 700px at 80% -10%, rgba(234, 84, 30, 0.06), transparent 60%), + radial-gradient(800px 600px at -10% 110%, rgba(62, 181, 233, 0.05), transparent 60%); + overflow: hidden; + box-sizing: border-box; + padding: 130px 110px 130px 110px; + display: flex; + flex-direction: column; + /* Faint inner border gives the card a printed-page feel. */ + border-bottom: 6px solid var(--orange); +} + +/* Override: theme=dark cards still use paper. We keep the editorial + * light look across the board so the wro.cpp brand stays consistent. + * If the user really wants a dark variant later, this is the hook. */ +.card.dark { background: var(--paper) !important; color: var(--ink) !important; } +.card.dark h1, .card.dark h2, .card.dark p, +.card.dark blockquote { color: var(--ink) !important; } + +/* ---------------- INSIGHT card ---------------- */ +.card-insight { + justify-content: center; + padding-top: 200px; /* reserve space for logo watermark (top:90px + 64px + safety) */ +} +.card-insight .insight-content { + display: flex; + flex-direction: column; + gap: 60px; + max-width: 980px; +} +.card-insight h1 { + font-family: var(--font-display); + font-weight: 700; + font-size: 92pt; + line-height: 1.02; + letter-spacing: -0.025em; + color: var(--ink); + margin: 0; +} +.card-insight h1.title-long { + font-size: 72pt; + line-height: 1.06; + letter-spacing: -0.02em; + max-height: 420px; +} +.card-insight h1.title-xlong { + font-size: 56pt; + line-height: 1.10; + letter-spacing: -0.015em; + max-height: 440px; +} +/* Auto-accent: ++ in C++/C++26 turns orange, sentence-final period + * (when wrapped in ) turns blue. The skill writes + * the heading with these spans for the wro.cpp signature look. */ +.card-insight h1 .accent { color: var(--orange); } +.card-insight h1 .dot { color: var(--blue-deep); } +.card-insight p { + font-family: var(--font-body); + font-size: 30pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 0; + max-width: 920px; +} +.card-insight .insight-citation { + font-family: var(--font-mono); + font-size: 18pt; + letter-spacing: 0.04em; + color: var(--ink-faint); + margin-top: 40px; + padding-top: 30px; + border-top: 1px solid var(--rule); + text-transform: lowercase; +} +.card-insight .insight-citation::before { + content: '// '; + color: var(--orange); + font-weight: 700; +} + +/* ---------------- QUOTE card ---------------- */ +.card-quote { justify-content: center; padding: 140px 110px; } +.card-quote .quote-content { display: flex; flex-direction: column; align-items: flex-start; } +.card-quote .quote-mark { + font-family: var(--font-display); + font-weight: 700; + font-size: 200pt; + line-height: 0.8; + color: var(--orange); + opacity: 0.20; + /* In-flow above the text (not floated in the corner) with a negative + * bottom margin so the mark nearly touches the first quote line. */ + margin: 0 0 -0.62em; +} +.card-quote .quote-body { + font-family: var(--font-display); + font-weight: 600; + font-size: 64pt; + line-height: 1.15; + letter-spacing: -0.02em; + color: var(--ink); + max-width: 980px; + margin: 0; +} +.card-quote .quote-attribution { + margin-top: 50px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-muted); +} +.card-quote .quote-attribution::before { content: '-- '; color: var(--orange); } +/* author and role are adjacent spans with no separator in the markup; + * add one so they do not run together ("wro.cppC++26 ..."). */ +.card-quote .quote-attribution .role::before { content: ' / '; color: var(--ink-faint); } + +/* ---------------- STAT card ---------------- */ +.card-stat { justify-content: center; } +/* Value and label sit side by side (label wraps to stacked lines whose + * combined height roughly matches the value); context + source span the + * full width underneath. */ +.card-stat .stat-content { + display: grid; + grid-template-columns: auto 1fr; + grid-template-areas: + "value label" + "context context" + "source source"; + column-gap: 64px; + align-items: center; +} +.card-stat .stat-value { + grid-area: value; + font-family: var(--font-display); + font-weight: 700; + font-size: 240pt; + line-height: 0.82; + letter-spacing: -0.04em; + color: var(--orange); + margin: 0; +} +.card-stat .stat-label { + grid-area: label; + font-family: var(--font-display); + font-weight: 700; + font-size: 90pt; + line-height: 1.0; + letter-spacing: -0.02em; + color: var(--ink); + /* min-content forces a per-word wrap, so "codegen steps" stacks into + * two lines next to the value instead of running on one long line. */ + width: min-content; + margin: 0; +} +.card-stat .stat-context { + grid-area: context; + font-family: var(--font-body); + font-size: 26pt; + line-height: 1.45; + color: var(--ink-muted); + margin: 56px 0 0; + max-width: 880px; +} +.card-stat .stat-source { + grid-area: source; + margin-top: 44px; + font-family: var(--font-mono); + font-size: 18pt; + color: var(--ink-faint); +} +.card-stat .stat-source::before { content: '// '; color: var(--orange); } + +/* ---------------- ANNOUNCEMENT card ---------------- */ +.card-announcement { justify-content: center; } +.card-announcement .announcement-meta { + font-family: var(--font-mono); + font-size: 20pt; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--orange); + margin-bottom: 30px; +} +.card-announcement .announcement-content h1, +.card-announcement .announcement-content h2 { + font-family: var(--font-display); + font-weight: 700; + font-size: 78pt; + line-height: 1.05; + letter-spacing: -0.02em; + color: var(--ink); + margin: 0; +} +.card-announcement .announcement-content p { + font-family: var(--font-body); + font-size: 28pt; + line-height: 1.5; + color: var(--ink-muted); + margin: 40px 0 0; + max-width: 900px; +} + +/* ---------------- LOGO WATERMARK ---------------- */ +/* brand-gen hard-codes "ScudoAI" in .logo-wordmark; we hide it and + * draw "wro.cpp" via ::after on the watermark. The orange ".cpp" mirrors + * the brand-mark in the site header. */ +.logo-watermark { + position: absolute; + display: flex; + align-items: center; + gap: 18px; + height: 64px; + z-index: 10; + color: var(--ink); +} +.logo-watermark.top-left { top: 90px; left: 110px; } +.logo-watermark.top-right { top: 90px; right: 110px; } +.logo-watermark.bottom-left { bottom: 60px; left: 110px; } +.logo-watermark.bottom-right { bottom: 60px; right: 110px; } +.logo-watermark svg { + width: 64px; + height: 64px; + flex-shrink: 0; + /* Magnet logo PNG already has transparent paper-tone background; + * no rounded box needed -- it sits on the paper card directly. */ +} +.logo-wordmark { + font-size: 0 !important; + line-height: 0 !important; + /* Hide the upstream "ScudoAI" text node entirely. */ +} +.logo-watermark::after { + content: 'wro.cpp'; + font-family: var(--font-display); + font-weight: 700; + font-size: 28pt; + letter-spacing: -0.025em; + color: var(--ink); + line-height: 1; + /* The .cpp portion is given orange via a ::first-line trick below + * isn't reliable for inline -- so the SKILL writes the wordmark + * with explicit spans when it owns the markup. For this default + * rendering, the whole wordmark is ink and the orange comes through + * the bottom border + eyebrow. */ +} +.logo-watermark.top-right::after, +.logo-watermark.bottom-right::after { order: -1; margin-right: 18px; } + +/* ---------------- AI DISCLOSURE BADGE ---------------- */ +/* A small, honest "AI-GENERATED" label so the disclosure rides with the + * card image on social. Bottom-right corner (logo is top-left, citation is + * center-bottom, so this corner is free). Injected into index.html by + * inject.sh. See the /ai policy page. */ +.ai-badge { + position: absolute; + bottom: 74px; /* clears the 6px orange accent bar; sits in the bottom padding band */ + right: 110px; /* matches the card side padding / logo inset */ + z-index: 10; + font-family: var(--font-mono); + font-size: 14pt; + font-weight: 500; + letter-spacing: 0.10em; + text-transform: uppercase; + color: var(--ink-faint); +} + +/* ---------------- Defensive overrides ---------------- */ +/* Anything brand-gen might have set inline using its tokens. */ +* { box-sizing: border-box; } diff --git a/social/linkedin/where-did-my-flash-go/caption.md b/social/linkedin/where-did-my-flash-go/caption.md new file mode 100644 index 00000000..8fc0286c --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/caption.md @@ -0,0 +1,24 @@ +# Where did my flash go? Finding 36 KB in a C++ firmware + +## Body +The C++ version of a small GUI screen took 283,724 bytes of flash on a Cortex-M4. The same screen in plain LVGL C took 244,472. This post is the method that found the 39,252 extra bytes, one step and one command at a time. + +Sizes per object came first. One object held a 17 KB string pool of function names, left there by contract checks. The link map, summed by object, showed my code pulling 4 KB more of LVGL than the fixed build links. nm sorted by size named the function: a 6,298-byte template that tested every member of an options struct at run time and so linked every setter. + +A call graph predicted 255 of the 262 symbols that the fix removed. The build with that one change removed 34,024 bytes, because records and names are not code and no call graph sees them. So the rule I kept: estimate to find, build to measure. + +After six fixes the gap is 2,528 bytes, 2,304 with full LTO (0.99 %). lvgl26 matches C on flash; it does not beat it. It uses less heap per widget, and its task frame costs 92 bytes more than C's timer. + +The four scripts, a 392-byte sample firmware and their tests are in the examples repository, and they run without an ARM toolchain. lvgl26 is written by Filip Sajdak, who runs wro.cpp. + +https://wrocpp.github.io/posts/where-did-my-flash-go/ + +## Hashtags +#cpp #cpp26 #embedded #firmware #binutils #lvgl #wrocpp + +## Alt-text +wro.cpp card with the magnet logo. Headline reads "Seven steps found 36 KB of flash" with a subtitle about a C++ GUI program on a Cortex-M4 that was 39,252 B larger than C and is now 2,528 B larger. Citation footer: wro.cpp, 2026-12-20. + +## Suggested post time +Sunday 2026-12-20, 16:00 UTC +Reason: the second slot of the day, beside the 08:00 UTC from_chars short, after the 13 and 16 December posts it links. diff --git a/social/linkedin/where-did-my-flash-go/config.yaml b/social/linkedin/where-did-my-flash-go/config.yaml new file mode 100644 index 00000000..de79ee57 --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/config.yaml @@ -0,0 +1,12 @@ +template: social/linkedin-post + +size: + width: 1200 + height: 1200 + dpr: 2 + +project: + name: "where-did-my-flash-go" + author: "Filip Sajdak, Founder & CEO" + email: "office@scudoai.com" + date: "2026-12-20" diff --git a/social/linkedin/where-did-my-flash-go/content.md b/social/linkedin/where-did-my-flash-go/content.md new file mode 100644 index 00000000..911a8c85 --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/content.md @@ -0,0 +1,12 @@ +--- +template: social/linkedin-post +--- + +::::post{type=insight theme=dark logo=top-left} + +:::insight{citation="wro.cpp -- 2026-12-20"} +# Seven steps found 36 KB of flash +A C++ GUI program on a Cortex-M4 was 39,252 B larger than the same screen in C. Sizes per object, the link map, nm, a call graph and one A/B build per change found why. The gap is now 2,528 B. +::: + +:::: diff --git a/social/linkedin/where-did-my-flash-go/image.png b/social/linkedin/where-did-my-flash-go/image.png new file mode 100644 index 00000000..f6a36f70 Binary files /dev/null and b/social/linkedin/where-did-my-flash-go/image.png differ diff --git a/social/linkedin/where-did-my-flash-go/index.html b/social/linkedin/where-did-my-flash-go/index.html new file mode 100644 index 00000000..9497dc5d --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/index.html @@ -0,0 +1,28 @@ + + + + + + where-did-my-flash-go + + + + + + + + + + +

Seven steps found 36 KB of flash

A C++ GUI program on a Cortex-M4 was 39,252 B larger than the same screen in C. Sizes per object, the link map, nm, a call graph and one A/B build per change found why. The gap is now 2,528 B.

wro.cpp -- 2026-12-20
ScudoAI
AI-generated
+ + \ No newline at end of file diff --git a/social/linkedin/where-did-my-flash-go/media/.gitkeep b/social/linkedin/where-did-my-flash-go/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/social/linkedin/where-did-my-flash-go/media/README.md b/social/linkedin/where-did-my-flash-go/media/README.md new file mode 100644 index 00000000..bb81c7fa --- /dev/null +++ b/social/linkedin/where-did-my-flash-go/media/README.md @@ -0,0 +1,9 @@ +# Media directory + +Drop images here (PNG, JPG, SVG) for use in your post. + +Reference them in your content.md with: + + :::image{src="screenshot.png" alt="Alt text" position="top"} + +The renderer resolves paths relative to this media/ directory. diff --git a/src/content/posts/2026-12-20-where-did-my-flash-go.mdx b/src/content/posts/2026-12-20-where-did-my-flash-go.mdx new file mode 100644 index 00000000..55674df4 --- /dev/null +++ b/src/content/posts/2026-12-20-where-did-my-flash-go.mdx @@ -0,0 +1,223 @@ +--- +title: "Where did my flash go? Finding 36 KB in a C++ firmware" +slug: "where-did-my-flash-go" +pubDate: 2026-12-20 +author: filip-sajdak +language: en +kind: flagship +audience: working-cpp +tags: [embedded, tooling, size, cpp26] +summary: "lvgl26's Cortex-M4 program was 39,252 B of flash larger than the same screen in C. Seven steps with binutils and four small scripts found where. After six fixes the gap is 2,528 B, and 2,304 B (0.99 %) with full LTO. The scripts, a sample firmware and their tests are in the examples." +draft: false +relatedPosts: [structured-binding-pack-lto-crash, contracts-on-a-microcontroller, options-struct-links-every-setter] +--- + +import GodboltEmbed from '../../components/GodboltEmbed.astro'; +import PostLink from '../../components/PostLink.astro'; + +The C++ version of a small screen took 283,724 bytes of flash on a Cortex-M4. The same screen written against LVGL's C API took 244,472. Seven steps with binutils found where the 39,252 extra bytes were. After six fixes the gap is 2,528 bytes. With full LTO on both programs, which one of the fixes made possible, it is 2,304 bytes, 0.99 % of the C program. This post is the method, step by step, with the command for each step and what it showed. + +## In short + +- Start with sizes per object and per section, not with the code. In lvgl26 one object held a 17,156-byte string pool, and those strings were function names, not code. +- Sum the link map by object, then sort the symbols by size. The third-largest symbol in flash was one function of mine, 6,298 bytes, which called every setter of a widget. +- A call graph estimates what one function keeps alive. Here it predicted 255 of the 262 symbols that the fix removed. Only the A/B build gives the number: 34,024 bytes. +- Measure the fixed cost and the cost per widget apart. They had different causes and different fixes. +- After the fixes lvgl26 matches C on flash and uses less heap per widget. It does not beat C on flash. + +lvgl26 is written by Filip Sajdak, who runs this blog. Status: lvgl26 is a 0.0.1 preview. It builds with GCC 16.2 only, and the numbers here come from its Cortex-M4 program run in QEMU. + +## What to do + +1. **Read sections before code.** Run `size -A` on each object and the map through a script that sums it by object. A big `.rodata.str1.1` or `.data` in your own object is a lead you can follow in a minute. +2. **Change one thing per build and measure that build.** Call graphs and symbol lists say where to look. The size of a build with one change is the only number to quote. +3. **Fit a line, not a point.** Build with 0, 4 and 16 copies of a widget. The intercept is your fixed cost and the slope is what each widget costs. +4. **Gate on bytes.** Fail the build when flash grows by more than a set number of bytes. Size is deterministic, so a percent limit is too loose. + +The four scripts, a 392-byte sample firmware to try them on, and their tests are in [the examples repository](https://github.com/wrocpp/cpp26-reflection-examples/tree/96d26715a4e45da052e63b74c56a14fb51db81b0/posts/152-where-did-my-flash-go). The tests need no ARM toolchain. + +## The method on one object file + +Before the 250 KB firmware, here is the method on one file. The demo holds a 64-entry table twice, once without `const` and once with it. It also has a function template that reports its own name, instantiated three times: + +```cpp +// Never written after start-up, but declared without const: .data +constinit std::array ramp_in_ram = make_ramp(); +// The same values, declared const: .rodata, flash only +extern const std::array ramp_in_flash = make_ramp(); + +template +T at_or_report(const std::array& values, std::size_t index, report_fn report) { + if (index < N) return values[index]; + report(std::source_location::current().function_name()); + return T{}; +} +``` + +Compiled for the Cortex-M4 with ARM GCC 16.2 at `-Os`, nm, readelf and strings show where each part went: + +| What | Section | Bytes | +|---|---|---| +| `ramp_in_ram` | `.data`: flash for the image, RAM for the copy | 128 flash, 128 RAM | +| `ramp_in_flash` | `.rodata`: flash only | 128 | +| each `at_or_report` instantiation | `.text` | 28 | +| the three function names | `.rodata.str1.1` | 598 | + +Three instantiations are 84 bytes of code and 598 bytes of names. The names carry every template argument, and each instantiation stores its own. On x86-64 the same program prints 623 bytes, because `std::size_t` is spelled `long unsigned int` there. + + + + + +## The firmware and the result + +The firmware is the slice of lvgl26. It shows a title, a dial and a counter label bound to a state, and a coroutine task moves the dial three times. The C program builds the same screen with the same LVGL v9.6.0 calls. Both are built with arm-none-eabi GCC 16.2 at `-Os` and run in QEMU on an `mps2-an386` board. Flash is text plus data from `arm-none-eabi-size`, and heap is what each program prints. + +| | BEFORE (03496b8) | AFTER (3a23a478) | plain C | +|---|---|---|---| +| Flash, as the repository ships it | 283,724 | 247,000 | 244,472 | +| Gap to C | +39,252 | +2,528 | | +| Gap to C, full LTO on both | +40,264 | +2,304 (0.99 %) | | +| RAM in `.data` | 4,224 | 192 | 184 | +| Flash per extra label and arc | 188.3 | 68.3 | 57.3 | +| Contract checks, flash / RAM | 22,784 / 4,032 | 364 / 0 | | +| Home-directory paths in the ELF | 8 | 0 | | + +The BEFORE full-LTO row could not use LTO on the C++ file, because of a GCC 16.2 crash. The 4 December post covers that bug and the rewrite that avoids it. All numbers come from builds I ran on 28 and 29 November 2026. [RESULTS.md](https://github.com/wrocpp/cpp26-reflection-examples/blob/96d26715a4e45da052e63b74c56a14fb51db81b0/posts/152-where-did-my-flash-go/RESULTS.md) in the examples lists them as rows 1 to 6, with the build of each. + +## Step 1: sizes per object + +The first command looks at the one object that lvgl26 adds, the compiled `slice.cpp`: + +```sh +arm-none-eabi-size -A build/examples/mcu/CMakeFiles/slice.elf.dir/slice.cpp.obj +``` + +The sections, summed by kind: + +| `slice.cpp.obj` | text | rodata | of which `.rodata.str1.1` | data | +|---|---|---|---|---| +| BEFORE | 13,704 | 17,421 | 17,156 | 4,040 | +| AFTER | 2,586 | 265 | 0 | 8 | + +A 17 KB string pool in an application with three widgets is not text a user sees. The strings tool showed what it was: function names with every template argument. The research note counted 97 of them in 16,448 bytes. They came from contract checks. GCC 16.2 stores a record and the full function name for every check in every instantiation. The records sit in `.data`, which is RAM. + +The string pool and the 4,040 bytes of `.data` explain 21 KB of the 39 KB. Most of those records exist only because of the function in step 3, so step 5 counts the same bytes again. The 13 December post follows it to the fix, which keeps the checks on for 364 bytes ([#302](https://github.com/filipsajdak/lvgl26/pull/302)). + +## Step 2: the link map, summed by object + +An object file shows what the compiler emitted. The linker drops unused sections and pulls members out of archives, so the map is where the final bytes are. `mapagg.py` sums a GNU ld map by object or archive and by kind of section. Given two maps, it prints the difference: + +```sh +python3 tools/mapagg.py slice.map slice_c.map +``` + +```text +source kind A B B - A +slice.cpp.obj rodata 19254 0 -19254 +slice.cpp.obj text 13688 0 -13688 +arm_slice_c.c.obj bss 0 6440 +6440 +slice.cpp.obj bss 6432 0 -6432 +liblvgl.a text 221056 216528 -4528 +``` + +Both maps come from the same build, so A is lvgl26 and B is the C program. The last line is the lead: lvgl26 linked 4,528 more bytes of LVGL. LVGL is the same library in both programs. Something in my code reached LVGL functions that the C program never needs. + +The map has one trap. The linker merges string sections across objects, and the map lists the merged pool under the first object that contributes. After the fixes the map gives `slice.cpp.obj` 2,082 bytes of rodata, while the object holds 265; the rest is LVGL's strings. For an object's own strings, trust `size -A` from step 1. + +## Step 3: the largest symbols + +The next question is which functions. `nm` sorts the symbols by size: + +```sh +arm-none-eabi-nm -S --size-sort -r -C slice.elf | head +``` + +Skip the buffers in `.bss` and the linker's own symbols, such as `__stack_top`. In the BEFORE build the third-largest symbol in flash was a function template of mine, 6,298 bytes (0x189a). These are the four largest in flash, with the addresses dropped and the long name cut: + +```text +00002280 t glyph_bitmap +00001be8 T lv_theme_default_init +0000189a W void lv::detail::apply_set_props{char [4]{(char)97, (char)114, (char)99}}, void>(...) +00001564 T lv_draw_sw_blend_image_to_rgb565_swapped +``` + +The characters 97, 114 and 99 spell `arc`. + +It applies an options struct to an arc. The struct has one optional member for each property, and the function tests every member at run time. A test that names a setter keeps that setter linked, even when no caller ever sets the member. One line in the task, `dial.set({.value = v})`, was its only caller. This happens at `-Os`, the size preset. At `-O2`, or with the function forced inline, GCC folds the call down to the one setter, as the 16 December post measures. + +## Step 4: what one function keeps alive + +Deleting a function also frees what only it calls. `closure.py` estimates that set from the disassembly. It builds a graph from the branches and from words that hold a function's address. Then it compares what the entry points reach with and without the function: + +```sh +arm-none-eabi-objdump -d slice.elf > slice.dis +arm-none-eabi-objdump -s -j .text -j .data slice.elf > slice.hex +python3 tools/closure.py slice.dis --words slice.hex --match --root apply_set_props +``` + +```text +roots: 1; reachable only through them: 255 symbols, 15088 bytes +``` + +The `--words` option matters. LVGL keeps callbacks in tables, and a function reached through a table has no branch pointing at it. Without the hex dump the script reported 247 symbols and 17,272 bytes, including functions that the fixed build still links. + +## Step 5: one change per build + +The estimate says where to cut. Only a build says what the cut saves. I changed the one line to `dial.set<"value">(v)`, which names the property at compile time, and built again. `symdiff.py` compares the two symbol tables: + +```text +added 0 symbols, 0 bytes +removed 262 symbols, 15222 bytes +resized 6 symbols, -698 bytes +``` + +All 255 predicted symbols were gone, and 7 more that the graph had missed. Flash dropped by 34,024 bytes, though, not 15 KB. Another 18,759 bytes were contract records and their names in the slice object. The generic set had instantiated a checked template once for each member of the struct, and 98 of the 112 records came from those copies. A call graph cannot see bytes that are not code, which is why step 1 comes first. + +Each variant in the research changed one file or one flag. It was built, run in QEMU, and put back. lvgl26 now offers `set<"value", "range">(...)` for several properties at once ([#303](https://github.com/filipsajdak/lvgl26/pull/303)). The 16 December post shows why an options struct links every setter at `-Os`, and when it does not. + +## Step 6: fixed cost against cost per widget + +The slice has three widgets, so its numbers mix two things: what the library costs once and what each widget costs. A generator added N more label and arc pairs to both programs, for N = 0, 4 and 16: + +| | flash N = 0 / 4 / 16 | flash per pair | heap per pair | +|---|---|---|---| +| lvgl26 BEFORE | 283,724 / 285,096 / 287,356 | 188.3 | 453.3 | +| lvgl26 AFTER | 247,000 / 247,312 / 248,132 | 68.3 | 453.3 | +| plain C | 244,472 / 244,692 / 245,380 | 57.3 | 468.3 | + +The slope had its own cause, found with objdump on `main`. For each property, the mount copied a 20 to 24 byte constant to the stack and called a generic function with its address. C passes the value in a register and calls the setter. The fix calls a constant property's setter with its value, as C does ([#307](https://github.com/filipsajdak/lvgl26/pull/307)). Between the two states the slope went from 188.3 to 68.3 bytes per pair. + +The other fixes were build settings. A prefix map removed the home paths ([#304](https://github.com/filipsajdak/lvgl26/pull/304)). With [#306](https://github.com/filipsajdak/lvgl26/pull/306) lvgl26 compiles with `-flto`, which is what makes the full-LTO row possible. With [#305](https://github.com/filipsajdak/lvgl26/pull/305) a program can leave LVGL's flex layout out. The slice still uses flex, so that fix does not change its numbers. + +## Step 7: a size gate + +A size regression is silent. Nothing fails, and the flash fills up one change at a time. `sizegate.py` reads the output of `size` and compares it with a budget in bytes: + +```json +{ + "warn": 256, "block": 1024, + "baseline": {"slice.elf": {"flash": 247000, "ram": 73208}}, + "gap": {"a": "slice.elf", "b": "slice_c.elf", "max": 3040} +} +``` + +The gap check compares lvgl26 with the C program from the same build. A newer LVGL or compiler then moves both, and only a change of mine moves the gap. On the AFTER build every line passes. Fed the BEFORE build, all three block: + +```text +BLOCK slice.elf flash: 283724 (+36724 against 247000) +BLOCK slice.elf ram: 77240 (+4032 against 73208) +BLOCK gap slice.elf - slice_c.elf: +39252 flash (max +3040) +``` + +lvgl26 has no such gate yet. Section 8 of its [research note](https://github.com/filipsajdak/lvgl26/blob/3a23a478ca2593d4d6517e8d7854f6a4ae72cb15/docs/research/size-vs-c.md) proposes one with these limits for the nightly Arm job. The note is dated 28 November, so its totals predate the six fixes. + +## Where lvgl26 is better than C, and where it is not + +On flash, lvgl26 now matches C; it does not beat it. The program is 2,528 bytes larger as shipped, and each label and arc pair costs 68.3 bytes against C's 57.3. + +On heap per widget it is lower: 453.3 bytes per pair against 468.3, because constant label text is not copied. With four style properties on every widget, at 16 pairs, lvgl26 used 8,636 bytes of heap. C that sets local styles on each widget used 10,140, so lvgl26 needs 15 % less. C that shares one style object used 8,836, only 2 % more than lvgl26. + +The repeating task costs more: a coroutine frame takes 128 bytes of LVGL's heap, where C's timer takes 36. The research note expects those 92 bytes to stay, because the library cannot size a coroutine frame at compile time. + +Episode 16 of the lvgl26 series, on 12 January, compares lvgl26 and the C program in full.