Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
K

kecc-public

> 编程语言
Open source

KECC: KAIST Educational C Compiler. IMPORTANT: DON'T FORK!

186 stars0 likes1 views
WebsiteGitHub

About

KECC: KAIST Educational C Compiler. IMPORTANT: DON'T FORK!

KECC: KAIST Educational C Compiler

Install

Install rustup.

Build

bash
cargo build            # debug build
cargo build --release  # release build

Documentation

bash
cargo doc --document-private-items          # built in target/doc
cargo doc --open --document-private-items   # opens in default broswer. Firefox or Chrome recommended.

Run

…

For more information, please refer to the KECC User's Manual.

Test

…

RUST_MIN_STACK=33554432 is necessary for deep call stack for irgen tests.

Fuzzing

We encourage you to do homework using the test-driven development (TDD)approach. You will randomly generate a test input, and if it fails, reduce it as much as possible and manually inspect the reduced test input. For example:

bash
# Randomly generates test inputs and tests them
python3 tests/fuzz.py 

# Reduces the failing test input as much as possible
python3 tests/fuzz.py  --reduce

# Fix your code for the reduced test input
cat tests/test_reduced.c

`` can be --print or --irgen. It shall be the one used in Run. For more information, please refer to the Fuzzer User's Manual.

Install

bash
# Ubuntu 20.04
sudo apt install -y build-essential clang make cmake python3 csmith libcsmith-dev creduce
pip3 install tqdm

Run

The following script generates 10 random test cases and tests your C AST printer:

bash
python3 tests/fuzz.py --help        # print options
python3 tests/fuzz.py --print -n10  # test C AST printer for 10 times

We use csmith to randomly generate C source codes. csmith will be automatically downloaded and built by the test script. For more information, we refer to the Csmith homepage.

Reduce

When the fuzzer finds a buggy input program for your compiler, the input program is likely too big to manually inspect. We use creduce that reduces the buggy input program as much as possible.

Suppose tests/test_polished.c is the buggy input program. Then the following script reduces the program to tests/test_reduced.c:

bash
python3 tests/fuzz.py  --reduce

`` can be --print or --irgen. It shall be the one used in Run.

How does it reduces the test case?

The script performs unguided test-case reduction using creduce: given a buggy program, it randomly reduces the program; check if the reduced program still fails on the test, and if so, replaces the given program with the reduced one; repeat until you get a small enough buggy program. For more information, we refer to the Creduce homepage.

[NOTICE] The fuzzer only supports Ubuntu 20.04. It may work for other platforms, but if it doesn't, please run the fuzzer in Ubuntu 20.04.

Running RISC-V Binaries

RISC-V Documentation

  • ISA:
  • ELF calling convention:

Install

bash
# Ubuntu 20.04
sudo apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu qemu-user-static gdb-multiarch

Cross-Compilation and Architecture-Emulation

bash
# Compile C source code into RISC-V assembly
riscv64-linux-gnu-gcc hello.c -S -fsigned-char -o hello.S

# Link to an RISC-V executable
riscv64-linux-gnu-gcc -static hello.S -o hello

# Emulate the executable
qemu-riscv64-static ./hello

# Check the return value
echo $?

Debugging Assembly

You can use QEMU's debugging facilities to investigate whether the generated assembly works correctly.

Open two terminal windows. In one, compile the assembly with -ggdb option and start up a gdb server with 8888 port. (If 8888 is already in use, then try with a different port like 8889, 8890, ...)

bash
# Link to an RISC-V executable with `-ggdb` option
riscv64-linux-gnu-gcc -ggdb -static hello.S -o hello

# Emulate the executable and wait for a debugging connection from GDB
qemu-riscv64-static -g 8888 hello

In the second terminal, run gdb-multiarch and set some configurations. You should see something like this,

…

Now you can debug the assembly using the GDB commands. For more information on GDB commands, see:

  • Full guide: http://sourceware.org/gdb/current/onlinedocs/gdb/
  • Cheatsheet: https://cs.brown.edu/courses/cs033/docs/guides/gdb.pdf

Run Benchmark for Performance Competition

bash
cd bench
make run

Submission

  • Submit the corresponding files to gg.kaist.ac.kr.
  • Run ./scripts/make-submissions.sh to generate irgen.zip to final.zip, which you should submit for homework 2 to the final project.

Running on a local machine

  • https://github.com/kaist-cp/cs420/issues/314
  • https://github.com/kaist-cp/cs420/issues/460

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言