Before we start...
If you have just stumbled upon my SPO600 series of blog posts, it has been created to document and share my learnings as I progress through my Software Portability and Optimization college course.
In this post, I’ll share my experience of building the GCC compiler from source on my college's AArch64 server. This setup is an important first step of our class project: adding a new experimental feature to he GNU Compiler Collection (GCC).
A little bit about the project
One of the cool things about Seneca’s Software Portability and Optimization course is that each semester, students get a chance to gain hands-on experience by working with real-world projects.
Our Fall 2024 batch will attempt to create a working prototype for function pruning (which is a component of the yet-to-be-implemented AFMV (automatic : helpful info for GCC newbies).
: official installation docs:
while also referring to the guides linked above for extra details.
1. Obtaining the Source Code
I cloned the source code from the official git repo into an empty gcc/ directory (created specifically for storing the source code).
git clone git://gcc.gnu.org/git/gcc.git gcc
Notably, cloning took longer the usual due to the size of the repo.
2. Configuring the build
I created the gcc-build-001/ build directory (to separate source files and build files), cd'd into it and ran the configure script (located in the source directory), specifying the installation directory with the --prefix flag.
Running the configure script checks the system requirements
and creates a Makefile with build instructions for GCC in the current directory. (In my case, the college server already had all the necessary dependencies installed. You can find the info about the prerequisites in the recommends setting this value between (number of cores + 1) and (number of cores * 2 + 1), using the higher end for systems with hyper-threading or slower disks and the lower end for those without. Since our college server has 4 cores and does not support hyper-threading, I decided to stick to the lower end of the recommended range by running up to 5 jobs.
time is used to measure how long the make process takes to complete. The tee command captures the output of make and writes it to the file build.log while also displaying it in the terminal.
In total, the build process took: 124 minutes and 3.647 seconds
By default, the compiler is built in three stages, following a bootstrapped build process to ensure reliability and consistency in the build. If you are performing a 3-stage bootstrapped build, you can quickly check the current build stage by looking at the
stage_currentfile.
Then, I ran this command to apply the changes:
CODEsource ~/.bashrc
After that, I was finally able to use my local copy of GCC 😃 🎉
Afterthoughts
This experience helped me get familiar with the build process: I learned about various configuration options, the three stages of the bootstrapped build, and got a peek at the codebase. Going through the related documentation also gave me a better understanding of the contribution process.
While this has been a solid start, I still have a lot of work ahead. To start contributing, I'll need to get comfortable with navigating the codebase and adapting to GCC’s coding style, so there’s a lot more documentation reading and code experimenting to come!
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.

SOCIAL SHARE CARD GENERATOR