GCC overview tips3

GNU Compiler Collection (GCC): Overview and Tips on the GCC Compiler Toolchain

=GCC Background=

Original author
Richard M. Stallman is the original author of GCC. Richard is also the founder of the GNU Project and the Free Software Foundation (FSF), and the father and current maintainer of the One True Emacs.

Big Picture
GCC is a critical piece of several free operating systems. GNU Hurd and GNU / Linux are two of these free operating systems.

Initially named "GNU C Compiler"
=Development History=

GCC Development Dates
1984 - Started GCC 1987 - First release (1.0) 1992 - Release 2.0 included C ++ support 1997 - Started experimental branch (EGCS) 2001 - Release 3.0 incorporated EGCS 2007 - Current release is 4.1.1 (released May 2006) =GNU Philosophy=

To support a proprietary-software free environment to work and communicate
=Supported Platforms=

32-bit CPU
x86 PowerPC Sun Sparc Motorola M68k DEC Alpha DEC VAX MIPS S/390 HP HPPA 7100 / 8000

64-bit CPU
AMD64 IA-64 / IPF PowerPC Sun UltraSparc IBM POWER / POWER4 DEC Alpha MIPS S/390x IBM Cell

DSP
ADI Blackfin TI TMS320C3x / TMS320C4x

Microcontroller
PowerPC ARM Motorola 68HC11 / 68HC12 Renesas H8/300 ATMEL AVR

Other Embedded Processor
Argonaut ARC Axis Communications CRIS CRX Vitesse IQ2000 Renesas M32C / M32R Xtensa Zilog Z80

OS / System
GNU Hurd Linux MS-Windows / MSDOS SVR4 (UNIX) HPUX FreeBSD / NetBSD Solaris VAX Ultrix AIX IRIX Mac OS X VxWorks Cray Unicos/Mk =Supported Languages=

Built-in Languages
The following languages have built-in interfaces, and require no additional installation steps after GCC is downloaded and installed. C (gcc command) C ++ (g ++ command) Objective-C / Objective-C ++ (gcc command) Fortran (g77 command) Java (gcj command) Ada (gnat command) Assembly language of every supported processor (as command)

Third-Party Supported Languages
The following languages are supported with "front-end" interfaces that are not built-in to GCC. User must obtain these front-ends from other sources. Pascal Mercury COBOL =Tools=

gcov – GNU coverage; collects line by line execution counts
=Compiler Toolchain=

Front-end command is typically used to perform all compile steps, thereby hiding the individual steps.
=Major Features=

Large development community increases number of features and provides support
=C / C ++ File Extensions=

=Compile Sequence=

=Error / Warning Messages=

Illegal instruction
=Compiler Front-end (gcc / g ++ commands)=

gcc -Wall hello.c -o hello.exe
=Command Line Options=

-ansi -pedantic -Wall -W –Wconversion -Wshadow -Wcast-qual -Wwrite-strings -O2
===The -ansi and -pedantic options are painful to use since they limit many common coding practices that most modern compilers properly handle anyway. See the -std option for some alternatives to selecting a specific language standard.===

Specify a specific static library to use when linking (-l small letter L)
=Preprocessing (cpp command)=

Line number and filename indications allow for accurate localization of warning and error messages identified during compilation step.
=Compilation=

Current GCC versions combine Preprocessing and Compilation steps into one integrated step.
=Assembly (as command)=

External function calls and data are left with undefined references.
=Linking (ld command)=

gcc hello.o -o hello.exe
===ld -Bdynamic --dll-search-prefix=cyg -o hello.exe /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../crt0.o -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../.. hello.o -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 –lgcc===

Extra C Run Time (CRT) object files are included to perform additional house keeping required by the system. These are system dependent (processor (hardware) and OS (kernel & utility) specific).
==If the native compiler (or cross compiler) was built correctly, there is no need to understand or remember the "ld" form of the command – just use the "gcc" form with all the project specific object files included on the command line.== =Archive (ar command)=

Any archive headers included by external source or other header files, need to be distributed with the static library file.
=Disassembly (objdump command)=

The best results of interspersed source code occur when optimization is turned off (-O0 option (capital letter o followed by zero)).
=Symbol Table Parsing (nm command)=

referenced but not defined in any object or library file
=Symbol Table Removal (strip command)=

Helps to limit reverse engineering of proprietary software
==Release version of a file can easily be stripped from the validated debug version simplifying an audit step, otherwise more effort would be needed to show that a recompiled release version (without a symbol table) exactly matched the debug version.== =Debugging (gdb command)=

GUI interfaces, such as DDD, offer a simplified user interface to gdb.
=Project Building (make command)=

Uses generic build rules, source specific steps, or a mix
=Profiling (gprof command)=

Also gives information on the function call sequence
=Coverage Testing (gcov command)=

Optimize code based on the likelihood that a branch is taken
=Reference Books=

http://www.gnu.org/software/make/manual/
=Reference URL ’ s=

http://www.eclipse.org/
=Conclusions=

If you don ’ t like it, you can fix it and give it to everyone else.
--69.244.36.62 01:09, 25 March 2007 (UTC)