GCC Configuration and Building

GCC Configuration and Building

Tutorial on Essential Abstractions in GCC GCC Configuration and Building Uday Khedker (www.cse.iitb.ac.in/grc) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay April 2011 EA-GCC, Chamonix Configuration & Building: Outline 1/1 Outline • A conceptual overview of configuration and building • Details of configuration and building • Testing the built compiler Uday Khedker GRC, IIT Bombay Part 1 Basic Concepts EA-GCC, Chamonix Configuration & Building: Basic Concepts 2/1 Configuration Preparing the GCC source for local adaptation: • The platform on which it will be compiled • The platform on which the generated compiler will execute • The platform for which the generated compiler will generate code • The directory in which the source exists • The directory in which the compiler will be generated • The directory in which the generated compiler will be installed • The input languages which will be supported • The libraries that are required • etc. Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 3/1 Pre-requisites for Configuring and Building GCC 4.5.0 • ISO C90 Compiler / GCC 2.95 or later • GNU bash: for running configure etc • Awk: creating some of the generated source file for GCC • bzip/gzip/untar etc. For unzipping the downloaded source file • GNU make version 3.8 (or later) • GNU Multiple Precision Library (GMP) version 4.3.2 (or later) • MPFR Library version 3.0.0 (or later) (multiple precision floating point with correct rounding) • MPC Library version 0.8.2 (or later) • Parma Polyhedra Library (PPL) version 0.10.2 • CLooG-PPL (Chunky Loop Generator) version 0.15.09 • jar, or InfoZIP (zip and unzip) • libelf versionInformation 0.8.12 (or later) (for LTO) Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 4/1 Our Conventions for Directory Names • GCC source directory : $(SOURCE D) • GCC build directory : $(BUILD) • GCC install directory : $(INSTALL) • Important ◮ $(SOURCE D) = $(BUILD) = $(INSTALL) ◮ None of the above directories should be contained in any of the above directories Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 5/1 Configuring GCC configure Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 5/1 Configuring GCC configure.in config/* config.guess config.sub configure Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 5/1 Configuring GCC configure.in config/* config.guess config.sub configure config.log config.cache config.status Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 5/1 Configuring GCC configure.in config/* config.guess config.sub configure config.h.in Makefile.in config.log config.cache config.status Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 5/1 Configuring GCC configure.in config/* config.guess config.sub configure config.h.in Makefile.in config.log config.cache config.status Makefile config.h Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 6/1 Steps in Configuration and Building Usual Steps • Download and untar the source • cd $(SOURCE D) • ./configure • make • make install Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 6/1 Steps in Configuration and Building Usual Steps Steps in GCC • Download and untar the • Download and untar the source source • cd $(SOURCE D) • cd $(BUILD) • ./configure • $(SOURCE D)/configure • make • make • make install • make install Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 6/1 Steps in Configuration and Building Usual Steps Steps in GCC • Download and untar the • Download and untar the source source • cd $(SOURCE D) • cd $(BUILD) • ./configure • $(SOURCE D)/configure • make • make • make install • make install GCC generates a large part of source code during a build! Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 7/1 Building a Compiler: Terminology • The sources of a compiler are compiled (i.e. built) on Build system, denoted BS. • The built compiler runs on the Host system, denoted HS. • The compiler compiles code for the Target system, denoted TS. The built compiler itself runs on HS and generates executables that run on TS. Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 8/1 Variants of Compiler Builds BS = HS = TS Native Build BS = HS = TS Cross Build BS = HS = TS Canadian Cross Example Native i386: built on i386, hosted on i386, produces i386 code. Sparc cross on i386: built on i386, hosted on i386, produces Sparc code. Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 9/1 T Notation for a Compiler C i386 i386 cc Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 9/1 T Notation for a Compiler input language C i386 i386 cc Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 9/1 T Notation for a Compiler input language output language C i386 i386 cc Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 9/1 T Notation for a Compiler input language output language C i386 i386 cc implementation or execution language Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 9/1 T Notation for a Compiler input language output language C i386 i386 cc implementation or name of the translator execution language Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View ass m/c m/c Machine language Assembly language Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View implementation language input language output language ass m/c m/c Machine language Assembly language Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View implementation language input language output language C0 m/c ass Level 0 C Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View implementation language input language output language C0 m/c ass ass m/c Level 0 C m/c Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View implementation language Level 1 C C1 m/c C0 input language output language Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View implementation language Level 1 C C1 m/c C0 m/c C0 input language ass output language Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View Level n C implementation language Cn m/c Cn−1 input language output language Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 10/1 Bootstrapping: The Conventional View Level n C implementation language Cn m/c Cn−1 m/c Cn−1 input language output language Cn−2 Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 11/1 Bootstrapping: GCC View • Language need not change, but the compiler may change Compiler is improved, bugs are fixed and newer versions are released • To build a new version of a compiler given a built old version: ◮ Stage 1: Build the new compiler using the old compiler ◮ Stage 2: Build another new compiler using compiler from stage 1 ◮ Stage 3: Build another new compiler using compiler from stage 2 Stage 2 and stage 3 builds must result in identical compilers ⇒ Building cross compilers stops after Stage 1! Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 GCC Source Requirement: BS = HS = TS = i386 Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 C i386 i386 Execution language cc GCC Source Requirement: BS = HS = TS = i386 Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 C i386 C i386 i386 Execution language cc GCC Source Requirement: BS = HS = TS = i386 Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 C i386 C i386 i386 cc GCC Source Requirement: BS = HS = TS = i386 Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 C i386 C i386 i386 Stage 1 Build cc GCC Source C i386 i386 gcc Requirement: BS = HS = TS = i386 • Stage 1 build compiled using cc Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 C i386 C i386 i386 Stage 1 Build cc GCC Source C i386 i386 gcc Requirement: BS = HS = TS = i386 • Stage 1 build compiled using cc Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 C i386 C i386 i386 Stage 1 Build cc GCC Source C i386 i386 Stage 2 Build gcc C i386 Requirement: BS = HS = TS = i386 • Stage 1 build compiled using cc i386 • Stage 2 build compiled using gcc gcc Uday Khedker GRC, IIT Bombay EA-GCC, Chamonix Configuration & Building: Basic Concepts 12/1 A Native Build on i386 C i386 C i386 i386 Stage 1 Build cc GCC Source C i386 i386 Stage 2 Build gcc C i386 Requirement: BS = HS = TS

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    127 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us