Introduction
Processors can differ in their design (i.e. architecture) to satisfy different requirements. One of the most oldest and well known architectures is x86, introduced in 1978 by Intel, is optimized for performance in desktops and servers with the cost of high power consumption (Source, Source 2).
In 2020, Apple released their first in-house processor the M-Series processors (Source). The processor is based off the aarch64 architecture with the goal of being more energy efficient compared to x86.
Each architecture has their own unique set of instructions. Therefore instructions for x86 won’t work on aarch64 and vice versa. When programming either low level (e.g. C, C++), or high level languages (e.g. Python, JavaScript) both need to go through a compiler - where the source code is translated into machine code specific to the architecture it is being compiled on.
Here’s a table of popular programming languages with their associated compiler:
| Programming Language | Compiler |
|---|---|
| C | GCC, Clang |
| C++ | G++, Clang++ |
| Python | CPython, PyPy |
| JavaScript | V8 |
GCC
GCC is an open-source C compiler, part of the GNU Compiler Collection. An advantage of GCC is its extensive portability, as it can be compiled for a wide range of popular, and emerging architectures. List of supported architectures.
Lab 4
GCC can be ported and used on x86 and aarch64 architectures. Having access to both architectures, the GCC source code can be cloned via GitHub and installed locally.
Predictions
Given the differences between the x86 and aarch64 architectures, I predict that x86 will compile GCC quicker than aarch64.
Possible Issues
A factor that contributes to a quicker compile time is the amount of RAM, the x86 system has 64GB of RAM whereas the aarch64 system only has 32GB - this issue can limit how much physical RAM can be utilized and force memory swaps (i.e. moving data between RAM and the hard drive).
The servers being used to compile GCC are also shared. Therefore, depending when compiling occurs, the resources can be limited and also effect the compile times.
Setup
The setup will be the same between systems. It’s possible to have multiple instances of GCC on a single machine - to differentiate each GCC build, a dedicated directory is created and a subdirectory is dedicated for the source code and another for the build. After building GCC we could specify which gcc to use to compile a C program.
The following steps will guide you on how to get the GCC source code to building and compiling a C program using the newly installed GCC:
-
Create and
cdinto the source code directory
mkdir -p ~/gcc-dev && cd ~/gcc-dev -
Clone the
GCCsource code
git clone https://gcc.gnu.org/git/gcc.git -
Create and
cdinto the build folder, this is where theGCCbuild will happen
cd .. mkdir build-gcc cd build-gcc -
Get the requirements needed to compile
GCCfor the system architecture
../gcc/configure --prefix=$HOME/gcc-build-x86-001/install --enable-languages=c,c++ --disable-multilib -
Build
GCCvia theMakefileand usetimeto log the runtime intobuild.log
time make -j$(nproc) 2>&1 | tee build.log
Verify GCC Compilation
We’ll check the version of the installed GCC compiler and compile test.c that prints out “Hello World” to the console.
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
aarch64
[japablo@aarch64-002 l4]$ $HOME/gcc-build-x86-001/install/bin/gcc --version
gcc (GCC) 15.0.1 20250224 (experimental)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[japablo@aarch64-002 l4]$ $HOME/gcc-build-x86-001/install/bin/gcc test.c -o test
[japablo@aarch64-002 l4]$ ./test
Hello, World!
x86
japablo@x86-001:~/gcc-dev/build-gcc$ $HOME/gcc-build-x86-001/install/bin/gcc --version
gcc (GCC) 15.0.1 20250224 (experimental)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
japablo@x86-001:~/l4$ $HOME/gcc-build-x86-001/install/bin/gcc test.c -o test
japablo@x86-001:~/l4$ ./test
Hello, World!
Results
It was hypothesized that the x86 system would finish quicker than aarch64 because of faster clock speeds.
# x86
**real 34m44.825s**
user 385m35.938s
sys 13m4.008s
# aarch64
**real 107m55.004s**
user 998m11.630s
sys 31m39.209s
For aarch64 system, it is said to compile gcc in approximately 100 min according to the system description here. The resulting aarch64 did take approximately 7 minutes longer than expected.
Top comments (0)