Project Stage 1

GCC install and build with version

Before diving into the code, let's set up a local GCC installation. Head over to the official installation guide https://gcc.gnu.org/install/ for detailed instructions. Here's a quick rundown:

Clone the Source: Use git clone git://gcc.gnu.org/git/gcc.git to grab the latest GCC source code.

Build Directory: Create a directory "mkdir" for your build and navigate to it using "cd". you can create different versions for different use case, but keep in mind GCC is not small. Once you are done with the build, you can simply delete the build files. We create different directory for different build so it would have a cleaner workflow.

mkdir ./gcc-build-001
cd ./gcc-build-001

Local Installation: In your newly made build folder. Specify a custom installation path with "../configure --prefix=/path/to/install/gcc". Replace "/path/to/install/gcc" with your desired location. This will create a make file for you in the build folder.

~/gcc/configure --prefix=$HOME/gcc-build-001

Parallel Power: Check the number of CPU cores with icpu or btop (number of cores per socket). Utilize these cores for faster compilation using "make -j<number_of_cores + 1>". For example, "make -j 8" for an 8-core system. Can also use the time commend to see how long it took for it to build. For example "time make -j 8". You can run "make" in your root of the build version folder to update the build.

icpu or btop
time make -j 8

Building for AArch64: While building for both x86 and AArch64 is possible, I will focus on AArch64 as we are going to be using that on our project.

Exploring the GCC Codebase

GCC is a big code base. There is a lot to take in and look around can be done. There are documentation to help you find the things you want (https://gcc.gnu.org/onlinedocs/). however some could be outdated, but still useful. The concept stays the same. It sure will take time, effort, and lots of patient to gain knowledge on GCC. we sadly only have 3-4 weeks to learn about this.

Compilation Passes:

Flag passes are one of the way to control how we want to optimization our project. The order you place the passes are important. Different passes also can have their own options build within. We combine different passes to pick and choose how we want GCC to translate our source code. flag usually starts with a "-". the "-O" is the level of optimization GCC will do. Depends what you want to target.

Example:  gcc helloworld.c -O3 -o hello

~/gcc/gcc/common.opt: this is where the to see the options you can put when running GCC. I believe this is where I add the pass for our project. The file common.opt is also kind of sorted alphabetically. I would also have to do some research on the rules of added an option for GCC (option definition records).

Finding the Passes:
There is (passes.def - definition | passes.cc - manager | tree-pass.h - declaration). those are the main files for pass in GCC. You could look thought the .def file to get a short summary of what is available.
 
Adding a flags takes some level of understanding on how the GCC works. Foe me GCC is a big step of a level to mess with. Thankfully my professor hold my hand and show me the way. After a change on the common.opt to see if your flag works you would have to use "make" to build it again.
 
I don't mind doing any part of the term project. I am very flexible. There is a lots to take in. The GCC code base is big and scary and will take time to get familiar with. Starting new on everything is scary at first, once I get to work on it more than things will become clear. When the GCC is building it makes me feel like I'm hacking, also sometimes i see it just stop but after a while it would just carry on. I thought it could be the internet but the files are all there to for build it can be done offline. I believe the reason could be depended on the hardware in the server, how many person are also doing the build so we would have to share the compute power.










Comments

Popular posts from this blog

Lab 1

Project Stage 2