This one walks you through GCC flag selection for different build modes: debug with `-g -Og`, release with `-O2` or `-O3 -march=native`, size-optimized with `-Os`, and sanitizer builds. It covers LTO and PGO workflows step by step, warning flag discipline with `-Wall -Wextra`, and a triage table for common errors like undefined references and ABI mismatches. The optimization decision tree is practical, especially the note that `-O3` can regress performance due to instruction cache pressure. If you've ever second-guessed whether to enable `-flto` or wondered why `-Ofast` broke your floating point math, this gives you the exact invocations and explains the tradeoffs without the usual compiler flag folklore.
- skills.sh installs
- 741
- GitHub stars
- 279
- last updated
- Aug 21, 2026
Install
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill gcc --agent claude-codeInstalls into .claude/skills of the current project.
Files
GCC
Purpose
Guide agents through GCC invocation: flag selection, build modes, warning triage, PGO, LTO, and common error patterns. Assume the project uses GNU Make, CMake, or a shell script.
Triggers
- "What flags should I use for a release build?"
- "GCC is giving me a warning/error I don't understand"
- "How do I enable LTO / PGO with GCC?"
- "How do I compile with
-fsanitize?" - "My binary is too large / too slow"
- Undefined reference errors, ABI mismatch, missing symbols
Workflow
1. Choose a build mode
| Goal | Recommended flags |
|---|---|
| Debug | -g -O0 -Wall -Wextra |
| Debug + debuggable optimisation | -g -Og -Wall -Wextra |
| Release | -O2 -DNDEBUG -Wall |
| Release (max perf, native only) | -O3 -march=native -DNDEBUG |
| Release (min size) | -Os -DNDEBUG |
| Sanitizer (dev) | -g -O1 -fsanitize=address,undefined |
Always pass -std=c11 / -std=c++17 (or the required standard) explicitly. Never rely on the implicit default.
2. Warning discipline
Start with -Wall -Wextra. For stricter standards compliance add -Wpedantic. To treat all warnings as errors in CI: -Werror.
Sponsors
Details
- Repository
- github.com/mohitmishra786/low-level-dev-skills
- Categories
- DevOps & CI/CD, Release Management, Debugging
- First seen
- Jun 3, 2026
More from mohitmishra786/low-level-dev-skills
All 54- Valgrind740
- Flamegraphs728
- Assembly X86724
- Strace Ltrace711
- Cpu Cache Opt709
- Assembly Arm707
- Lldb703
- Elf Inspection702
- Simd Intrinsics701
- Make697
- Memory Model693
- Freertos691
- Linux Kernel Modules689
- Ninja681
- Heaptrack676
- Rust Profiling673
- Ebpf672
- Msvc Cl671
- Fuzzing670
- Binutils665
- Linkers Lto663
- Conan Vcpkg659
- Dynamic Linking650
- Rust Security624
