When I tried to compile the example code posted athttps://eli.thegreenplace.net/2012/01/03/understanding-the-x64-code-models/#example-c-source on an arm64 device(Raspberrypi) with
raspberrypi:~$ gcc -g -O0 -c code_model.c -fPIC -mcmodel=large -o code_model_large_pic.occ1: sorry, unimplemented: code model ‘large’ with -fPIC
but clang happily compiles the same.
I suspect I need some extra configuration options enabled while building gcc for my Raspberrypi.
raspberrypi:~$ gcc -dumpspecs...*cc1:%{profile:-p}%{%:sanitize(address):-funwind-tables}...
on my x86-64 pc
x86-64-pc:~$ gcc -dumpspecs...*cc1:%{!mandroid|tno-android-cc:%(cc1_cpu) %{profile:-p};:%(cc1_cpu) %{profile:-p} %{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}}...
i believe it got something to do with %{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}}
.
How to build gcc for arm64 device to support large code model with position independent code?