-fPIC总是一个坏主意吗?

时间:2021-07-21 20:25:30

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?

即使我可能不打算将生成的可重定位目标文件链接到共享库中,总是使用-fPIC进行编译是否有任何损害?

1 个解决方案

#1


2  

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

好吧,总是使用-fPIC进行编译会产生更多的膨胀和更慢的代码。

Difference would be less visible on x64 target, I believe

我认为差异在x64目标上不太明显

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

您应该测量并确定这些差异是否与您的应用程序相关,您可能会对它感到满意

#1


2  

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

好吧,总是使用-fPIC进行编译会产生更多的膨胀和更慢的代码。

Difference would be less visible on x64 target, I believe

我认为差异在x64目标上不太明显

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

您应该测量并确定这些差异是否与您的应用程序相关,您可能会对它感到满意