Monday, February 11, 2019

Internals of GCC

Internals Of GCC

In the podcast from the Software Engineering Radio, with Morgan Deters as guest, the team discuss the characteristics and functions of the GNU Project compiler known as GCC.

At the beginning I found the recording a little tedious, however as it continued I gained more interest in the subject. I learned a lot of things I never assumed with GCC, besides the fact I've used it for many projects and competitions in C. For instance, I thought it was compatible only for C programs, but I found out that it also works for C++, Java, and some other languages. 

On the other hand, it was very interesting to learn about the compiler working process: it  goes through three different phases in which source code is transformed into target code for the computer to understand it and execute it correctly.

The first phase is the frontend where a translator of the input (the source) produces an output for the middle end, which is going to use this output as its input. The front end has to parse its input into an abstract syntax tree form to create a representation of what's in the source file and send the data as it should.

Then comes the middle
 end where the output generated by the tree in the front end is used to produce an equivalent and more efficient low level representation of the input tree.

Finally, we have the backend, that takes the output of the middle end as its input to produce code. The code is optimized by replacing certain blocks and then is finally translated to Assembly Language.

Learning about this entire process was quite intersting and enlightning. I can't help but think the complexity envolved in GCC in order for it to be compatible with so many languages and platforms.


No comments:

Post a Comment

The Hitchhiker's Guide To The Galaxy

The Hitchhiker's Guide To The Galaxy Reading this comedy and science-fiction comedy from Douglas Adams was actually pretty funny and ...