Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

some pointer to understanding GCC source code

I'm student working on optimizing GCC for multi-core processor. I tried going through the source code, it is difficult to follow through it since I need to add some code to the back end. Can anyone suggest some good resource which explains the code flow through the different phases. Also suggest some development environment for debugging GCC mainly to step through the code. Is it possible on windows?

like image 447
rizwanhudda Avatar asked Mar 23 '10 23:03

rizwanhudda


2 Answers

As a starting point see Links and Selected Readings on GCC site. Of particular interest to you, I think, are:

  • GNU C Compiler Internals
  • Compilation of Functional Programming Languages using GCC -- Tail Calls by Andreas Bauer
  • Porting GCC for Dunces by Hans-Peter Nilsson

If you want to develop on Windows you probably need to start from MinGW (Minimalist GNU for Windows) Compiler Suite sources (it includes GNU GDB debugger), which is a port of GCC to Windows.

For a comfortable development environment I cannot help much because I don't develop in C++. But I suppose a good IDE for C/C++ is what you need: have a look at this comparison, there are plenty free/open source IDEs for Windows.

Update: I think ICI can also be of interest to you:

The Interactive Compilation Interface (or 'ICI' for short) is a plugin system with a high-level compiler-independent and low-level compiler-dependent API to transform current compilers into collaborative open modular interactive toolsets. The ICI framework acts as a "middleware" interface between the compiler and the user-definable plugins. It opens up and reuses the production-quality compiler infrastructure to enable program analysis and instrumentation, fine-grain program optimizations, simple prototyping of new development and research ideas while avoiding building new compilation tools from scratch. For example, it is used in MILEPOST GCC to automate compiler and architecture design and program optimizations based on statistical analysis and machine learning. It should enable universal self-tuning compilers adaptable to heterogeneous, reconfigurable, multi-core architectures ranging from supercomputers to embedded systems.

.. as the rest of projects under the Collective TUNING umbrella.

Note: Writing "compilers are one of the most complex programs there are", as BlueRaja wrote in comments, is an overstatement: there are very simple compilers and very complex compilers. But in compiler theory (once you have studied it) there is nothing esoteric. GCC is a complex program to understand as whatever BIG, poorly documented program out there1. So rizwanhudda don't be discouraged: start studying the documentation available and then ask GCC developers (on GCC irc channel, as suggested by nvl or GCC developers mailing list) to explain what is poorly (or not at all) documented.

  1. In fact program comprehension is an active field of research.
like image 183
MaD70 Avatar answered Oct 02 '22 20:10

MaD70


I would suggest you to use the GCC irc channel, it is meant for discussion of development of GCC.

like image 21
N 1.1 Avatar answered Oct 02 '22 18:10

N 1.1