Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/chen3feng/agent-skills/per-function-optimize-attribute-abi-mismatchnpx skills add chen3feng/agent-skills --skill per-function-optimize-attribute-abi-mismatchgit clone --depth 1 https://github.com/chen3feng/agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/chen3feng/agent-skills/per-function-optimize-attribute-abi-mismatch)<a href="https://agentmods.dev/skills/chen3feng/agent-skills/per-function-optimize-attribute-abi-mismatch"><img src="https://agentmods.dev/badge/skills/chen3feng/agent-skills/per-function-optimize-attribute-abi-mismatch.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00041 | $0.01699 |
| Opus 5 | $0.00020 | $0.00849 |
| Sonnet 5 | $0.00008 | $0.00340 |
| Haiku 4.5 | $0.00004 | $0.00170 |
Grade A, and why
per-function-optimize-attribute-abi-mismatch scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 170 lines — stays where its author put it; the contents beside it link to each section on GitHub.
__attribute__((optimize("O0"))) silently breaks the ABI on GCC
When to use
You're trying to isolate a miscompile in a single helper function by
forcing it to lower optimization, using one of these forms inside a
translation unit that is otherwise built at -O2 or higher:
__attribute__((optimize("O0")))
static void Helper(uint8_t* Dst, const uint8_t* Src, int N) { ... }
or equivalently:
#pragma GCC push_options
#pragma GCC optimize("O0")
static void Helper(...) { ... }
#pragma GCC pop_options
and the program now crashes — usually SIGSEGV — on the first call
into Helper, before any of its body runs, even though the same code
worked at -O2.
Problem
GCC's per-function optimize attribute changes the optimization
level of the callee, but it does not re-align the ABI between
that callee and its -O2 caller. Concretely:
-O0GCC emits a full stack frame with a frame pointer, spills all arguments to memory, and does not use the x86-64 SysV red zone.-O2GCC elides the frame pointer, keeps arguments in registers, and may use the red zone.- The caller, built at
-O2, passes arguments and return address under-O2assumptions. The callee reads them under-O0assumptions. The mismatch shows up as reading0or garbage from a pointer argument, or a segfault on return (frame pointer mismatch).
Crucially, there is no compiler warning. The attribute silently produces a working-looking binary that crashes at runtime.
On Clang, __attribute__((optnone)) exists and is better-behaved
about this, but it's also more restrictive (disables all opts, not
just some) and is not a fix-by-dropping-level tool.
Solution
If you really need one function at a lower optimization level, pick one of these, in order of preference:
- Don't. If you reached for
optimize("O0")to diagnose a miscompile, see stop-chasing-the-optimizer-reduce-instead — reduce the repro and fix the real bug (usually UB) instead. - Isolate the function in its own TU, compiled at
-O1. MoveHelperintohelper.cppand add a per-file flag in the build system:
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 6d ago First seen · 170 lines · 0 tokens per session scan A 4abeb8b6573e
per-function-optimize-attribute-abi-mismatch is a skill published in the GitHub repository chen3feng/agent-skills (5 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 41 tokens to every session and 1,699 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
cpp-pro
Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management — or when addressing performance…
memory-safety-patterns
Implement memory-safe programming with RAII, ownership, smart pointers, and resource management across Rust, C++, and C. Use when writing safe systems code, managing resources, or preventing memory bugs.
cpp
Comprehensive C/C++ programming reference covering everything from C11-C23 and C++11-C++23, system programming, CUDA GPU computing, debugging tools, Rust interop, and advanced topics. Use for: C/C++ questions, C/C++ interview preparation, modern language features, RAII/memory management, templates/generics, CUDA…
fix-cppheaders
Use when hl2sdkcs2 C++ headers must be repaired to match the latest vtable or record-layout YAML references. Runs runcpptests.py to obtain layout diffs, maps failing cpptests entries to their configured headers, edits only those headers, and repeats validation until the differences are resolved. Triggers: fix cpp…
cuda-c-optimization
CUDA C 性能优化、数值稳定性和调试排查.
cpp-debugging
Use when a C++ failure involves memory lifetime, undefined behavior, native crashes, or debugger-only state — debug with symbols, sanitizers, and platform-native debuggers before patching symptoms.