[PATCH] D15455: [Driver] Let -static override the toolchain default PIC setting.

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 11 12:59:55 PST 2015


On Fri, Dec 11, 2015 at 07:49:25PM +0000, Frederic Riss wrote:
> friss added a comment.
> 
> Just because it makes the behavior more intuitive? If you toolchain
> does PIC by default, it's because you are mostly building shared
> objects. When you are building a static object, it's highly likely
> that you don't need PIC. There should be a way to enable it, but I
> find it really awkward to have to spell "clang -static -fno-PIC" to
> get the intuitive behavior.

There is nothing wrong with linking PIC as static binary. In some cases
that can even result in more compact binaries. The only platforms I know
that default to PIC are some RISC architectures like PPC or MIPS, where
the overhead of materializing immediates is comparable to indirect
calls. Most people don't use single-step compilation anyway, so your
change would be just more puzzling. Why does clang -c && clang -static
give different results than clang -static?

Joerg


More information about the cfe-commits mailing list