Project Stage 1
GCC install and build with version
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).
Comments
Post a Comment