Project Stage 1.2

 Navigating the GCC Codebase

Compilation Passes

GCC’s compilation process involves multiple passes, each performing specific transformations on the code. These passes are defined in gcc/passes.cc and described in gcc/tree-pass.h. To understand and potentially modify these passes, I navigated to these files within the codebase. I found that each pass is defined with a specific structure that includes its name, execution function, and other metadata. Adding a new pass involved defining it in tree-pass.h and implementing it in passes.cc.

 Argument Parsing

 To add a new argument, I first located the argument parsing code in gcc/toplev.cc. I added a dummy argument to the common.opt file and then implemented the definition of this argument in toplev.cc. This involved declaring a flag for the new argument and adding a case to set this flag when the argument was used. Testing this modification required rebuilding GCC and using the new argument in a test command. The result was a successful recognition and handling of the dummy argument

Argument Information storage

After some poking around, I found that GCC stores Argument information in various structures within gcc/opts.cc  and  gcc/opts.h.

Dumps During Compilation Passes

I found out that GCC provides detailed dumps during compilations, and it can be enabled using flags like:

-fdump-tree-all

So, to test it, I made a simple Hello World program and used the above flag for the compilation process. I was able to generate dumps for the Hello World program. 



Reflections

I learned a lot about GCC. I found its modular nature, which allows for custom compilation, quite interesting. However, the biggest challenge I faced was the overwhelming amount of information I had to take in. I really wished this course was full-term so that I could experiment more with GCC. I found GCC quite interesting and fun to play around with when everything worked fine. 


Comments

Popular Posts