Define __PIC__ for darwin targets.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 24 Aug 2005 18:22:12 +0000 (18:22 +0000)
committerFariborz Jahanian <fjahanian@gcc.gnu.org>
Wed, 24 Aug 2005 18:22:12 +0000 (18:22 +0000)
OKed by Mike Stump.

From-SVN: r103447

gcc/ChangeLog
gcc/config/darwin.h
gcc/config/rs6000/darwin.h
gcc/testsuite/gcc.dg/pic-macro-define.c [new file with mode: 0644]

index b20069cb28a39106987ba403292646716ec13a67..26ea0debe955b7eb7bf77c4886e1266b2320c07f 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-24  Fariborz Jahanian <fjahanian@apple.com>
+
+       * config/darwin.h: define __PIC__
+       * config/rs6000/darwin.h: Add SUBTARGET_OS_CPP_BUILTINS to
+       TARGET_OS_CPP_BUILTINS macro.
+
 2005-08-24  Paolo Bonzini  <bonzini@gnu.org>
 
        * config/rs6000/rs6000.md: Fix thinko in the peephole2 I added
index c611cb8b1da7af4cc5b9da2cb8a4177ca9be82a7..08abfbe10009d4f4ee35cac8826e93eb5dcf0223 100644 (file)
@@ -140,6 +140,14 @@ Boston, MA 02110-1301, USA.  */
   { "-unexported_symbols_list", "-Zunexported_symbols_list" }, \
   SUBTARGET_OPTION_TRANSLATE_TABLE
 
+#define SUBTARGET_OS_CPP_BUILTINS()                     \
+  do                                                   \
+    {                                                  \
+      if (flag_pic)                                    \
+       builtin_define ("__PIC__");                     \
+    }                                                  \
+  while (0)
+
 /* These compiler options take n arguments.  */
 
 #undef  WORD_SWITCH_TAKES_ARG
index 482c6e74f9a3eac747c17b9c385d75baea78f567..ef1532d776f2f811949140163442b9614f4ec4d5 100644 (file)
@@ -55,6 +55,7 @@
       builtin_define ("__POWERPC__");           \
       builtin_define ("__NATURAL_ALIGNMENT__"); \
       darwin_cpp_builtins (pfile);             \
+      SUBTARGET_OS_CPP_BUILTINS ();             \
     }                                           \
   while (0)
 
diff --git a/gcc/testsuite/gcc.dg/pic-macro-define.c b/gcc/testsuite/gcc.dg/pic-macro-define.c
new file mode 100644 (file)
index 0000000..7bda6fe
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run { target "i?86-*-*-darwin" powerpc*-*-darwin* } } */
+/* { dg-options "-fPIC" } */
+
+#if defined __PIC__ 
+int main() {
+       return 0;
+}
+#else
+  error "NO __PIC__ DEFINED"   
+#endif