Lab-4: GCC Build Lab - Building the GCC Compiler from Source

Introduction

In this lab, I explored the process of building a large software project—specifically, the GCC (GNU Compiler Collection) compiler—from source code. GCC is a critical toolchain used for compiling programs in various programming languages, including C, C++, and Fortran. The goal of this lab was to understand the build process, use tools like make and autotools, and compare the performance of the build process on two different architectures: x86-001 (x86_64) and aarch64-002 (ARM64). This lab is part of the SPO600 course, where we study software portability and optimization.

Lab Steps and Results
1. Obtaining and Building GCC

I followed these steps to build GCC on both servers:

  1. Cloned the GCC source code:
    git clone git://gcc.gnu.org/git/gcc.git gcc-source


  2. Created a separate build directory and configured the build:
    mkdir gcc-build
    cd gcc-build
    ../gcc-source/configure --prefix=$HOME/gcc-install --disable-multilib

  3. Built GCC using make:
    time make -j 16 |& tee build.log

  4. Installed GCC:
    make install

2. Build Times

Server             Initial Build Time           Rebuild Time                           Null Rebuild Time
x86-001            14m 43.132s                 1m 52.908s                                 1m 9.318s
aarch64-002  72m 23.931s                  4m51.450s
                                 2m3.145s

Observations:
  • The ARM64 server (aarch64-002) took significantly longer to build GCC compared to the x86_64 server (x86-001). This is likely due to differences in CPU performance and architecture.
  • The rebuild time after modifying passes.cc was much shorter, as only the affected files were recompiled.
  • The null rebuild was almost instantaneous, as make simply checked the timestamps and determined that no changes were needed.
3. Proof of Successful Build
  • Verified the GCC version:
    $HOME/gcc-install/bin/gcc --version

    Output:
    gcc (GCC) 13.0.0 20231003 (experimental)

  • Compiled and ran a simple C program:
    echo 'int main() { return 0; }' > test.c
    $HOME/gcc-install/bin/gcc test.c -o test
    ./test

    The program ran successfully, confirming that the GCC build works.
4. Comparison with System GCC
  • The system GCC version on both servers:
    /usr/bin/gcc --version

    Output
    gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10)

  • The newly built GCC is a development version (13.0.0), while the system GCC is an older stable version (8.5.0).

Experiences and Reflections

1. Challenges:
  • The initial build took a long time, especially on the ARM64 server. Patience was key!
  • I encountered a missing dependency (libmpc-devel) during the configuration step, but installing it resolved the issue.
2. Learnings:
  • I gained a deeper understanding of how large software projects are built using tools like make and autotools.
  • I learned how to use the time command to measure build times and the tee command to log output.
  • I now understand the importance of separating source and build directories to keep the source tree clean.
3. Interesting Observations:
  • The rebuild process was much faster than the initial build, demonstrating the efficiency of make in handling incremental builds.
  • The null rebuild was almost instantaneous, highlighting how make optimizes the build process by checking file timestamps.

Conclusion
This lab was a great hands-on experience in building a large software project like GCC. I learned how to configure, build, and install software from source, and I gained insights into the differences in build performance across architectures. The lab also reinforced the importance of tools like make in managing complex builds efficiently. I look forward to applying these skills in future projects and exploring optimization techniques in the SPO600 course.

Comments

Popular posts from this blog

Lab-1: Exploring 6502 Assembly

Project Stage III: Multi-Clone Analysis in GCC Pass

Lab 2 - 6502 Math Lab