[cfe-dev] Why -fno-pic and -fPIC gives the same results?

Peter Smith via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 24 07:59:33 PST 2019


Hello,

On many targets the instructions needed for an empty function won't
need to refer to an address at all, so will always be position
independent, hence no difference in code-generation. If you make the
example a bit more complex, such as using a global variable then
you'll see some code-generation differences between -fPIC and
-fno-pic.

Hope this helps.

Peter

On Thu, 24 Jan 2019 at 15:28, Peng Yu via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Hi,
>
> I got this. Why -fno-pic and -fPIC are the same?
>
> $ cat f.c
> void f() { }
> $ clang -fno-pic f.c -c -o nopic.o
> $ clang -fPIC f.c -c -o pic.o
> $ cmp nopic.o pic.o
> $ echo "$?"
> 0
>
> --
> Regards,
> Peng
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list