Project Stage - 1 GCC for AArch64

Goal:

The primary goal of this project is to add a functioning proof-of-concept prototype of auto-function-multi-versioning capability to the GNU Compiler Collection (GCC) for AArch64 systems.

Building GCC on AArch64:

Download GCC Source: 

Start by cloning the latest GCC source code from the official GCC repository:

sangwooshin@sinsang-us-MacBook-Pro % git clone git://gcc.gnu.org/git/gcc.git

Cloning into 'gcc'...

remote: Enumerating objects: 3044476, done.

remote: Counting objects: 100% (224151/224151), done.

remote: Compressing objects: 100% (13890/13890), done.

remote: Total 3044476 (delta 219673), reused 210438 (delta 210250), pack-reused 2820325

Receiving objects: 100% (3044476/3044476), 1.16 GiB | 13.98 MiB/s, done.

Resolving deltas: 100% (2506365/2506365), done.

Updating files: 100% (134862/134862), done.


Create Separate Build Directory:


mkdir project

cd project



Configure GCC:


Configure the build for AArch64:


[sshin36@aarch64-001 project]$ ../configure --target=aarch64-linux-gnu --enable-languages=c,c++


Configure the build for x86_64 system:

[sshin36@aarch64-001 project]$ ../configure --target=x86_64-linux-gnu --enable-languages=c,c++


Build and Install GCC:

build the gcc compiler. This step can take several hours depending on the system specification.
For me, It took around two hours to install it.

[sshin36@aarch64-001 project]$ make -j$(nproc)


Install DejaGnu

git clone git://git.sv.gnu.org/dejagnu.git
 cd dejagnu
./configure 
make 
sudo make install

DejaGnu is needed for running tests. Clone the DejaGnu repository and install it.

Run the Test Suite:

[sshin36@aarch64-001 project]$ make -k check


Running the test suite will verify the GCC build by running a series of test. The '-k' option continues as much as possible after an error.

PASS: gcc.c-torture/execute/builtins/strcmp.c execution,  -O3 -g 

PASS: gcc.c-torture/execute/builtins/strcmp.c compilation,  -Os 

PASS: gcc.c-torture/execute/builtins/strcmp.c execution,  -Os 

PASS: gcc.c-torture/execute/builtins/strcmp.c compilation,  -Og -g 

PASS: gcc.c-torture/execute/builtins/strcmp.c execution,  -Og -g 

PASS: gcc.c-torture/execute/builtins/strcmp.c compilation,  -O2 -flto -fno-use-linker-plugin -flto-partition=none 

PASS: gcc.c-torture/execute/builtins/strcmp.c execution,  -O2 -flto -fno-use-linker-plugin -flto-partition=none 

PASS: gcc.c-torture/execute/builtins/strcmp.c compilation,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects 

PASS: gcc.c-torture/execute/builtins/strcmp.c execution,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -O0 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -O0 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -O1 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -O1 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -O2 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -O2 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -O3 -g 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -O3 -g 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -Os 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -Os 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -Og -g 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -Og -g 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -O2 -flto -fno-use-linker-plugin -flto-partition=none 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -O2 -flto -fno-use-linker-plugin -flto-partition=none 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c compilation,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects 

PASS: gcc.c-torture/execute/builtins/strcpy-2.c execution,  -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects 

PASS: gcc.c-torture/execute/builtins/strcpy-chk.c compilation,  -O0 

PASS: gcc.c-torture/execute/builtins/strcpy-chk.c execution,  -O0 


=== gcc Summary ===


# of expected passes 15311


Now the GCC complier working on my server.

Once you check the compiler working well, then now you can create .c programming. Below code is sample code to run compiler. I created below code with 'touch hello.c' and insert code by using 'vi' keyword.

#include <stdio.h>

int main() {

        printf("Hello this is SPO600 Project Stage 1\n Your Compiler is now running!\n");

        return 0;

}


Compile program : gcc -o hello hello.c
Run the program: ./hello

[sshin36@aarch64-001 project]$ gcc hello.c -o hello

[sshin36@aarch64-001 project]$ ./hello

Hello this is SPO600 Project Stage 1

 Your Compiler is now running!


By using objdump, also user can check variety of data such as, assembly code, file section and file symbol.

[sshin36@aarch64-001 project]$ objdump -d hello|less


Output:


hello:     file format elf64-littleaarch64



Disassembly of section .init:


0000000000400430 <_init>:

  400430:       d503233f        paciasp

  400434:       a9bf7bfd        stp     x29, x30, [sp, #-16]!

  400438:       910003fd        mov     x29, sp

  40043c:       94000033        bl      400508 <call_weak_fn>

  400440:       a8c17bfd        ldp     x29, x30, [sp], #16

  400444:       d50323bf        autiasp

  400448:       d65f03c0        ret


Disassembly of section .plt:


0000000000400450 <.plt>:

  400450:       a9bf7bf0        stp     x16, x30, [sp, #-16]!

  400454:       f00000f0        adrp    x16, 41f000 <__FRAME_END__+0x1e880>

  400458:       f947fe11        ldr     x17, [x16, #4088]

  40045c:       913fe210        add     x16, x16, #0xff8

  400460:       d61f0220        br      x17


댓글

이 블로그의 인기 게시물

Lab 1 - Calculate performance & memory usage

Project stage-3 (testing & reflection)