LAB 4

Building GCC process:


Step 1:

Create a Directory for the GCC Source Code:




Step 2:

Clone the GCC Repository into the Source Directory: 





Step 3:
Create a Separate Build Directory


Note:
Building GCC directly in its source code directory is not recommended. Doing so can mix original source files with new files created during the build process, making it hard to manage the code. This can also cause problems with version control systems, which track changes in the code. To avoid these issues, it's better to create a separate directory for building GCC. This keeps the original source code clean and makes it easier to manage different build versions. For example, you can create a directory named gcc-build next to your GCC source code directory and perform the build process there.


Step 4:
Configure the Build



Note:

--prefix option specifies the installation directory for GCC after the build process. In this case, GCC will be installed in ~/gcc-test-001.

gcc-build-001 Directory: Purpose: This is the build directory where the compilation process occurs.

gcc-test-001 Directory: Purpose: This is the installation directory where the final GCC binaries and associated files are placed after a successful build.



Step 5:
Perform the build:



Step 6:

Install the build:




GCC Version Info On Servers:

 aarch64-002:


    (Version installed)

    (Default version on the system)

x86-001:


  (Version installed)


 (Default version on the system)

Execute  C program using GCC

 aarch64-002:

Step 1: Create a c file:


Step 2: Compile the C program:



Step 3:Run the compiled program:




x86-001:

Step 1: Create a c file:



Step 2: Compile the C program:



Step 3:Run the compiled program:



Build Time For Each Server:

aarch64-002:

Build time: approximately 100 minutes (forgot to take a screenshot)
Build time after update the timestamp on the file “passes.cc":
Build time with no change:



x86-001:
Build time:


Build time after update the timestamp on the file “passes.cc":


Build time with no change:


Reflection:

Reflecting on this lab, I learned how to build GCC by keeping source code and build files in separate folders, which helps organize and simplifies the compiling process. I also saw how setting build options, like choosing where to install GCC, tailors the build to specific needs. Additionally, I examined the build time for GCC on different servers and explored commands like time make -j 24 |& tee build.log. Furthermore, I explored tools like GNU Screen and the use of Makefiles. GNU Screen allows multiple sessions within a single terminal window, enabling processes to continue running even after disconnecting, which is particularly useful for managing long-running tasks on remote servers. Makefiles, on the other hand, are essential for automating the build process, defining rules and dependencies for compiling and linking programs to ensure efficient and accurate builds.

Additional Investigation and research:

I did some additional research after reading the register and instruction quick start guides for both x86_64 and aarch64 to better understand the concepts behind these two processors.
Links for the register and instruction quick start guides:
AArch64:
http://spo600.cdot.systems/doku.php?id=spo600:aarch64_register_and_instruction_quick_start
x86_64:
http://spo600.cdot.systems/doku.php?id=spo600:x86_64_register_and_instruction_quick_start

Reference:
https://devblogs.microsoft.com/oldnewthing/20220726-00/?p=106898

AArch64:

r0 to r30: These are general-purpose registers. They are used for both 32-bit and 64-bit operations, without specifying the data width.These registers are used for both 32-bit and 64-bit operations, depending on the context.

x0 to x30: These are the same registers as r0 to r30 but are used when working with 64-bit values. Each register is capable of holding a 64-bit (8-byte) value.

w0 to w30: These refer to the lower 32 bits of the same registers. They are used for 32-bit operations. When you use w registers, only the lower 32 bits are accessed, and the upper 32 bits are either cleared or sign-extended.

x0:The return value of a function is placed in x0 if it’s an integer or a pointer.
x0-x7 argument registers:are used to pass the first eight arguments to a function.If a function has more than eight arguments, the additional arguments are passed on the stack.
x8-x15:used for temporary values and intermediate results.they can be used freely by functions but the values in them are not guaranteed to be preserved across function calls.
x16,x17: are volatile because they often used for indirect branch instructions, holding the address for jumps or function calls.
x17: This register is typically reserved for platform or operating system use in the ARM aarch64. architecture. It is often used for system calls or for interactions with the underlying operating system.
x19-x28:preserved:if a function (callee) uses these registers, it is responsible for saving their values before using them and restoring them before returning, to ensure that the calling function (caller) does not lose its data in these registers.
x29 is the frame pointer (FP):points to the current function's stack frame. A stack frame contains the function's local variables, saved registers, and the return address (stored in x30).
x30 is the Link Register:Store the return address when a function call is made.

The flags register is formally known as the Application Program Status Register (APSR):



x86_64:
rax (Register A Extended) is mainly used for doing math and logic operations. It stores the result of these operations and is often used to return values from functions.

rbx (Register B Extended) is usually used as a base for memory access. It helps in addressing data and can be used temporarily to store values. It’s a callee-saved register, which means functions should not overwrite it.

rcx (Register C Extended) is commonly used for loop counters or in operations like shifting bits. It can also hold function arguments, depending on the calling convention. 

rdx (Register D Extended) is used in math operations like multiplication and division. When you multiply large numbers, the result is split between rax and rdx, with rax holding the lower part and rdx holding the higher part. 

rbp (Register Base Pointer) is important for function calls. It points to the start of the stack frame, helping access function arguments and local variables. It’s preserved during function calls.

rsp (Register Stack Pointer) points to the top of the stack. The stack grows downwards, and rsp keeps track of where the stack is. It adjusts as data is added or removed. 

rsi (Register Source Index) is used to point to the source when copying or comparing data. It stores the address of the data you are working with. 

rdi (Register Destination Index) is the counterpart to rsi. It points to where data is going, like the destination when moving or copying data. 
These registers are key to managing data, memory, and function calls in low-level programming on x86-64 systems.

r8: This register can be used for general-purpose storage or for function arguments in certain calling conventions.

r9: Like r8, this register is another general-purpose register for calculations or passing arguments.

r10: This register can be used similarly for general-purpose purposes or as an argument in function calls. 

r11: This register serves as another general-purpose register, and it can also be used as an argument register in certain calling conventions.

r12: A general-purpose register often used for temporary storage in functions or for data manipulations. It’s preserved across function calls, meaning that if a function uses r12, it should save and restore it if needed. 

r13: Similar to r12, this register is a general-purpose register used in operations, but it’s callee-saved and preserved across function calls. 

r14: Like r13, r14 is used for general-purpose purposes, such as storing values temporarily. It is also callee-saved. 

r15: This is the final register in the set of r8-r15. It’s also used for general-purpose storage or as an argument in function calls.

% Symbol:distinguish registers from other types of operands like immediate values or memory addresses. Example:%rax refers to the rax register.%r10,(%r11)move data from address pointed to by r10 to r10

$ Symbol:refer to immediate values in assembly language. An immediate value is a constant that is used directly in an instruction.




Comments

Popular posts from this blog

PROJECT STAGE2

PROJECT STAGE1