{"id":18781519,"url":"https://github.com/andrewchambers/c","last_synced_at":"2025-04-05T13:08:14.738Z","repository":{"id":33774175,"uuid":"37431317","full_name":"andrewchambers/c","owner":"andrewchambers","description":"small self hosting C compiler","archived":false,"fork":false,"pushed_at":"2021-10-21T17:05:42.000Z","size":508,"stargazers_count":480,"open_issues_count":16,"forks_count":59,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-03-29T12:08:27.644Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://acha.ninja","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewchambers.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}},"created_at":"2015-06-14T22:04:00.000Z","updated_at":"2025-03-28T23:30:26.000Z","dependencies_parsed_at":"2022-09-07T02:52:02.814Z","dependency_job_id":null,"html_url":"https://github.com/andrewchambers/c","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewchambers%2Fc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewchambers","download_url":"https://codeload.github.com/andrewchambers/c/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339158,"owners_count":20923014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-07T20:32:10.206Z","updated_at":"2025-04-05T13:08:14.713Z","avatar_url":"https://github.com/andrewchambers.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# A small, fast C compiler suite.\n\nNOTE - This project is not being actively developed. Please direct yourself to https://github.com/michaelforney/cc which\nis a successor that is more complete. I direct my own fixes to that project instead now.\n\n[![Join the chat at https://gitter.im/andrewchambers/c](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/andrewchambers/c?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n- Small.\n- Fast.\n- Consistent.\n- High quality.\n- Low complexity.\n- No dependencies.\n- No fussy configuration.\n- Painless cross compiling.\n- Just work.\n\nYou should be able to get a C compiler, assembler, linker and libc for any\nsupported target in less than 30 seconds.\n\n## Building\n\nRequires an external C compiler and gnu binutils (for now), and I have only tested\nit on linux 64 bit so far.\n\nThe code does use anonymous union extensions, so your compiler will need to support them too.\n\n```\n$ make\n```\n\n## Testing\n```\n$ make test\n$ make selfhost # self hosting\n```\n\n## Plan\n\n### Stage 1.\n\nSelf hosting x86_64, dumb backend.\n\n### Stage 2.\n\nSelf hosting arm, something like raspberry pi/android.\n\n### Stage 3.\n\nBuild small clean C code bases like 8cc, tcc, sbase.\n\n### Stage 4.\n\nBuild musl libc.\n\n### Beyond. \n\n- Build more programs.\n- Replace gnu as with our own assembler.\n- Replace ld with our own static linker.\n- Build OS kernels.\n- SSA backend.\n\n## Status\n\nPre stage 2. Self hosting with lots of missing common cases. Though technically these\nbugs can be fixed with the compiler itself :). It uses it's own stubbed out headers\nand cannot correctly process system headers yet (Help wanted). \n\n\n## Contributing\n\nProject on hold. See https://github.com/michaelforney/cc for a new compiler project that is more complete.\n\n### Code layout\n\n- Libraries are in src/*\n- Commands are in src/cmd/*\n\nIf you are unsure about the purpose of a library, check the header which\nshould give a short description.\n\n### Code style\n\nFollow Plan9 style conventions. Headers are not allowed to include\nother headers to eliminate circular dependencies and increase build speed.\nsrc/u.h is the only exception to this rule.\n\n- http://www.lysator.liu.se/c/pikestyle.html\n- http://plan9.bell-labs.com/magic/man2html/6/style\n- http://aiju.de/b/style\n\n### Bug fixes and issues\n\nTry and attach a single source file which exibits your issue. If possible\nreduce the test case by hand until it is as small as possible.\n\nTry and follow the general template changed where needed:\n```\nWhat are you trying to do:\n...\nWhat you expected to happen:\n...\nWhat actually hapened:\n...\n```\nTry and add a small self contained file which reproduces the issue.\n\nIn general each bug fix or change should add a test file which triggers the bug.\n\n### Memory management\n\nThe compiler does not explicitly free memory. Peak memory usage while self hosting\nis approximately 2Mb, so it should not be an issue, even for planned targets/hosts like\nthe raspberry pi.\n\n This actually simplifies the code and probably makes it faster because allocations can be pointer bumps.\n\n## Useful Links\n\n- C11 standard final draft http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf\n- Dave Prosser's C Preprocessing Algorithm http://www.spinellis.gr/blog/20060626/\n- The x86-64 ABI http://www.x86-64.org/documentation/abi.pdf\n- http://aiju.de/rant/cross-compiling\n- http://bellard.org/tcc/\n- https://github.com/rui314/8cc\n- http://harmful.cat-v.org/software/\n- http://suckless.org/philosophy\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewchambers%2Fc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewchambers%2Fc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewchambers%2Fc/lists"}