Set __PIC__ (more) correctly.
- Add -pic-level clang-cc option to specify the value for the define,
updated driver to pass this.
- Added __pic__
- Added OBJC_ZEROCOST_EXCEPTIONS define while I was here (to match gcc).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68584 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index f44be0a..eb9bbf2 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -124,6 +124,17 @@
CmdArgs.push_back("--relocation-model");
CmdArgs.push_back(Model);
+ // Infer the __PIC__ value.
+ //
+ // FIXME: This isn't quite right on Darwin, which always sets
+ // __PIC__=2.
+ if (strcmp(Model, "pic") == 0 || strcmp(Model, "dynamic-no-pic") == 0) {
+ if (Args.hasArg(options::OPT_fPIC))
+ CmdArgs.push_back("-pic-level=2");
+ else
+ CmdArgs.push_back("-pic-level=1");
+ }
+
if (Args.hasArg(options::OPT_ftime_report))
CmdArgs.push_back("--time-passes");
// FIXME: Set --enable-unsafe-fp-math.