Skip to content

1 1 getting started and build system

TransCompilator edited this page Nov 26, 2026 · 1 revision

1.1 Getting Started and Build System

Source: https://deepwiki.com/PonvasanthPon/TransCompilator/1-1-getting-started-and-build-system

Getting Started and Build System

Relevant source files

The following files were used as context for generating this wiki page:

Purpose and Scope

This page documents the build system, Cargo workspace topology, offline/zero-dependency constraints, build scripts (build.rs), Makefile development targets, and continuous integration (CI) workflow for the tc_r1 compiler workspace. The build system enforces strict invariants: zero network access during compilation/testing, absence of machine-learning (ML) model dependencies or runtime web services, and reproducible static binary generation.


Cargo Workspace Layout and Topology

The repository is structured as a Cargo workspace managed by Cargo.toml Cargo.toml:1-13 and pinned via Cargo.lock Cargo.lock:1-81. The workspace contains exactly nine local packages (tc-*), with no external registry crates or remote dependency resolutions permitted during normal builds.

graph TD
    subgraph "Workspace Root Cargo.toml"
        Workspace["Workspace [workspace]"]
    end

    subgraph "CLI & Editors"
        tc_cli["crates/tc-cli"]
        tc_editor["crates/tc-editor"]
        tc_lsp["crates/tc-lsp"]
    end

    subgraph "Compactor Pipeline & Frontend"
        tc_syntax["crates/tc-syntax"]
        tc_semantics["crates/tc-semantics"]
        tc_typeck["crates/tc-typeck"]
        tc_lexicon["crates/tc-lexicon"]
    end

    subgraph "Backend & IR"
        tc_ir["crates/tc-ir"]
        tc_codegen["crates/tc-codegen-x86"]
    end

    Workspace --> tc_cli
    Workspace --> tc_editor
    Workspace --> tc_lsp
    Workspace --> tc_syntax
    Workspace --> tc_semantics
    Workspace --> tc_typeck
    Workspace --> tc_lexicon
    Workspace --> tc_ir
    Workspace --> tc_codegen

    tc_cli --> tc_codegen
    tc_cli --> tc_editor
    tc_cli --> tc_ir
    tc_cli --> tc_lexicon
    tc_cli --> tc_semantics
    tc_cli --> tc_syntax
    tc_cli --> tc_typeck

    click tc_cli "crates/tc-cli" "Command-line driver"
    click tc_ir "crates/tc-ir" "Core-7 IR"
    click tc_lexicon "crates/tc-lexicon" "Lexical tables"
Loading

Figure 1.1.1: Workspace topology showing local intra-workspace dependencies among tc-* crates.

Sources: Cargo.toml:[1-13](), Cargo.lock:[1-82]()


Makefile Targets and Development Workflow

Development tasks are standardized through the root Makefile Makefile:1-67. The Makefile exposes targets for compilation, linting, formatting verification, test execution, editor/LSP launchers, and the strict --audit security/determinism scanner.

Target Command Description
build $(CARGO) build --workspace Compiles all workspace crates in debug mode.
release $(CARGO) build --workspace --release Compiles optimized release binaries.
test $(CARGO) test --workspace Executes unit, integration, and parity test suites.
lint $(CARGO) clippy --workspace ... Runs Clippy with strict workspace lints (-D warnings).
fmt-check $(CARGO) fmt --all -- --check Validates code formatting against rustfmt.
selftest ./target/debug/tc --selftest Invokes the built-in compiler self-test suite.
audit Custom checks Runs the static determinism, dependency, and ML-free audit.
clean $(CARGO) clean Removes build artifacts from target/.

Sources: Makefile:[1-67]()


Offline and Zero-Dependency Constraints

To preserve determinism and eliminate supply-chain attack vectors, the build system enforces strict offline and zero-dependency constraints, verified automatically by make audit Makefile:35-64 and CI workflows .github/workflows/ci.yml:17.

  1. Local-Only Dependencies: All dependencies in Cargo.toml use explicit path = ... specifiers Cargo.toml:1-13. Cargo.lock contains zero registry sources, checksums, or external git repositories Makefile:51-57.
  2. No Machine Learning Assets: The audit script scans the directory tree (excluding .git and target) for forbidden file extensions such as .onnx, .pt, .binlm, .mem, .hmm, .gguf, and .safetensors Makefile:37-39.
  3. No External Runtime Services: Network scanners check that workspace sources contain no references to HTTP servers, HTML rendering engines, or external socket listeners (TcpListener, frontend.html, xdg-open, etc.) Makefile:58-60.
graph TD
    subgraph "Audit Pipeline Makefile audit"
        AuditStart["make audit"] --> CheckML["Check ML Models .onnx .pt .safetensors"]
        CheckML --> CheckPaths["Check Cargo.toml path = ... only"]
        CheckPaths --> CheckExt["Check Cargo.lock local tc-* packages only"]
        CheckExt --> CheckWeb["Check crates/*/src for TcpListener or http/https"]
        CheckWeb --> AuditPass["Audit PASS"]
    end

    click AuditStart "Makefile" "Audit target definition"
Loading

Figure 1.1.2: Audit verification workflow ensuring zero-ML, local-only path constraints.

Sources: Makefile:[35-64](), Cargo.toml:[1-13]()


Link Grammar FFI and Build Scripts (build.rs)

The compiler front-end integrates with the vendored CMU Link Grammar parser (vendor/link-grammar/) THIRD_PARTY_NOTICES.md:7-15 via FFI. Because Link Grammar requires native shared libraries (liblink-grammar.so), companion build.rs scripts in crates/tc-cli crates/tc-cli/build.rs:1-19 and crates/tc-semantics crates/tc-semantics/build.rs:1-23 configure dynamic linker run-paths (-Wl,-rpath).

The build scripts emit cargo:rustc-link-arg directives ensuring binaries locate the vendored library relative to $ORIGIN across nested output directories:

for depth in 2..=6 {
    let origin = "../".repeat(depth);
    println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN/{origin}vendor/link-grammar/lib");
}

crates/tc-cli/build.rs:11-14, crates/tc-semantics/build.rs:15-18

Sources: crates/tc-cli/build.rs:[1-20](), crates/tc-semantics/build.rs:[1-24], THIRD_PARTY_NOTICES.md:[7-15]()


Continuous Integration (CI) Workflow

The GitHub Actions workflow .github/workflows/ci.yml executes on every push and pull request to main .github/workflows/ci.yml:1-7. Operating with CARGO_NET_OFFLINE: "true" .github/workflows/ci.yml:17, the CI pipeline runs:

graph TD
    subgraph "CI Workflow ci.yml"
        Checkout["actions/checkout@v4"] --> Toolchain["dtolnay/rust-toolchain@stable"]
        Toolchain --> Format["make fmt-check"]
        Format --> Lint["make lint"]
        Lint --> Build["make build (offline)"]
        Build --> Test["make test"]
        Audit --> CompilerAudit["tc --audit"]
        Build --> Audit["make audit"]
        Test --> Selftest["tc --selftest"]
        CompilerAudit --> Repro["Reproducible ELF64 Build Check"]
        Selftest --> Repro
    end

    click Checkout ".github/workflows/ci.yml" "CI workflow definition"
Loading

Figure 1.1.3: Continuous integration job sequence enforcing format, lint, offline build, audit, and binary reproducibility.

Sources: .github/workflows/ci.yml:[1-53]()


File Exclusion and Artifact Control (.gitignore)

The repository .gitignore rules prevent build products, intermediate assembly files, interpreter logs, and editor-specific build artifacts from entering version control .gitignore:1-16. Excluded patterns include the workspace target directory (/target/), object files (*.o, *.s, *.elf), Python caches (__pycache__/), and Zed extension compilation directories (editors/zed/tc-eng-extension/target/) .gitignore:1-16.

Sources: .gitignore:[1-17]()


Clone this wiki locally