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

Bob Wilson via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 16 15:59:10 PST 2015


bob.wilson added a subscriber: bob.wilson.
bob.wilson added a comment.

There has been a long-standing convention in both gcc and clang for Darwin that -static changes the default for PIC. Changing that convention is breaking stuff for us. The commit message for r245667 says "This new behavior also matches GCC", but that is not correct, at least for Darwin. I just tried compiling a simple test file with gcc-4.8.2 for OS X. If you run "gcc -v" with and without -static, you'll see that the gcc driver adds -fPIC to the cc1 command only when you do not use -static. I only have access to the GCC sources from an old version, but the config/i386/darwin.h file has this:

/* We want -fPIC by default, unless we're using -static to compile for

  the kernel or some such.  */

#undef CC1_SPEC
#define CC1_SPEC "%{!mkernel:%{!static:%{!mdynamic-no-pic:-fPIC}}}
....

We can change this to be Darwin-specific if you prefer, but we should maintain compatibility with GCC and previous Clang releases in this behavior.


http://reviews.llvm.org/D15455





More information about the cfe-commits mailing list