Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

How I Built cjsawk - A New C Compiler for Any Platform

ACCU Conference via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Explore the development of a revolutionary self-hosted C compiler that operates across multiple platforms through an innovative multi-language approach in this 14-minute conference talk. Discover how cjsawk solves the persistent challenge of inconsistent C compiler availability across different systems by creating a compiler written in a unique dialect that is simultaneously valid in C, JavaScript, and AWK. Learn about the technical implementation including the recursive descent parser, tokenizer, macro assembler, and linker components that enable this cross-platform functionality. Understand how the compiler can bootstrap itself bit-identically across Linux, Node.js, web browsers, and AWK interpreters, ensuring reproducible builds regardless of the target system. Examine the compiler's architecture covering global and function declaration handling, expression processing, and the use of inline macro assembly for operations not expressible in the limited language subset such as divide or bitwise operations. Gain insights into how cjsawk can bootstrap a C99 compiler and extend to build a full GCC toolchain, making it a practical solution for cross-platform development. Discover the language design decisions that maintain consistency across the three target languages while preserving the compiler's self-hosting capability and portability features.

Syllabus

0:00 Introduction to cjsawk and Motivation
0:04 What is cjsawk? Subset of C, JavaScript, and AWK
0:20 Challenges of Cross-System C Compilation
0:33 Self-Hosted Compiler Concept
1:09 Compiler Bootstrap Paths and Platform Support
2:00 Macro Assembly Output and Compilation Process
3:02 Assembler and Linker: m0.js and hex2.js
3:45 Rebuilding the Compiler Bit-Identically
4:20 Compiler Architecture Overview
5:33 Main Compiler Loop and Global Declarations
6:20 Function Declarations and Argument Handling
7:29 Expression Handling and Language Limitations
8:20 Inline Assembly for Unsupported Operations
9:41 Language Design Decisions and Consistency
10:02 Porting C99 Compiler and Bootstrapping TCC
12:01 Use Cases and Practical Applications
13:12 Closing Remarks and Questions

Taught by

ACCU Conference

Reviews

Start your review of How I Built cjsawk - A New C Compiler for Any Platform

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.