Skip to content

Latest commit

 

History

History
101 lines (74 loc) · 2.49 KB

File metadata and controls

101 lines (74 loc) · 2.49 KB

Self-hosting Verification

Japanese | Docs index

The standard YCPL compiler, ycc, is implemented in YCPL. The C++ ycc-bootstrap executable is retained only as the initial seed and reference.

Generation Chain

ycc-bootstrap (C++)
    -> ycc-stage1 (YCPL)
    -> ycc-stage2 (YCPL)
    -> ycc-stage3 (YCPL)
    -> ycc
       └─ ycc-ycpl

Only stage1 is generated by C++. Stage1 generates stage2, stage2 generates stage3, and stage3 is promoted as the standard ycc.

Recommended Verification

Configure LLVM 22 and let Bazel generate every stage:

eval "$(scripts/setup-llvm.sh 22 --print-env)"

bazel build \
  //:ycc-bootstrap \
  //:ycc-stage1 \
  //:ycc-stage2 \
  //:ycc-stage3 \
  //:ycc \
  //:ycc-ycpl

bazel test //:self_host_stage_test //:ycc_ycpl_test
bazel test //...

The fixed-point test:

  1. Generates the compiler's LLVM IR with stage2 and stage3.
  2. Canonicalizes both through LLVM 22 llvm-as and llvm-dis.
  3. Stabilizes only ModuleID and source filename, then compares them exactly.
  4. Builds and runs hello with both stage2 and stage3.
  5. Applies the same expanding conformance suite to both compilers.
  6. Checks that promoted ycc contains no bootstrap/fallback route strings.

Build Only the C++ Bootstrap

eval "$(scripts/setup-llvm.sh 22 --print-env)"
bazel build //:ycc-bootstrap

The executable is bazel-bin/ycc-bootstrap. To generate the compiler project manually, run it with compiler/ycpl as the current directory:

mkdir -p /tmp/ycpl-stage1

(
  cd compiler/ycpl
  ../../bazel-bin/ycc-bootstrap build -o /tmp/ycpl-stage1
)

/tmp/ycpl-stage1/ycc check compiler/ycpl

Do not use ycc-bootstrap build compiler/ycpl ... directly from the repository root; that does not match the bootstrap driver's project-current-directory convention.

Build a YCPL Program with the YCPL Compiler

YCPL_STL_ROOT="$PWD/stl" \
YCPL_RUNTIME_SRC="$PWD/bootstrap/cpp/runtime/yc_runtime.c" \
/tmp/ycpl-stage1/ycc \
  build examples/basics/hello.yc -o /tmp/ycpl-hello

/tmp/ycpl-hello/merged

The expected output is Hello World. Normal use through bazel-bin/ycc or Bazel runfiles resolves these paths automatically:

bazel run //:ycc -- run examples/basics/hello.yc

Run Conformance Separately

tests/run_conformance.sh ./bazel-bin/ycc

The harness accepts any compiler executable and checks positive, negative, runtime, project/module, standard-library, and c/* FFI behavior against the same oracle.