{"id":51592886,"url":"https://github.com/pinguy/c_optimizer","last_synced_at":"2026-07-11T16:01:05.941Z","repository":{"id":365355966,"uuid":"1271735414","full_name":"pinguy/c_optimizer","owner":"pinguy","description":"Tiny Linux demoscene/sizecoding C optimizer and runnable packer","archived":false,"fork":false,"pushed_at":"2026-06-17T02:57:14.000Z","size":110,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-17T03:14:53.378Z","etag":null,"topics":["c","demoscene","gcc","linux","optimizer","sizecoding","xz"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pinguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-17T00:58:55.000Z","updated_at":"2026-06-17T02:57:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pinguy/c_optimizer","commit_stats":null,"previous_names":["pinguy/c_optimizer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pinguy/c_optimizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinguy%2Fc_optimizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinguy%2Fc_optimizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinguy%2Fc_optimizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinguy%2Fc_optimizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pinguy","download_url":"https://codeload.github.com/pinguy/c_optimizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pinguy%2Fc_optimizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35367446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-11T02:00:05.354Z","response_time":104,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","demoscene","gcc","linux","optimizer","sizecoding","xz"],"created_at":"2026-07-11T16:01:03.935Z","updated_at":"2026-07-11T16:01:05.929Z","avatar_url":"https://github.com/pinguy.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C Optimizer\n\nC Optimizer turns a single C source file into a tiny runnable Linux executable wrapper.\n\nIt was built for demoscene / sizecoding projects like **VOIDRUNNER** and **nervk**: native Linux games or intros where the whole project lives in one `.c` file, assets are generated at runtime, and the release artefact is judged by bytes on disk.\n\n## What It Does\n\n- Opens a file picker for one `.c` file.\n- Builds that file with size-focused GCC flags.\n- Uses a tiny custom `_start` instead of normal startup files.\n- Strips and section-strips the ELF.\n- Searches several x86 BCJ + raw LZMA settings.\n- Emits a self-extracting runnable beside the source file.\n- Reports output sizes using the best-fit IEC unit plus exact bytes and bits.\n\nThe original `.c` file is left untouched.\n\n## What It Is For\n\nC Optimizer is aimed at projects with constraints like:\n\n- one translation unit\n- no external asset files\n- procedural textures, geometry, maps, audio, or UI generated in code\n- dynamic use of system libraries where useful\n- Linux x86_64 release builds where the final runnable size matters\n- fast iteration from a single C file to a releasable packed runner\n\nReference-style projects:\n\n- [VOIDRUNNER](https://github.com/pinguy/VOIDRUNNER) - a native Linux procedural space-trader / combat game released as a 32 KiB-class runnable.\n- [nervk](https://github.com/pinguy/murkk/releases/tag/nervk) - a sub-32KB native Linux procedural survival FPS game lineage with runtime-synthesized visuals, level, audio, and font data.\n\nThe `examples/` directory includes real single-file sources from that lineage:\n\n- `examples/VOIDRUNNER.c`\n- `examples/nervk.c`\n- `examples/ECHOHULL.c`\n\n## Quick Start\n\nFor a release-style build, pass the C file directly. The runnable is written beside the source file:\n\n```bash\n./build_gcc9_bullseye.sh nervk.c\n```\n\nThat writes:\n\n```text\n./nervk\n```\n\nThe GCC 9 wrapper uses a local Podman image so byte-chasing builds are more repeatable across hosts. The first run builds `localhost/c-optimizer-gcc9:bullseye`; later runs reuse it.\n\nFor the default host compiler instead:\n\n```bash\n./build_asm_syscall.sh nervk.c\n```\n\nFor a GUI file picker:\n\n```bash\n./run_c_optimizer.sh\n```\n\nDouble-clickable local launcher:\n\n```bash\n./install_desktop.sh\n```\n\nAfter installing the launcher, open **C Optimizer** from your application menu and choose a single C source file.\n\n## Requirements\n\nRequired:\n\n- Linux x86_64\n- `sh`\n- `gcc`\n- `strip`\n- `readelf`\n- `xz`\n- `python3`\n\nOptional:\n\n- `sstrip` for external section stripping. If missing, `tiny_tools/sstrip64.py` is used.\n- `kdialog` or `zenity` for the graphical file picker.\n- `notify-send` for desktop notifications.\n\n## Output\n\nGiven:\n\n```text\n/home/pingu/projects/demo.c\n```\n\nC Optimizer writes:\n\n```text\n/home/pingu/projects/demo\n```\n\nThe output is an executable shell stub with compressed ELF payload appended. Running it extracts the payload to `/tmp`, runs it, and exits with the wrapped program's exit status.\n\nThat shell runner is a sizecoding trade-off, not a hardened installer. It keeps the release artifact tiny, but it writes a predictable PID-based temporary path and needs an executable `/tmp`; hardened systems with `noexec` temporary directories can reject it. A `memfd_create`/`fexecve` loader would avoid disk extraction and noexec problems, but it would cost more stub bytes.\n\n## Try The Example\n\n```bash\n./build_gcc9_bullseye.sh examples/nervk.c\n```\n\nThat writes `examples/nervk`. Generated example runners are ignored by git.\n\nBuild the real examples:\n\n```bash\n./build_gcc9_bullseye.sh examples/nervk.c\n./build_gcc9_bullseye.sh examples/VOIDRUNNER.c\n./build_gcc9_bullseye.sh examples/ECHOHULL.c\n```\n\nTo send output somewhere else, set `OUT`:\n\n```bash\nOUT=release/nervk ./build_gcc9_bullseye.sh examples/nervk.c\n```\n\n## Why GCC 9?\n\nTiny packed C releases are sensitive to compiler version. The raw stripped ELF can be similar across GCC versions, while the final shell runner changes because x86 BCJ and LZMA compress different instruction layouts differently.\n\nOn the current reference machine:\n\n```text\nSource      Host GCC 16 runner   GCC 9 Bullseye runner   Saved\nnervk       31,841 bytes         31,472 bytes            369 bytes / 1.16%\nVOIDRUNNER  33,934 bytes         33,543 bytes            391 bytes / 1.15%\n```\n\nGCC 9 was the smallest tested toolchain for VOIDRUNNER and also made the included nervk example smaller. See [Toolchains](docs/TOOLCHAINS.md) for the compiler comparison table and wrapper details.\n\n## Documentation\n\n- [Usage](docs/USAGE.md)\n- [Demoscene Workflow](docs/DEMOSCENE-WORKFLOW.md)\n- [Examples](docs/EXAMPLES.md)\n- [Toolchains](docs/TOOLCHAINS.md)\n- [Build Pipeline](docs/BUILD-PIPELINE.md)\n- [Troubleshooting](docs/TROUBLESHOOTING.md)\n\n## License\n\nC Optimizer is licensed under the [MIT License](LICENSE).\n\nThe published example game sources under `examples/` are licensed under the [Apache License, Version 2.0](examples/LICENSE) and include attribution notes in [examples/NOTICE](examples/NOTICE).\n\nGenerated runners are output artifacts from your own C source. C Optimizer does not impose the MIT License on the programs you build with it.\n\n## Notes\n\nThis is intentionally narrow:\n\n- One C file in, one runnable out.\n- No multi-file project discovery.\n- No Make/CMake integration.\n- Linux x86_64 only.\n\nIt is a tiny release-build tool for tiny C productions, not a general C build system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinguy%2Fc_optimizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinguy%2Fc_optimizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinguy%2Fc_optimizer/lists"}