Project Stage 1- GCC Build & Dump on AArch64

 Goal 

The primary objective of my project is to develop a working proof-of-concept prototype for the function-pruning component of Automatic Function Multi-Versioning (AFMV) within the GNU Compiler Collection (GCC) specifically designed for AArch64 systems. This initiative aims to build upon existing functionalities and enhance the efficiency of the compiler.

A significant aspect of this project is to familiarize myself with the process of building GCC on AArch64 architecture. By engaging in this project on the aarch64-002 server, I hope to gain hands-on experience and become comfortable with the intricacies involved in the build process. Understanding the steps required to successfully compile and configure GCC on this platform will provide me with invaluable insights into compiler development and operation.

I have followed the project instructions outlined in SPO600 2024 Fall Project to guide my work.


Steps to Build GCC

1. Clone the GCC Repository: Firstly, I created a directory for my project and begin by cloning the GCC source code repository. Used the following command to clone the main repository from the GCC Git repository:


2. Create a Build Directory: It's a good practice to create a separate directory for building GCC to keep the source and build files organized:



3. Configure the GCC Build: This step is essential for ensuring that the subsequent build process runs smoothly and that the final GCC installation meets our specific needs and system requirements:


4. Compile GCC: We will use the "make" command to start the compilation, and set it to run multiple jobs in parallel based on the server's core count (for this server). Using "time" command we will measure how long the build takes and "|& tee build.log" will save the output to a "build log" file for future reference.     


The build process took a total of 227 minutes, with substantial user time of approximately 990 minutes logged.


5. Install GCC: After the build completes, we want to install it in the directory specified during the configuration. Ran:


6. Setting up the Environment: To use the newly built GCC as the default version, updated "PATH" to prioritize the new compiler location:

   


This line adds the path to our new GCC installation at the beginning of the "PATH" variable, so our system finds it first when you run GCC.

7. Verify the Installation: Confirm that the correct GCC version is now being used:


After the build process completed, I verified the GCC version to ensure it was the correct, newly built experimental version. Running the command "which gcc" and "gcc --version" confirmed that GCC version 15.0.0 (experimental) was successfully compiled and installed. This output confirms that I am using the newly built version, not a system-installed one.


Steps for producing dump files

 1. Create the C Program :First, I opened the terminal on my AArch64 server. To create a new C program file, I used the "nano" command:


In the nano editor, I wrote the following C code:


2. Compile the C Program: Next, I compiled the C program using the following command:


Once the compilation was complete, I executed the compiled program with ./testProgram command.

 3. Generate Dump Files: To delve deeper into the compilation process, I generated dump files by running the following command, which includes the dump option:


I checked for the generated .gimple dump files by running ls *.gimple, which confirmed their successful creation. To analyze the output, I reviewed the contents of one of the dump files using the command cat testProgram.c.006t.gimple.


The -fdump-tree-all and -fdump-tree-pass options generate detailed dump files related to the tree representation of the program, while the -fdump-rtl-all and -fdump-rtl-pass options offer similar capabilities for the RTL (Register Transfer Language) representation. Exploring these options allows for a deeper understanding of the compiler's behavior and the transformations applied to the source code.


Reflection

Working on this part of the project has shown me how complex building a compiler can be and how crucial it is to get configurations and dependencies just right. This experience has taught me a lot about the setup process, including working with dump files, and I’m eager to keep learning more about GCC’s inner workings. I’m looking forward to continuing with the project.



Comments

Popular posts from this blog

SPO600 LAB 1

Project Stage 3: Tidy & Wrap