Cross-compilation

Cross-compilation

A cross-compiler produces target code for a machine different from the one on which it is run
For example, running gcc on a Pentium Linux platform and generating code for a 68000 PalmOS platform







1. Suppose we have cross-compiler for a new language L in implementation language S generating code for machine N.
LSN
2. Suppose we also have an existing S compiler running on machine M implementing code for machine M:
SMM
3. Run LSN through SMM to produce LMN




                                                              LSN + SMM = LM



                                  

Composition Example

1. Suppose we have cross-compiler for a new language, Decaf, implemented in C++: DecafC++MIPS
2. Suppose we also have an existing C++ compiler for a PowerPC machine (e.g., Mac)
C++PowerPCPowerPC
3. Run DecafC++MIPS through C++PowerPCPowerPC to produce DecafPowerPCMIPS


Bootstrapping
Let’s create a compiler for a new language L that runs on machine M
1. Write a compiler for S, a subset of L: SMM Here, M is assembly  language


2. Write the compiler for L using language S: LSM 

3. Compile LSM under SMM to make LMM LMM is a compiler for language L that produces code 
for machine M



Retargeting and Rehosting the Compiler
Let’s make an L compiler for a different machine, N
1. Write LLN 
2. Compile LLN with LMM to produce LMB This make a cross-compiler for N that runs on machine M
 3. Compile LLN with the cross-compiler to produce LNN This makes a compiler for language L that runs on machine N


Comments

Popular posts from this blog

Fingerprint Analysis

Benefits of Buying Old Twitter Accounts

Buy YouTube Accounts at Affordable Price