Lab 04 - Building GCC
Lab 04 - GCC Build Lab
This lab aims to introduce me to software building by starting with the installation of the latest GCC compiler. In this blog, I’ll walk you through the step-by-step process I followed to build and install it.
STEP 1: Obtain the Source Code
In the first week of this course, we were introduced to Software Portability and Optimization and was tasked to set up SSH keys to prepare for the future labs. I obtained a public and private key that allowed me to gain access to remote systems. With that, I had to connect to SPO600 Servers (AArch64 and x86-64) and cloned a git repository through gcc.gnu.org.
Here's the command used to acquire a copy:
git clone git://gcc.gnu.org/git/gcc.git SomeLocalDir (in my case, I named my directory "Desktop")
STEP 2: Configure Your Build
In a developer's world, it is strongly discouraged to configure build inside the source directories, hence, the creation of a new directory. By doing so, I was able to have a separate file to build upon.
I created a new directory by following this command:
mkdir ~/gcc-build-001
To change the current directory:
cd ~/gcc-build-001
To invoke the the configure script I initially used this command:
~/Desktop/gcc/configure --prefix=$HOME/gcc-test-001
The command I used resulted in an error (*make: *** No rule to make target*) that occurred when make process could not find the file to build a target. While trying to find the error in the command, I realized that the mistake I made was from path not being recognized. Since I created a copy of the repository in a directory called "Desktop", the configure file is within the said directory.
The command I used to fix error:
~/Desktop/configure --prefix=$HOME/gcc-test-001
STEP 3: Perform The Build
Now that I have separate directories to configure and build, I was ready to start building GCC. By following the commands provided, I was able to measure the time it took for make process to complete.
Command used to measure the length of time for make process to complete:
time
Command used to build while running 24 parallel jobs simultaneously:
make -j 24
Final command for make to run 24 parallel jobs simultaneously while having ensuring record output into build.log:
time make -j 24 |& tee build.log
Total build time:
AArch64 Server
real 110m9.676s
user 1070m39.559s
sys 34m50.520s
x86-64 Server
real 47m24.874s
user 473m17.616s
sys 19m56.311s
STEP 4: Install and Test the Build
Upon the completion of make process, I installed the build by using "make install" command. This command allowed me to finally have the gcc installed within the server. I tested this by using "make check" command to run the GCC test suite and ensure it works accordingly. Additionally I tested this by creating a nano file to write a code in C.
Here's the following code I used to check:
Here's the following code I used to check:
int main() {
printf("GCC is working fine!");
return 0;
}
Test using command:
$HOME/gcc-test-001/bin/gcc test.c -o test
./test
Result:
GCC is working fine!
Comments
Post a Comment