Lab 4 - GCC Build Lab (Part 3)
Continuing from Part 2
Now, I am repeating the same process on aarch64-002, but this time, I will focus on any differences, challenges, and additional tools I used to make the process smoother. The overall steps remain the same, but I encountered some unexpected issues that required troubleshooting.
Setting Up the Environment
Just like before, I needed to set up my workspace by cloning the GCC repository and creating separate directories for the build and installation:
mkdir -p ~/gcc-build-002
cd ~/gcc-build-002
~/git/gcc/configure --prefix=$HOME/gcc-test-002
Once the configuration was successful, I proceeded with the build.
Building GCC: Unexpected Challenges
Building GCC is a resource-intensive process, and on aarch64-002, I faced some unexpected delays.
- On x86-001, the entire build took around 47 minutes.
- On aarch64-002, I noticed that it was taking significantly longer than expected—over 2 hours at one point!
To investigate, I checked system resource usage:
top # or htop
The CPU was highly utilized, but the build was progressing, just very slowly compared to x86-001.
Solution: Using Screen for Persistent Sessions
Since the long build time made it difficult to stay connected, I decided to use screen to prevent disconnections from interrupting the process.
screen -S gcc-build
After running this command, I started the build:
time make -j 24 |& tee build.log
This allowed me to detach the session (Ctrl + A, then D) and safely close my SSH connection.
Later, I could resume the session anytime with:
screen -r gcc-build
Lesson learned: Screen is extremely useful for handling long builds that may be interrupted!
Installation and Verification
Once the build was complete, I installed GCC using:
make install |& tee install.log
Then, I verified that my custom-built GCC was installed and different from the system version:
which gcc $HOME/gcc-test-002/bin/gcc --version
Next, I tested it by compiling a simple program:
echo '#include <stdio.h>\nint main() { printf("Hello, GCC!\n"); return 0; }' > test.c $HOME/gcc-test-002/bin/gcc test.c -o test ./test
If everything was set up correctly, it should print:
Hello, GCC!
Measuring Rebuild and Null Rebuild Times
After installation, I tested the rebuild behaviour:
Step 1: Rebuild after modifying a file
To simulate a source code change, I updated the timestamp of passes.cc:
touch ~/git/gcc/gcc/passes.cc time make -j 24 |& tee rebuild.log
As expected, the rebuild time was significantly shorter than the initial build.
Step 2: Null Rebuild (No changes)
Finally, I checked how long it takes to detect that nothing needs to be rebuilt:
time make -j 24 |& tee null-rebuild.log
This step was extremely fast because make just verified that everything was already up-to-date.
Reflection
Lab 4 was a deep dive into building and optimizing large-scale software across different architectures. Going through the full GCC build process on x86-001 and aarch64-002, I encountered real-world challenges that forced me to think critically about build performance, system resource management, and efficient workflow strategies.
One of the biggest takeaways was how hardware differences impact build times—even with identical source code and configurations, my build on x86-001 took under an hour, while aarch64-002 exceeded two hours at times. This highlighted the importance of monitoring system resources (top, htop) and anticipating performance bottlenecks when working on cross-platform projects.
Another key lesson was the importance of managing long builds efficiently. Early on, I struggled with SSH disconnections, which made me restart or piece together the build process. Using screen allowed me to detach and reattach sessions, ensuring that my builds continued even if I lost connection. This was a game-changer and is something I will use in any long-running remote job in the future.
Logging and tracking build times also proved to be critical for debugging. At one point, I mistakenly saved logs under the wrong filename (guild.log instead of build.log), making it difficult to verify my build progress. This experience reinforced why precise documentation and validation are essential when working on large software projects.
Lastly, the incremental build and null rebuild tests helped me appreciate how make efficiently tracks changes—modifying just one file resulted in a significantly shorter build time, while a null rebuild completed in seconds. This is a fundamental concept in software development, where optimizing build times can dramatically improve productivity.
Reference
Building GCC Instruction by Professor Chris Tyler's wiki
http://spo600.cdot.systems/doku.php?id=spo600:building_gcc
Comments
Post a Comment