What is Compiler Bootstrapping?

It is an approach for making a self-compiling compiler that is a compiler written in the source programming language that it determine to compile. A bootstrap compiler can compile the compiler and thus you can use this compiled compiler to compile everything else and the future versions of itself.

Uses of Bootstrapping

There are various uses of bootstrapping which are as follows −

  • It can allow new programming languages and compilers to be developed starting from actual ones.

  • It allows new features to be combined with a programming language and its compiler.

  • It also allows new optimizations to be added to compilers.

  • It allows languages and compilers to be transferred between processors with different instruction sets

Advantages of Bootstrapping

There are various advantages of bootstrapping which are as follows −

  • Compiler development can be performed in the higher-level language being compiled.

  • It is a non-trivial test of the language being compiled.

  • It is an inclusive consistency check as it must be capable of recreating its object code.

For bootstrapping, a compiler is defined by three languages −

S→Source language it compiles.

T→Target language it generates.

I→Implementation language that it is written in

These languages can be represented using a T-diagram as

Cross Compiler

A compiler is characterized by three languages as its source language, its object language, and the language in which it is written. These languages may be quite different. A compiler can run on one machine and produce target code for another machine. Such a compiler is known as a cross-compiler.

  • If it can write a cross-compiler for a new language 'L' in execution languages 'S' to generate a program for machine 'N'.

i.e. LsN

  • If a current compiler for S runs on machine M and generates a program for M, it is defined by SMM.

  • If LSN runs through SMM, we get a compiler LMN, i.e., a compiler from L to N that runs on M.

Example − Create a cross compiler using bootstrapping when SsM runs on SAA.

Solution − First of all, it represents two compilers with T-diagram.

When SsM runs on SAA, SAM will be generated.