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?
Asked
Active
Viewed 262 times
1
PSkocik
- 55,062
- 6
- 86
- 132
-
2Relocation 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
-
1Related: [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 Answers
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
-
It worth mention that there are not only x86 and x86_64 out there (their current share maybe even less than everything else) – Ivan Aksamentov - Drop Oct 14 '15 at 21:36