1

Is there any harm in always compiling with -fPIC even if I might not intend to link the resulting relocatable object files into a shared library?

PSkocik
  • 55,062
  • 6
  • 86
  • 132
  • 2
    Relocation costs extra indirection and increases code size, and you may wish to take that into account. But best to measure and compare! – Kerrek SB Oct 14 '15 at 20:42
  • 1
    Related: [Why does arm-linux-androideabi-gcc enforce -fpic?](http://stackoverflow.com/questions/14990461/why-does-arm-linux-androideabi-gcc-enforce-fpic) – Ivan Aksamentov - Drop Oct 14 '15 at 21:33

1 Answers1

1

Well, always compiling with -fPIC will produce a bit more bloated and a bit slower code.

Difference would be less visible on x64 target, I believe

You shall measure and decide if those differences are relevant for you app, you might be ok with it

Severin Pappadeux
  • 16,848
  • 3
  • 34
  • 60