# How to explain rehosting and retargeting with T-diagrams?

I'm currently learning for an exam about compilers and found the following question:

(3 p.) Bootstrapping: Explain the concepts of rehosting and retargeting. Use T-diagrams.

As far as I understand, rehosting means to compile a compiler for another platform (host), so it should look like this:

-------------
| a       b |     --------------
-----   -----     | a        b |
| c |-------------    ------
-----| c       x || x |
-----   ----------
| ? |
-----


Is this correct? And what does retargeting mean?

Retargeting refers to having the compiler generate code for a different CPU or instruction set.
A different CPU would be X86 vs PowerPC.
A different instruction set would be ARM vs THUMB or x86 vs x86-64 (same CPU, but different mode).

Rehosting means running the code on a different machine than the code was compiled on.
The new machine usually has the same architecture.
Rehosting need not be trivial, because e.g. the filesystem may look different on the compiler system.

Retargetability
Easily modified to generate code for a different target language

Rehostability
Easily modified to run on a different machine

Collectively the two terms are often combined in the term portability.
Code that is portable is not tied to an architecture (target) and not tied to the setup of a specific machine (host).

? should be replaced by x, see these lecture notes.