{"id":50783539,"url":"https://github.com/luxumbris/c-shift","last_synced_at":"2026-06-28T08:00:35.782Z","repository":{"id":359429224,"uuid":"1212939164","full_name":"LuxUmbris/C-Shift","owner":"LuxUmbris","description":"C\u003c\u003c is designed to be safe without fighting the compiler, and easy to use without runtime abstractions. So it does not have a GC (Garbage Collector), Borrow Checker or similar things and is fully arena-based. The runtime is only a minimal C-file for the standard library.","archived":false,"fork":false,"pushed_at":"2026-06-20T20:05:24.000Z","size":1388,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-20T22:05:23.773Z","etag":null,"topics":["compiler","compiler-design","compilers","pogramming","programming-language","programming-languages","system","system-programming","systems-programming","systems-programming-language"],"latest_commit_sha":null,"homepage":"","language":"C++","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/LuxUmbris.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-04-16T22:10:24.000Z","updated_at":"2026-06-20T20:05:28.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/LuxUmbris/C-Shift","commit_stats":null,"previous_names":["luxumbris/c-shift"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/LuxUmbris/C-Shift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuxUmbris%2FC-Shift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuxUmbris%2FC-Shift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuxUmbris%2FC-Shift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuxUmbris%2FC-Shift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LuxUmbris","download_url":"https://codeload.github.com/LuxUmbris/C-Shift/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuxUmbris%2FC-Shift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34881384,"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-06-28T02:00:05.809Z","response_time":54,"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":["compiler","compiler-design","compilers","pogramming","programming-language","programming-languages","system","system-programming","systems-programming","systems-programming-language"],"created_at":"2026-06-12T05:30:56.864Z","updated_at":"2026-06-28T08:00:35.770Z","avatar_url":"https://github.com/LuxUmbris.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C\u003c\u003c (C-Shift)\n\n![C\u003c\u003c Logo](https://raw.githubusercontent.com/LuxUmbris/C-Shift/main/cll_logo.svg)\n\n[![Build](https://github.com/LuxUmbris/C-Shift/actions/workflows/build.yml/badge.svg)](https://github.com/LuxUmbris/C-Shift/actions/workflows/build.yml)\n\nAn LLVM-based compiler for a safe, arena-oriented systems language.\nC\u003c\u003c focuses on deterministic, zero-runtime behaviour and direct C-ABI interoperability.\n\n---\n\n## Quick Start\n\n```bash\n# Download a release and install\ntar -xzf cshift-*-linux-x86_64.tar.gz\nsudo ./install.sh              # system-wide (/usr/local)\n# or:\n./install.sh ~/.local          # user-local, no sudo needed\n```\n\n```cll\n// hello.cll\nimport std;\n\nentry\n{\n    puts(\"Hello, C\u003c\u003c world!\");\n}\n```\n\n```bash\ncshift hello.cll -o hello\n./hello\n```\n\n---\n\n## Building from Source\n\n### Prerequisites\n\n| Platform | Required |\n|----------|----------|\n| Linux    | `llvm-18-dev`, `libclang-18-dev`, `cmake ≥ 3.16`, `ninja-build` |\n| macOS    | `brew install llvm cmake ninja` |\n| Windows  | msys2 ucrt64: `mingw-w64-ucrt-x86_64-llvm`, `cmake`, `ninja` |\n\n### Linux / macOS\n\n```bash\n./rebuild.sh            # Release build → build/cshift\n./rebuild.sh debug      # Debug build\n./rebuild.sh clean      # Wipe build dir and rebuild\n```\n\nOr manually:\n\n```bash\ncmake -S . -B build -G Ninja \\\n    -DCMAKE_BUILD_TYPE=Release \\\n    -DCSHIFT_LINK_STATIC=ON          # statically link LLVM (default)\ncmake --build build\n```\n\n### Windows (msys2 / ucrt64)\n\nOpen the **UCRT64** msys2 shell:\n\n```bash\npacman -S mingw-w64-ucrt-x86_64-{gcc,cmake,ninja,llvm,llvm-libs,clang,clang-libs,zlib,zstd}\n\ncmake -S . -B build -G Ninja \\\n    -DCMAKE_BUILD_TYPE=Release \\\n    -DLLVM_DIR=\"$(llvm-config --cmakedir)\"\ncmake --build build\n```\n\n### CMake options\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `CSHIFT_LINK_STATIC` | `ON` | Link LLVM + libstdc++ statically — portable binary |\n| `CSHIFT_BUNDLE_LIBCLANG` | `ON` | Copy `libclang.so` into the install tree |\n| `CSHIFT_PRECOMPILE_FRT` | `ON` | Pre-compile `frt.c` for every available cross-target |\n| `CSHIFT_BUNDLE_FRT` | `ON` | Install precompiled `frt.o` blobs |\n\n---\n\n## Compiler Flags\n\n```\nUsage: cshift \u003csource.cll\u003e [options]\n\nOptions:\n  -o \u003coutput\u003e          Output file\n  -O0 / -O1 / -O2 / -O3   Optimization level (default: -O0)\n  -Os / -Oz            Optimize for size / aggressively for size\n  --mcpu \u003ccpu\u003e         Target CPU  (e.g. skylake, cortex-a72)\n  --mattr \u003cfeatures\u003e   CPU feature flags  (e.g. +avx2,+bmi2)\n  --emit-llvm          Emit LLVM IR (.ll)\n  --emit-asm           Emit assembly (.s)\n  -c                   Compile to object file (.o), skip link\n  --target \u003ctriple\u003e    Cross-compile target triple\n  --no-frt             Skip frt.o linking\n  --check-only         Lex + parse + type-check only, no codegen\n  -l\u003clib\u003e              Pass -l\u003clib\u003e to the linker  (e.g. -lm)\n  -Wl,\u003cflag\u003e           Pass raw flag to the linker\n  --link-flag \u003cf\u003e      Pass raw linker flag\n  --verbose / -v       Print resolution steps to stderr\n```\n\n---\n\n## Module System\n\nModules are real separately-parsed translation units, not text copy-paste.\nEach file is parsed exactly once per compilation; duplicate imports are silently deduplicated.\n\n```cll\nimport std;                   // standard library module\nimport \"path/to/mylib.cll\";   // file import (relative to source)\nimport io::file;              // namespace::module path\n```\n\n### C-Header Import\n\nDirect import of C headers via libclang — no hand-written wrapper needed:\n\n```cll\nimport \u003cstdio.h\u003e;             // system header (angle brackets)\nimport \u003cmath.h\u003e;\nimport \"vendor/mylib.h\";      // local header (quoted)\n```\n\nThis parses the header with libclang and generates the appropriate `import` declarations automatically. Requires `libclang` at build time; falls back to a runtime warning if absent.\n\n### Manual C-ABI Import\n\nFor one-off declarations without a header:\n\n```cll\nimport int32  printf(string fmt, ...);\nimport voided free(voided* ptr);\nimport voided* malloc(uint64 size);\n```\n\n---\n\n## Standard Library\n\n`import std;` provides 16+ generic containers — all monomorphized at compile time.\n\n| Container | Description |\n|-----------|-------------|\n| `Vector\u003cT\u003e` | Dynamic array (chunk-based, zero-copy allocation) |\n| `HashMap\u003cK,V\u003e` | Hash table with chaining |\n| `LinkedList\u003cT\u003e` | Doubly-linked list |\n| `Set\u003cT\u003e` | Hash set |\n| `Deque\u003cT\u003e` | Double-ended queue (ring buffer) |\n| `RingBuffer\u003cT\u003e` | Fixed-size circular buffer |\n| `Pool\u003cT\u003e` | Object pool for allocation-free patterns |\n| `Pair\u003cA,B\u003e` | Simple tuple |\n| `Lazy\u003cT\u003e` | Compute-on-demand caching |\n| `BitSet` | Compact bitfield |\n| `Guard` | RAII scope guard |\n| `StringBuilder` | Chunked string building |\n| `Buffer\u003cT\u003e` | Typed buffer with capacity |\n| `SortedVec\u003cT\u003e` | Sorted container with custom comparator |\n\nThe parsed standard library is cached as `~/.cache/cshift/bc/std.bc` — subsequent builds skip re-parsing.\n\n---\n\n## Install \u0026 Uninstall\n\n### Tarball (Linux / macOS)\n\n```bash\n# Install (default: /usr/local)\nsudo ./install.sh\n# or user-local:\n./install.sh ~/.local\n\n# Uninstall\nsudo ./uninstall.sh\n# or:\n./uninstall.sh ~/.local\n```\n\nThe installer:\n- Detects and removes any previous cshift installation at the target prefix.\n- Records an install manifest (`share/cshift/.install_manifest`) for clean removal.\n- Adds `CSHIFT_STD_PATH` and `PATH` entries to your shell rc file.\n\nThe uninstaller reads the manifest and removes every installed file, then prunes empty directories, and strips the shell rc entries.\n\n### Windows\n\n```powershell\n# User-local (no elevation needed):\n.\\install.ps1\n\n# System-wide (run PowerShell as Administrator):\n.\\install.ps1 -InstallDir \"C:\\Program Files\\cshift\"\n\n# Uninstall (auto-detects install dir):\n.\\uninstall.ps1\n```\n\n### Debian / Ubuntu package\n\n```bash\n# Build the .deb (from the build directory after cmake):\ncpack -G DEB\n\n# Install (removes any old version first via preinst):\nsudo dpkg -i cshift-*.deb\n\n# Remove:\nsudo dpkg -r cshift\n\n# Purge (also removes config and cache):\nsudo dpkg --purge cshift\n```\n\n### cmake uninstall target\n\n```bash\n# After cmake --install:\ncmake --build build --target uninstall\n```\n\n---\n\n## Language Overview\n\nSee [`Syntax_spec.md`](Syntax_spec.md) for the full specification.\n\n### Hello World\n\n```cll\nimport std;\n\nentry\n{\n    puts(\"Hello, C\u003c\u003c world!\");\n}\n```\n\n### Functions and Tunnels\n\nFunctions have no return type. Values are passed back via *tunnels*:\n\n```cll\ndef add(int32 x, int32 y)\n{\n    tunnel x + y -\u003e int32 result;\n}\n\nentry\n{\n    reserve int32 result = add(5, 7);\n    printf(\"%d\\n\", result);\n}\n```\n\n### Structs\n\n```cll\nstruct Player\n{\n    int32   id;\n    float32 health;\n    string  name;\n}\n```\n\n### Templates\n\n```cll\ntemplate\u003ctypename T\u003e\nstruct Pair\n{\n    T first;\n    T second;\n}\n\ntemplate\u003ctypename T\u003e\ndef pair_sum(Pair\u003cT\u003e* p)\n{\n    tunnel p-\u003efirst + p-\u003esecond -\u003e T result;\n}\n```\n\n### VOP (Vertical Ownership Programming)\n\nC\u003c\u003c uses arena-based memory instead of GC or borrow checker:\n\n1. A pointer must only point to a variable whose arena depth ≤ the pointer's depth.\n2. Each `{ }` control-flow block is its own arena; when it exits, its variables are destroyed.\n3. Functions use tunnels instead of return values.\n4. `reset` clears the current arena (forbidden if child arenas hold pointers into it).\n5. `move` transfers ownership; the source becomes *voided*. Accessing a potentially-voided variable without a `switch` guard is a compile-time error.\n\n```cll\nentry\n{\n    int32  x = 42;\n    int32* p = \u0026x;\n    move x;           // x is now voided\n    switch (p)\n    {\n        case valid   { printf(\"value: %d\\n\", *p); }\n        case voided  { puts(\"pointer is voided\"); }\n    }\n}\n```\n\n### Control Flow\n\n`if` / `else`, `while`, `for`, `foreach`, `switch` / `case` / `default`, `break`, `continue`.\n\n### Raw Strings\n\n```cll\n// Delimiter form:\nstring banner = raw\u003cuntil \"END\"\u003e\n###################\n#  Hello, C\u003c\u003c !  #\n###################\nEND\n\n// Line-count form:\nputs(raw\u003c2\u003e\nLine one — backslashes \\n and nulls \\0 are literal here.\nLine two.\n);\n```\n\n---\n\n## Philosophy\n\nC\u003c\u003c is designed to be safe without fighting the compiler, and fast without runtime abstractions:\n\n- No garbage collector, no borrow checker — arena-based deterministic memory.\n- No exceptions, no virtual dispatch, no hidden allocations.\n- Full C-ABI interop: call any C library with zero overhead.\n- Cross-compilation to any LLVM-supported target.\n- Optimization levels from `-O0` (debug) to `-O3` / `-Os` / `-Oz`.\n\n---\n\n## License\n\n[Apache 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxumbris%2Fc-shift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluxumbris%2Fc-shift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluxumbris%2Fc-shift/lists"}