Compiler Design 1
BOOTSTRAPPING AND CROSS COMPILER AWDHESH KUMAR(ASST. PROF.) (
[email protected] )
Third Language Language for Compiler Compiler Construction 2
Machine language Another language with existed compiler on the same target machine : (First Scenario)
Compile the new compiler with existing compiler
Another language with existed compiler on
Compilation produce a cross compiler
T-Diagram Describing Complex Situation 3
A compiler written in language H that translates .
S
T
H T-Diagram can be combined in two basic ways.
The First T-diagram Combination 4
A
B B H
C H
A
C H
Two compilers run on the same machine H
First from A to B Second from B to C Result from A to C on H
The Second T-diagram Combination 5
A
B H H
A K
B K
M
Translate implementation language of a compiler from H to K Use another compiler from H to K
The First Scenario 6
A
H B B
A H
H H
H
Translate a compiler from A to H written in B
Use an existing compiler for language B on machine H
The Second Scenario 7
A
H B B
A K
H K
K
Use an existing compiler for language B on different machine K
Result in a cross compiler
Process of Bootstrapping 8
Write a compiler in the same language
S No compiler for source language yet Porting to a new host machine
The First step in bootstrap 9
A
H A A
A H
H H
H
quick and dirty compiler written in machine language H Compiler written in its own language A “
”
The Second step in bootstrap 10
A
H A A
A H
H H
H
Running but inefficient compiler Compiler written in its own language A Result in final version of the compiler
The step 1 in porting 11
A
K A A
A H
K H
H
Original compiler Compiler source code retargeted to K Result in Cross Compiler
The step 2 in porting 12
A
K A A
A K
K K
H
Cross compiler Compiler source code retargeted to K Result in Retargeted Compiler