SlideShare uma empresa Scribd logo
1 de 6
2012
Saket Kr. Pathak
Software developer
3D Graphics




GNU GCC - what just a compiler...?
A quick lookup of overview in reference of GCC that is GNU Compiler Collection.
GNU GCC - what just a compiler...?

Among all of us, we had learnt or studied about compilers and languages supported by
these compilers from last few days (*whatever days might be in multiple of 365 ... :) )
and most of us had specific paper entitled as "Compiler Design" ... or any other name
having similar sense or content of syllabus. That's really great mate, because I never got
that type of fortunate chance to study "Compiler Designing" and all. Whatever ... it's all
my interest and fortunate time that I found some thing valuable as well as sensible to
learn and study.

How many of times any one asked you in which compiler you work ... this question
belong to all studying professional and stud fellows? Even I had asked a few times, and
most of the time, I replied the answer to the question.

And my answer was, GNU GCC or VC++ as per environment matters. Today I realized
this is quite foolish answer as ... If some one asked you about the flavor of coffee (in
reference of dating friend) ... and you replied ... The coffee was good ... what a sense of
humor ... haaa haa. :)

So I realized it and studied my answer in reference of... GNU GCC compiler.
It's basically GCC, stands for GNU Compiler Collection. Originally named the GNU
C Compiler, because it only handled the C programming language, GCC 1.0 was
released in 1987, and the compiler was extended to compile C++ in December of that
year. Later on it is embed with compilers concern to languages like Objective-C,
Objective-C++, Fortran, Java, Ada, and Go etc.

Now since it's a collection of compilers so It can't be the exact answer as the question is
about the type and version of your compiler. So In reference of C++ we have a specific
name for the compiler embed within this GC Collection and that is G++, similarly in
reference of C we have a specific name as GNU C Compiler (i.e GCC). A lot of other
languages with there compiler are supported by GCC and are listed as bellow:



Seq.   Language                                Compiler
1.     C                                       gcc
2.     C++                                     g++
3.     Objective-C                             gobjc
4.     Fortran                                 gFortran
5.     Java                                    gcj
6.     Ada                                     GNAT
7.     Go                                      gccgo
8.     Pascal                                  gpc
9.     Mercury                                 Mercury
10.    PL/I                                    PL/1
11.    VHDL                                    GHDL



Saket Kr. Pathak                                                                       Page 2
GNU GCC - what just a compiler...?

Basically GNU Project has some component modules, that I found to discuss here as
some add-on, because. I thought how this big list of Compilers is going to handle within
a single GNU tool chain for all compiler logic, programming libraries and their syntax.
Then I found quite intellectual overview of GCC architecture that is basically categorized
into 3 hierarchical modules and each compiler includes the following three components:
a Front End, a Middle End, and a Back End. GCC compiles one file at a time. A source
file goes through all three components one after another. These three components are
discussed in bit details as follows:



GCC basic components
Front-End   The purpose of the front end is to read the source file, parse it, and convert it into
            the standard Abstract Syntax Tree (AST) representation. There is one front end
            for each programming language. Because of the differences in languages, the
            format of the generated ASTs is slightly different for each language. The next
            step after AST generation is the unification step in which the AST tree is
            converted into a unified form called Generic.
Middle-End The middle end part of the compiler takes control. First, the tree is converted into
            another representation called GIMPLE. In this form, each expression contains no
            more than three operands, all control flow constructs are represented as
            combinations of conditional statements and goto operators, arguments of a
            function call can only be variables. GIMPLE is a convenient representation for
            optimizing the source code. After GIMPLE, the source code is converted into the
            Static Single Assignment (SSA) representation i.e. each variable is assigned to
            only once, but can be used at the right hand side of an expression any time. GCC
            performs more than 20 different optimizations on SSA trees. The tree is converted
            back to the GIMPLE form which is then used to generate a Register-Transfer
            Language (RTL) form of a tree. RTL is a hardware-based representation that
            corresponds to abstract target architecture with an infinite number of registers. An
            RTL optimization pass optimizes the tree in the RTL form.
Back-End    Finally, a GCC back-end generates the assembly code for the target architecture
            using the RTL representation. Examples of back-ends are x86 back end, mips
            back end, etc.




Saket Kr. Pathak                                                                           Page 3
GNU GCC - what just a compiler...?

Hence from the above short-descriptions we have the overview of all the three
components.




Front-End:

Frontends vary internally, having to produce trees that can be handled by the backend.
Currently, the parsers are all hand-coded recursive descent parsers, though there is
no reason why a parser generator could not be used for new front-ends in the future
hence, version 2 of the C compiler used a bison based grammar. Here a recursive
descent parser is a top-down parser built from a set of mutually-recursive procedures
(or a non-recursive equivalent) where each such procedure usually implements one of
the production rules of the grammar, whereas GNU bison, commonly known as Bison,
is a parser generator that is part of the GNU Project. Bison reads a specification of a
context-free language, warning about any parsing ambiguities, and generates a parser
(either in C, C++, or Java) which reads sequences of tokens and decides whether the
sequence conforms to the syntax specified by the grammar.

Then as it converts the source file to abstract syntax tree which has somewhat different
meaning for different language front-ends, and front-ends could provide their own tree
codes. This was simplified with the introduction of GENERIC and GIMPLE, two new
forms of language-independent trees that were introduced with the advent of GCC 4.0.
GENERIC is more complex, based on the GCC 3.x Java front-end's intermediate
representation. GIMPLE is a simplified GENERIC, in which various constructs are
lowered to multiple GIMPLE instructions. The C, C++ and Java front ends produce
GENERIC directly in the front end. Other front ends instead have different intermediate
representations after parsing and convert these to GENERIC.

Middle-end:

As it takes control, GENERIC that is an intermediate representation language used as a
"middle-end" while compiling source code into executable binaries. A subset, called
GIMPLE, is targeted by all the front-ends of GCC. So it’s responcible for all the code
analysis and optimization, working independently of both the compiled language and

Saket Kr. Pathak                                                                  Page 4
GNU GCC - what just a compiler...?

the target architecture, starting from the GENERIC representation and expanding it to
Register Transfer Language. The GENERIC representation contains only the subset of
the imperative programming constructs optimized by the middle-end. In transforming
the source code to GIMPLE, complex expressions are split into a three address code
using temporary variables. This representation was inspired by the SIMPLE
representation proposed in the McCAT compiler by Laurie J. Hendren for simplifying
the analysis and optimization of imperative programs.

As it performs optimization that occurs during any phase of compilation, however the
bulk of optimizations are performed after the syntax and semantic analysis of the front-
end and before the code generation of the back-end. The exact set of GCC optimizations
varies from release to release as it develops, but includes the standard algorithms, such
as loop optimization, jump threading, common sub-expression elimination,
instruction scheduling, and so forth. The RTL optimizations are of less importance
with the addition of global SSA-based optimizations on GIMPLE trees. Some of these
optimizations performed at this level include dead code elimination, partial
redundancy elimination, global value numbering, sparse conditional
constant propagation, and scalar replacement of aggregates. Array dependence
based optimizations such as automatic vectorization and automatic
parallelization are also performed.

Back-end:

The behavior of GCC's back end is partly specified by preprocessor macros and functions
specific to a target architecture, for instance to define the endianness, word size, and
calling conventions. The front part of the back end uses these to help decide RTL
generation, so although GCC's RTL is nominally processor-independent, the initial
sequence of abstract instructions is already adapted to the target. At any moment, the
actual RTL instructions forming the program representation have to comply with the
machine description of the target architecture. At the end of compilation, valid RTL is
further reduced to a strict form in which each instruction refers to real machine
registers and real instructions from the target's instruction set. Forming strict RTL is a
very complicated task, done mostly by the register allocation first but completed only by
a separate "reloading" phase which must account for the vagaries of all of GCC's targets.
The final phase is somewhat anticlimactic, because the patterns to match were generally
chosen during reloading, and so the assembly code is simply built by running
substitutions of registers and addresses into the strings specifying the instructions.

Compatible IDEs
Integrated development environments written for GNU/Linux and some for other
operating systems support GCC. These include:
    Anjuta
    Code::Blocks
    CodeLite
    Dev-C++
    Eclipse
    geany

Saket Kr. Pathak                                                                    Page 5
GNU GCC - what just a compiler...?

       KDevelop
       Net Beans
       Qt Creator
       Xcode

Hmmm ... So please never tell any one like fool ... "I use to work on GNU GCC" ... be
specific with GNU C Compiler/G++ for C/C++ receptively. A few links I would like to
mention here, If any of you people like to read about GNU project in bit detail can
definitely enjoy your time with these all ... But I know ... you are Quite busy ... :) ...
whatever ...




References:
http://en.wikipedia.org/wiki/GNU_Project
http://en.wikipedia.org/wiki/GNU_Compiler_Collection#cite_note-8
http://gcc.gnu.org/frontends.html
http://en.wikipedia.org/wiki/GNU_Compiler_Collection
http://www.enotes.com/topic/GNU_Compiler_Collection
http://www.enotes.com/topic/GNU_Compiler_Collection#Back-end



Saket Kr. Pathak                                                                       Page 6

Mais conteúdo relacionado

Mais procurados

The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019corehard_by
 
Web technology slideshare
Web technology slideshareWeb technology slideshare
Web technology slideshareGuruAbirami2
 
Golang execution modes
Golang execution modesGolang execution modes
Golang execution modesTing-Li Chou
 
C++ compilation process
C++ compilation processC++ compilation process
C++ compilation processRahul Jamwal
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...Mickael Istria
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDBkyaw thiha
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
Syncevolution: Open Source and Funambol
Syncevolution: Open Source and FunambolSyncevolution: Open Source and Funambol
Syncevolution: Open Source and FunambolFunambol
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDBDavid Khosid
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
LLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationLLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationVivek Pansara
 
Introduction to C Programming by Subid Biswas
Introduction to C Programming by Subid BiswasIntroduction to C Programming by Subid Biswas
Introduction to C Programming by Subid BiswasSubid Biswas
 
Turbo C Compiler Reports
Turbo C Compiler Reports Turbo C Compiler Reports
Turbo C Compiler Reports Sunil Kumar R
 
Autotools pratical training
Autotools pratical trainingAutotools pratical training
Autotools pratical trainingThierry Gayet
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about goDvir Volk
 

Mais procurados (20)

The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
The Hitchhiker's Guide to Faster Builds. Viktor Kirilov. CoreHard Spring 2019
 
C compilation process
C compilation processC compilation process
C compilation process
 
Web technology slideshare
Web technology slideshareWeb technology slideshare
Web technology slideshare
 
Golang execution modes
Golang execution modesGolang execution modes
Golang execution modes
 
C++ compilation process
C++ compilation processC++ compilation process
C++ compilation process
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDB
 
Gnu debugger
Gnu debuggerGnu debugger
Gnu debugger
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
Syncevolution: Open Source and Funambol
Syncevolution: Open Source and FunambolSyncevolution: Open Source and Funambol
Syncevolution: Open Source and Funambol
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
LLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationLLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time Optimization
 
Introduction to C Programming by Subid Biswas
Introduction to C Programming by Subid BiswasIntroduction to C Programming by Subid Biswas
Introduction to C Programming by Subid Biswas
 
Turbo C Compiler Reports
Turbo C Compiler Reports Turbo C Compiler Reports
Turbo C Compiler Reports
 
Autotools pratical training
Autotools pratical trainingAutotools pratical training
Autotools pratical training
 
Usage of GDB
Usage of GDBUsage of GDB
Usage of GDB
 
GDB Rocks!
GDB Rocks!GDB Rocks!
GDB Rocks!
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
Golang
GolangGolang
Golang
 

Semelhante a GNU GCC - what just a compiler...?

From gcc to the autotools
From gcc to the autotoolsFrom gcc to the autotools
From gcc to the autotoolsThierry Gayet
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application DevelopmentRamesh Prasad
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Shivang Bajaniya
 
Language translators
Language translatorsLanguage translators
Language translatorsAditya Sharat
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applicationsRoman Podoliaka
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)guest91cc85
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)guest251d9a
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Anil Thakral
 
Golang : A Hype or the Future?
Golang : A Hype or the Future?Golang : A Hype or the Future?
Golang : A Hype or the Future?Mindfire LLC
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)omercomail
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdbRoman Podoliaka
 

Semelhante a GNU GCC - what just a compiler...? (20)

Unit1 cd
Unit1 cdUnit1 cd
Unit1 cd
 
From gcc to the autotools
From gcc to the autotoolsFrom gcc to the autotools
From gcc to the autotools
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
The compilation process
The compilation processThe compilation process
The compilation process
 
Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)Transpilers(Source-to-Source Compilers)
Transpilers(Source-to-Source Compilers)
 
Language translators
Language translatorsLanguage translators
Language translators
 
Debugging of (C)Python applications
Debugging of (C)Python applicationsDebugging of (C)Python applications
Debugging of (C)Python applications
 
Compiler Design(Nanthu)
Compiler Design(Nanthu)Compiler Design(Nanthu)
Compiler Design(Nanthu)
 
Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)Compiler Design(NANTHU NOTES)
Compiler Design(NANTHU NOTES)
 
Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02Compilerdesignnew 091219090526-phpapp02
Compilerdesignnew 091219090526-phpapp02
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
Golang : A Hype or the Future?
Golang : A Hype or the Future?Golang : A Hype or the Future?
Golang : A Hype or the Future?
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Unit 2 l1
Unit 2 l1Unit 2 l1
Unit 2 l1
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdb
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
Comparing C and Go
Comparing C and GoComparing C and Go
Comparing C and Go
 
First session quiz
First session quizFirst session quiz
First session quiz
 

Mais de Saket Pathak

Wan Important Questions
Wan Important QuestionsWan Important Questions
Wan Important QuestionsSaket Pathak
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignmentSaket Pathak
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 
A Guy and gal in STL
A Guy and gal in STLA Guy and gal in STL
A Guy and gal in STLSaket Pathak
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
Malloc, calloc, realloc
Malloc, calloc, reallocMalloc, calloc, realloc
Malloc, calloc, reallocSaket Pathak
 
C++ diamond problem
C++ diamond problemC++ diamond problem
C++ diamond problemSaket Pathak
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++Saket Pathak
 

Mais de Saket Pathak (14)

Wan Important Questions
Wan Important QuestionsWan Important Questions
Wan Important Questions
 
Wan notes
Wan notesWan notes
Wan notes
 
C++ lab assignment
C++ lab assignmentC++ lab assignment
C++ lab assignment
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
A Guy and gal in STL
A Guy and gal in STLA Guy and gal in STL
A Guy and gal in STL
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
C++ friendship
C++ friendshipC++ friendship
C++ friendship
 
C++ Template
C++ TemplateC++ Template
C++ Template
 
Copy constructor
Copy constructorCopy constructor
Copy constructor
 
Malloc, calloc, realloc
Malloc, calloc, reallocMalloc, calloc, realloc
Malloc, calloc, realloc
 
Recursion in c
Recursion in cRecursion in c
Recursion in c
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
C++ diamond problem
C++ diamond problemC++ diamond problem
C++ diamond problem
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
 

Último

Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 

Último (20)

Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 

GNU GCC - what just a compiler...?

  • 1. 2012 Saket Kr. Pathak Software developer 3D Graphics GNU GCC - what just a compiler...? A quick lookup of overview in reference of GCC that is GNU Compiler Collection.
  • 2. GNU GCC - what just a compiler...? Among all of us, we had learnt or studied about compilers and languages supported by these compilers from last few days (*whatever days might be in multiple of 365 ... :) ) and most of us had specific paper entitled as "Compiler Design" ... or any other name having similar sense or content of syllabus. That's really great mate, because I never got that type of fortunate chance to study "Compiler Designing" and all. Whatever ... it's all my interest and fortunate time that I found some thing valuable as well as sensible to learn and study. How many of times any one asked you in which compiler you work ... this question belong to all studying professional and stud fellows? Even I had asked a few times, and most of the time, I replied the answer to the question. And my answer was, GNU GCC or VC++ as per environment matters. Today I realized this is quite foolish answer as ... If some one asked you about the flavor of coffee (in reference of dating friend) ... and you replied ... The coffee was good ... what a sense of humor ... haaa haa. :) So I realized it and studied my answer in reference of... GNU GCC compiler. It's basically GCC, stands for GNU Compiler Collection. Originally named the GNU C Compiler, because it only handled the C programming language, GCC 1.0 was released in 1987, and the compiler was extended to compile C++ in December of that year. Later on it is embed with compilers concern to languages like Objective-C, Objective-C++, Fortran, Java, Ada, and Go etc. Now since it's a collection of compilers so It can't be the exact answer as the question is about the type and version of your compiler. So In reference of C++ we have a specific name for the compiler embed within this GC Collection and that is G++, similarly in reference of C we have a specific name as GNU C Compiler (i.e GCC). A lot of other languages with there compiler are supported by GCC and are listed as bellow: Seq. Language Compiler 1. C gcc 2. C++ g++ 3. Objective-C gobjc 4. Fortran gFortran 5. Java gcj 6. Ada GNAT 7. Go gccgo 8. Pascal gpc 9. Mercury Mercury 10. PL/I PL/1 11. VHDL GHDL Saket Kr. Pathak Page 2
  • 3. GNU GCC - what just a compiler...? Basically GNU Project has some component modules, that I found to discuss here as some add-on, because. I thought how this big list of Compilers is going to handle within a single GNU tool chain for all compiler logic, programming libraries and their syntax. Then I found quite intellectual overview of GCC architecture that is basically categorized into 3 hierarchical modules and each compiler includes the following three components: a Front End, a Middle End, and a Back End. GCC compiles one file at a time. A source file goes through all three components one after another. These three components are discussed in bit details as follows: GCC basic components Front-End The purpose of the front end is to read the source file, parse it, and convert it into the standard Abstract Syntax Tree (AST) representation. There is one front end for each programming language. Because of the differences in languages, the format of the generated ASTs is slightly different for each language. The next step after AST generation is the unification step in which the AST tree is converted into a unified form called Generic. Middle-End The middle end part of the compiler takes control. First, the tree is converted into another representation called GIMPLE. In this form, each expression contains no more than three operands, all control flow constructs are represented as combinations of conditional statements and goto operators, arguments of a function call can only be variables. GIMPLE is a convenient representation for optimizing the source code. After GIMPLE, the source code is converted into the Static Single Assignment (SSA) representation i.e. each variable is assigned to only once, but can be used at the right hand side of an expression any time. GCC performs more than 20 different optimizations on SSA trees. The tree is converted back to the GIMPLE form which is then used to generate a Register-Transfer Language (RTL) form of a tree. RTL is a hardware-based representation that corresponds to abstract target architecture with an infinite number of registers. An RTL optimization pass optimizes the tree in the RTL form. Back-End Finally, a GCC back-end generates the assembly code for the target architecture using the RTL representation. Examples of back-ends are x86 back end, mips back end, etc. Saket Kr. Pathak Page 3
  • 4. GNU GCC - what just a compiler...? Hence from the above short-descriptions we have the overview of all the three components. Front-End: Frontends vary internally, having to produce trees that can be handled by the backend. Currently, the parsers are all hand-coded recursive descent parsers, though there is no reason why a parser generator could not be used for new front-ends in the future hence, version 2 of the C compiler used a bison based grammar. Here a recursive descent parser is a top-down parser built from a set of mutually-recursive procedures (or a non-recursive equivalent) where each such procedure usually implements one of the production rules of the grammar, whereas GNU bison, commonly known as Bison, is a parser generator that is part of the GNU Project. Bison reads a specification of a context-free language, warning about any parsing ambiguities, and generates a parser (either in C, C++, or Java) which reads sequences of tokens and decides whether the sequence conforms to the syntax specified by the grammar. Then as it converts the source file to abstract syntax tree which has somewhat different meaning for different language front-ends, and front-ends could provide their own tree codes. This was simplified with the introduction of GENERIC and GIMPLE, two new forms of language-independent trees that were introduced with the advent of GCC 4.0. GENERIC is more complex, based on the GCC 3.x Java front-end's intermediate representation. GIMPLE is a simplified GENERIC, in which various constructs are lowered to multiple GIMPLE instructions. The C, C++ and Java front ends produce GENERIC directly in the front end. Other front ends instead have different intermediate representations after parsing and convert these to GENERIC. Middle-end: As it takes control, GENERIC that is an intermediate representation language used as a "middle-end" while compiling source code into executable binaries. A subset, called GIMPLE, is targeted by all the front-ends of GCC. So it’s responcible for all the code analysis and optimization, working independently of both the compiled language and Saket Kr. Pathak Page 4
  • 5. GNU GCC - what just a compiler...? the target architecture, starting from the GENERIC representation and expanding it to Register Transfer Language. The GENERIC representation contains only the subset of the imperative programming constructs optimized by the middle-end. In transforming the source code to GIMPLE, complex expressions are split into a three address code using temporary variables. This representation was inspired by the SIMPLE representation proposed in the McCAT compiler by Laurie J. Hendren for simplifying the analysis and optimization of imperative programs. As it performs optimization that occurs during any phase of compilation, however the bulk of optimizations are performed after the syntax and semantic analysis of the front- end and before the code generation of the back-end. The exact set of GCC optimizations varies from release to release as it develops, but includes the standard algorithms, such as loop optimization, jump threading, common sub-expression elimination, instruction scheduling, and so forth. The RTL optimizations are of less importance with the addition of global SSA-based optimizations on GIMPLE trees. Some of these optimizations performed at this level include dead code elimination, partial redundancy elimination, global value numbering, sparse conditional constant propagation, and scalar replacement of aggregates. Array dependence based optimizations such as automatic vectorization and automatic parallelization are also performed. Back-end: The behavior of GCC's back end is partly specified by preprocessor macros and functions specific to a target architecture, for instance to define the endianness, word size, and calling conventions. The front part of the back end uses these to help decide RTL generation, so although GCC's RTL is nominally processor-independent, the initial sequence of abstract instructions is already adapted to the target. At any moment, the actual RTL instructions forming the program representation have to comply with the machine description of the target architecture. At the end of compilation, valid RTL is further reduced to a strict form in which each instruction refers to real machine registers and real instructions from the target's instruction set. Forming strict RTL is a very complicated task, done mostly by the register allocation first but completed only by a separate "reloading" phase which must account for the vagaries of all of GCC's targets. The final phase is somewhat anticlimactic, because the patterns to match were generally chosen during reloading, and so the assembly code is simply built by running substitutions of registers and addresses into the strings specifying the instructions. Compatible IDEs Integrated development environments written for GNU/Linux and some for other operating systems support GCC. These include:  Anjuta  Code::Blocks  CodeLite  Dev-C++  Eclipse  geany Saket Kr. Pathak Page 5
  • 6. GNU GCC - what just a compiler...?  KDevelop  Net Beans  Qt Creator  Xcode Hmmm ... So please never tell any one like fool ... "I use to work on GNU GCC" ... be specific with GNU C Compiler/G++ for C/C++ receptively. A few links I would like to mention here, If any of you people like to read about GNU project in bit detail can definitely enjoy your time with these all ... But I know ... you are Quite busy ... :) ... whatever ... References: http://en.wikipedia.org/wiki/GNU_Project http://en.wikipedia.org/wiki/GNU_Compiler_Collection#cite_note-8 http://gcc.gnu.org/frontends.html http://en.wikipedia.org/wiki/GNU_Compiler_Collection http://www.enotes.com/topic/GNU_Compiler_Collection http://www.enotes.com/topic/GNU_Compiler_Collection#Back-end Saket Kr. Pathak Page 6