1
0
Fork 0
C compiler built from the bones of tcc. Meant to allow Go/Odin-like builds of C projects.
  • C 95.3%
  • Assembly 2.4%
  • Makefile 1%
  • C++ 0.5%
  • Shell 0.4%
  • Other 0.4%
Find a file
2026-02-05 06:37:15 -06:00
bench Begin work on optimization passes 2026-02-05 06:37:15 -06:00
examples Rebrand TCC to SCC (Sharkk C Compiler) 2026-01-26 15:05:05 -06:00
include Add really awesome, convenient source detection to the compiler CLI 2026-02-02 13:16:28 -06:00
lib Implement Go-style CLI with subcommands 2026-01-27 21:55:50 -06:00
src Begin work on optimization passes 2026-02-05 06:37:15 -06:00
tests Implement Go-style CLI with subcommands 2026-01-27 21:55:50 -06:00
win32 Complete C99 standard headers audit 2026-01-27 07:32:55 -06:00
.gitignore Rebrand TCC to SCC (Sharkk C Compiler) 2026-01-26 15:05:05 -06:00
CLAUDE.md Update documentation 2026-01-26 21:03:35 -06:00
CodingStyle CodingStyle: Remove reference to misaligned struct CString. 2016-01-06 19:09:28 +00:00
configure Rebrand TCC to SCC (Sharkk C Compiler) 2026-01-26 15:05:05 -06:00
conftest.c Rebrand TCC to SCC (Sharkk C Compiler) 2026-01-26 15:05:05 -06:00
license.md Update docs 2026-01-27 20:04:44 -06:00
Makefile Add really awesome, convenient source detection to the compiler CLI 2026-02-02 13:16:28 -06:00
optclash tcc options: document behavior and clashes (no-op) 2025-10-27 14:50:54 +02:00
readme.md Add really awesome, convenient source detection to the compiler CLI 2026-02-02 13:16:28 -06:00
scc-doc.texi Rebrand TCC to SCC (Sharkk C Compiler) 2026-01-26 15:05:05 -06:00
stab.def Revert all of my changes to directories & codingstyle. 2015-07-29 16:57:12 -04:00
tcc-doc.info Update documentation 2026-01-26 21:03:35 -06:00
texi2pod.pl Revert all of my changes to directories & codingstyle. 2015-07-29 16:57:12 -04:00
TODO testing 2025-07-21 00:48:51 -03:00
todo-opti.md work on optimizations 2026-01-27 12:12:15 -06:00
todo.md Add restrict qualifier tracking 2026-01-27 08:35:51 -06:00
USES configury update & bump VERSION to 0.9.28rc 2023-09-06 22:42:52 +02:00
VERSION Reset version to 0.1.0 for SCC fork 2026-01-26 15:06:42 -06:00

Sharkk C Compiler

A hard fork of TCC, using it as a building block for a C compiler that approaches the ease of use of self-contained compilers like those for Go and Odin.

Installation

./configure
make
make install

CLI Usage

SCC uses Go-style subcommands for a clean, intuitive interface.

Commands

Command Description
build Compile source files to executable
run JIT compile and run
obj Compile to object file
pp Preprocess only
lib Build shared library
ar Archive tool
version Show version
help Show help

Build

Compile source files to an executable.

scc build file.c                    # Output: a.out
scc build -o myapp file.c           # Output: myapp
scc build -g -O2 file.c             # With debug info and optimization
scc build file.c -lm -lpthread      # Link with libraries

Run

JIT compile and execute immediately.

scc run file.c                      # Compile and run
scc run file.c -- arg1 arg2         # Pass arguments to program
scc run -DDEBUG file.c              # With macro definition

Object Files

Compile to object files for later linking.

scc obj file.c                      # Output: file.o
scc obj -o custom.o file.c          # Custom output name
scc obj file1.c file2.c             # Multiple files

Preprocess

Run the preprocessor only.

scc pp file.c                       # Output to stdout
scc pp -o file.i file.c             # Output to file
scc pp -P file.c                    # Without line markers

Shared Libraries

Build shared libraries (.so/.dll).

scc lib -o libfoo.so foo.c          # Build shared library
scc lib -o libfoo.so foo.c -lm      # With dependencies

Archive Tool

Create and manage static libraries.

scc ar rcs libfoo.a foo.o bar.o     # Create archive
scc ar t libfoo.a                   # List contents
scc ar x libfoo.a                   # Extract

Common Flags

Flag Description
-o FILE Output file
-g Generate debug info
-O[0-3] Optimization level
-I DIR Add include path
-D NAME[=VAL] Define macro
-U NAME Undefine macro
-L DIR Add library path
-l LIB Link library
-W NAME Warning option
-static Static linking
-pthread Enable pthreads
-std=VERSION C standard (c11, gnu11)
-v Verbose output
-w Suppress warnings
-B DIR Set compiler paths
--project DIR Set project root explicitly
--no-auto-paths Disable automatic path detection

Project Detection

SCC automatically detects project structure and infers include/library paths, similar to Go and Odin. This eliminates the need for explicit -I flags in most cases.

How It Works

When you run scc build or scc run, the compiler walks up the directory tree looking for project markers:

  • scc.toml (explicit project file - highest priority)
  • .git or .hg (version control roots)
  • Makefile or CMakeLists.txt (build system markers)

Once a project root is found, these paths are automatically added if they exist:

Directory Added to Purpose
{root}/include/ Include paths Project headers
{root}/src/ Include paths Source-relative includes
{root}/vendor/ Include paths Third-party code
{root}/lib/ Library paths Project libraries

Directory Compilation

You can pass a directory instead of individual files to compile all .c files within it:

scc build src/ -o myapp              # Compile all .c files in src/
scc build src/ lib/ -o myapp         # Multiple directories

Implicit Directory Mode

When no files are specified, SCC will compile the project automatically:

cd myproject
scc build -o myapp                   # Compiles src/*.c (or project root if no src/)

Example Project Structure

myproject/
├── .git/                 # Project root marker
├── include/
│   └── mylib.h          # Auto-added to include path
├── src/
│   ├── main.c
│   └── utils.c
└── vendor/
    └── json/
        └── json.h       # Auto-added to include path
# Old way (explicit paths)
scc build -Iinclude -Ivendor src/main.c src/utils.c -o myapp

# New way (auto-detected)
cd myproject
scc build src/main.c src/utils.c -o myapp

# Even simpler (directory compilation)
scc build src/ -o myapp

# Simplest (implicit mode)
scc build -o myapp

Controlling Auto-Detection

# Disable auto-detection entirely
scc build --no-auto-paths -Iinclude src/*.c -o myapp

# Explicitly set project root (useful when building from outside project)
scc build --project=/path/to/project src/*.c -o myapp

Help

scc help                            # General help
scc help build                      # Help for build command
scc help run                        # Help for run command

Examples

# Hello World
echo 'int main() { printf("Hello\\n"); }' > hello.c
scc run hello.c

# Build with optimization
scc build -O2 -o fast program.c

# Debug build
scc build -g -o debug program.c

# Link multiple files with libraries
scc build main.c utils.c -lm -o app

# Compile to object, then link
scc obj file1.c file2.c
scc build file1.o file2.o -o app

License

LGPL-2.1 (inherited from TCC)