Now that we understand a little bit of assembly in difference architectures, we can play with compilers now. For this course we will be interacting with the GCC compiler. There is project associated with this on AArch64 systems. For this stage of the project, we were asked to make ourselves familiar with the gcc build process. In short, we were supposed to build the current development version of GCC and just experiment with it.
GCC
Before we talk about what I did with the build, lets understand GCC, GCC was a popular compiler for c but now has been expanded its support to more languages. It also is responsible to optimization and portability options that we get while compiling our programmes. Some of them are listed below:
IFUNC: allows a program to provide multiple implementations of a function and to use a resolver function which will determine the implementation that will be used during run time. This was we can make multiple functions geared towards optimization for different platforms.
FMV(function multi versioning): Improved version of IFUNC where the resolver function not something we have to create. We only have to provide a target attribute so that the compiler resolver understands where the function is used.
AFMV(automatic function multi-versioning): You can think how the amount of work is increased with writing function for all architectures. So there is this capability still in makes which will solve this. And this is what we will be building for this project. For AFMV, a compiler option will be used to specific the architectural variants and the function that will benefit will be automatically cloned.
The start of the project.
To start off, I cloned the development version of GCC using git clone git://gcc.gnu.org/git/gcc.git gcc
.
Now we can create a build directory and configure our build to use that directory using ~/gcc/configure --prefix=$HOME/gcc-test-001
Finally we can start the build process. GCC takes a long time to build, so we will also be using a time command and the -j attribute to specify the cores to be used during the build process. This is the command I used time make -j 4 |& tee build.log
. Keep in mind this mind take a lot of time depending on what system you are using, for me it took almost 2 hours!!
Finally after the long wait, we can install the source code using make install
. After the installation, we dont want to use the systems gcc compiler, we want to use our new compiler, by using PATH=$HOME/gcc-test-001:$PATH
, and check if it was installed using which gcc
Conclusion
We learned how to build our own version of GCC. Next we will talk about the compilation passes that a normal compilation goes through!!
Top comments (0)