If I compile a c file into ARM64 assembly I get different instructions (not only a different syntax and directives - eg .cfi_def_cfa
vs .cfi_def_cfa_offset
) depending on whether I compile on linux or mac. Why is this if the ISA is the same? I know there will be different target binary formats (ELF/Mach-O), but I was expecting identical instructions that would then be compiled into different objects. Is this because apple use apple clang which may process things differently from the internals of the aarch64 gcc toolchain?
Is there any way to enforce using the same instructions?
Input file (fib.c):
int fib(int n)
{
if (n <= 1)
return 1;
return fib(n - 1) fib(n - 2);
}
Mac (compiled on a mac mini with gcc -S fib.c -o fib.s
):
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 11, 0 sdk_version 12, 1
.globl _fib ; -- Begin function fib
.p2align 2
_fib: ; @fib
.cfi_startproc
;