OSDN Git Service

2009-10-06 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
[pf3gnuchains/gcc-fork.git] / gcc / config / darwin.h
index 7070072..2bcc71a 100644 (file)
@@ -1,6 +1,6 @@
 /* Target definitions for Darwin (Mac OS X) systems.
    Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007
+   2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Contributed by Apple Computer Inc.
 
@@ -8,7 +8,7 @@ This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GCC is distributed in the hope that it will be useful,
@@ -16,10 +16,14 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+<http://www.gnu.org/licenses/>.  */
 
 #ifndef CONFIG_DARWIN_H
 #define CONFIG_DARWIN_H
@@ -72,6 +76,38 @@ Boston, MA 02110-1301, USA.  */
 #undef WCHAR_TYPE_SIZE
 #define WCHAR_TYPE_SIZE 32
 
+#define INT8_TYPE "signed char"
+#define INT16_TYPE "short int"
+#define INT32_TYPE "int"
+#define INT64_TYPE "long long int"
+#define UINT8_TYPE "unsigned char"
+#define UINT16_TYPE "short unsigned int"
+#define UINT32_TYPE "unsigned int"
+#define UINT64_TYPE "long long unsigned int"
+
+#define INT_LEAST8_TYPE "signed char"
+#define INT_LEAST16_TYPE "short int"
+#define INT_LEAST32_TYPE "int"
+#define INT_LEAST64_TYPE "long long int"
+#define UINT_LEAST8_TYPE "unsigned char"
+#define UINT_LEAST16_TYPE "short unsigned int"
+#define UINT_LEAST32_TYPE "unsigned int"
+#define UINT_LEAST64_TYPE "long long unsigned int"
+
+#define INT_FAST8_TYPE "signed char"
+#define INT_FAST16_TYPE "short int"
+#define INT_FAST32_TYPE "int"
+#define INT_FAST64_TYPE "long long int"
+#define UINT_FAST8_TYPE "unsigned char"
+#define UINT_FAST16_TYPE "short unsigned int"
+#define UINT_FAST32_TYPE "unsigned int"
+#define UINT_FAST64_TYPE "long long unsigned int"
+
+#define INTPTR_TYPE "long int"
+#define UINTPTR_TYPE "long unsigned int"
+
+#define SIG_ATOMIC_TYPE "int"
+
 /* Default to using the NeXT-style runtime, since that's what is
    pre-installed on Darwin systems.  */
 
@@ -147,6 +183,7 @@ extern GTY(()) int darwin_ms_struct;
   { "-multiply_defined", "-Zmultiply_defined" },  \
   { "-multi_module", "-Zmulti_module" },  \
   { "-static", "-static -Wa,-static" },  \
+  { "-shared", "-Zdynamiclib" }, \
   { "-single_module", "-Zsingle_module" },  \
   { "-unexported_symbols_list", "-Zunexported_symbols_list" }, \
   SUBTARGET_OPTION_TRANSLATE_TABLE
@@ -236,11 +273,11 @@ extern GTY(()) int darwin_ms_struct;
     %{o*}%{!o:-o a.out} \
     %{!A:%{!nostdlib:%{!nostartfiles:%S}}} \
     %{L*} %{fopenmp:%:include(libgomp.spec)%(link_gomp)}   \
-    %(link_libgcc) %o %{fprofile-arcs|fprofile-generate|coverage:-lgcov} \
+    %(link_libgcc) %o %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
     %{!nostdlib:%{!nodefaultlibs:%(link_ssp) %G %L}} \
     %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} }}}}}}}\n\
 %{!fdump=*:%{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
-    %{.c|.cc|.C|.cpp|.c++|.CPP|.m|.mm: \
+    %{.c|.cc|.C|.cpp|.cp|.c++|.cxx|.CPP|.m|.mm: \
     %{gdwarf-2:%{!gstabs*:%{!g0: dsymutil %{o*:%*}%{!o:a.out}}}}}}}}}}}}"
 
 #ifdef TARGET_SYSTEM_ROOT
@@ -257,6 +294,7 @@ extern GTY(()) int darwin_ms_struct;
 #define LINK_SPEC  \
   "%{static}%{!static:-dynamic} \
    %{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)}\
+   %{static|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\
    %{!Zdynamiclib: \
      %{Zforce_cpusubtype_ALL:-arch %(darwin_arch) -force_cpusubtype_ALL} \
      %{!Zforce_cpusubtype_ALL:-arch %(darwin_subarch)} \
@@ -297,7 +335,8 @@ extern GTY(()) int darwin_ms_struct;
    %{headerpad_max_install_names*} \
    %{Zimage_base*:-image_base %*} \
    %{Zinit*:-init %*} \
-   -macosx_version_min %(darwin_minversion) \
+   %{!mmacosx-version-min=*:-macosx_version_min %(darwin_minversion)} \
+   %{mmacosx-version-min=*:-macosx_version_min %*} \
    %{nomultidefs} \
    %{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \
    %{Zmultiply_defined*:-multiply_defined %*} \
@@ -305,6 +344,7 @@ extern GTY(()) int darwin_ms_struct;
      %:version-compare(< 10.5 mmacosx-version-min= -multiply_defined) \
      %:version-compare(< 10.5 mmacosx-version-min= suppress)}} \
    %{Zmultiplydefinedunused*:-multiply_defined_unused %*} \
+   %{fpie:-pie} \
    %{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \
    %{read_only_relocs} \
    %{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} \
@@ -350,12 +390,16 @@ extern GTY(()) int darwin_ms_struct;
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC                                                  \
    "%{static-libgcc|static: -lgcc_eh -lgcc;                               \
-      shared-libgcc|fexceptions:                                          \
+      shared-libgcc|fexceptions|fgnu-runtime:                             \
        %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)       \
        %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_s.10.5)       \
+       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)     \
+       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)     \
        -lgcc;                                                             \
       :%:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
        %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_s.10.5)       \
+       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)     \
+       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)     \
        -lgcc}"
 
 /* We specify crt0.o as -lcrt0.o so that ld will search the library path.
@@ -376,7 +420,8 @@ extern GTY(()) int darwin_ms_struct;
                 %{!pg:%{static:-lcrt0.o}                                   \
                       %{!static:%{object:-lcrt0.o}                         \
                                 %{!object:%{preload:-lcrt0.o}              \
-                                  %{!preload: %(darwin_crt1)  %(darwin_crt2)}}}}}}  \
+                                  %{!preload: %(darwin_crt1)               \
+                                             %(darwin_crt2)}}}}}}          \
   %{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
 
 /* The native Darwin linker doesn't necessarily place files in the order
@@ -384,17 +429,17 @@ extern GTY(()) int darwin_ms_struct;
    to put anything in ENDFILE_SPEC.  */
 /* #define ENDFILE_SPEC "" */
 
-#define DARWIN_EXTRA_SPECS     \
-  { "darwin_crt1", DARWIN_CRT1_SPEC },                                 \
-  { "darwin_dylib1", DARWIN_DYLIB1_SPEC },                            \
+#define DARWIN_EXTRA_SPECS                                             \
+  { "darwin_crt1", DARWIN_CRT1_SPEC },                                 \
+  { "darwin_dylib1", DARWIN_DYLIB1_SPEC },                             \
   { "darwin_minversion", DARWIN_MINVERSION_SPEC },
 
-#define DARWIN_DYLIB1_SPEC                                             \
-  "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o)          \
+#define DARWIN_DYLIB1_SPEC                                             \
+  "%:version-compare(!> 10.5 mmacosx-version-min= -ldylib1.o)          \
    %:version-compare(>= 10.5 mmacosx-version-min= -ldylib1.10.5.o)"
 
-#define DARWIN_CRT1_SPEC                                               \
-  "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o)            \
+#define DARWIN_CRT1_SPEC                                               \
+  "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o)            \
    %:version-compare(>= 10.5 mmacosx-version-min= -lcrt1.10.5.o)"
 
 /* Default Darwin ASM_SPEC, very simple.  */
@@ -405,7 +450,7 @@ extern GTY(()) int darwin_ms_struct;
 
 #define DBX_DEBUGGING_INFO 1
 
-#define DWARF2_DEBUGGING_INFO
+#define DWARF2_DEBUGGING_INFO 1
 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
 
 #define DEBUG_FRAME_SECTION    "__DWARF,__debug_frame,regular,debug"
@@ -521,6 +566,9 @@ extern GTY(()) int darwin_ms_struct;
 
 #define USER_LABEL_PREFIX "_"
 
+/* A dummy symbol that will be replaced with the function base name.  */
+#define MACHOPIC_FUNCTION_BASE_NAME "<pic base>"
+
 /* Don't output a .file directive.  That is only used by the assembler for
    error reporting.  */
 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
@@ -599,13 +647,17 @@ extern GTY(()) int darwin_ms_struct;
   } while (0)
 
 /* Wrap new method names in quotes so the assembler doesn't gag.
-   Make Objective-C internal symbols local.  */
+   Make Objective-C internal symbols local and in doing this, we need 
+   to accommodate the name mangling done by c++ on file scope locals.  */
+
+
+int darwin_label_is_anonymous_local_objc_name (const char *name);
 
 #undef ASM_OUTPUT_LABELREF
 #define ASM_OUTPUT_LABELREF(FILE,NAME)                                      \
   do {                                                                      \
        const char *xname = (NAME);                                          \
-       if (! strcmp (xname, "<pic base>"))                                  \
+       if (! strcmp (xname, MACHOPIC_FUNCTION_BASE_NAME))                   \
          machopic_output_function_base_name(FILE);                           \
        else if (xname[0] == '&' || xname[0] == '*')                         \
          {                                                                  \
@@ -625,7 +677,7 @@ extern GTY(()) int darwin_ms_struct;
         }                                                                   \
        else if (xname[0] == '+' || xname[0] == '-')                         \
          fprintf (FILE, "\"%s\"", xname);                                   \
-       else if (!strncmp (xname, "_OBJC_", 6))                              \
+       else if (darwin_label_is_anonymous_local_objc_name (xname))                                  \
          fprintf (FILE, "L%s", xname);                                      \
        else if (!strncmp (xname, ".objc_class_name_", 17))                  \
         fprintf (FILE, "%s", xname);                                        \
@@ -672,11 +724,11 @@ extern GTY(()) int darwin_ms_struct;
       }                                                                        \
   } while (0)
 
-/* The maximum alignment which the object file format can support.
-   For Mach-O, this is 2^15.  */
+/* The maximum alignment which the object file format can support in
+   bits.  For Mach-O, this is 2^15 bytes.  */
 
 #undef MAX_OFILE_ALIGNMENT
-#define MAX_OFILE_ALIGNMENT 0x8000
+#define MAX_OFILE_ALIGNMENT (0x8000 * 8)
 
 /* Declare the section variables.  */
 #ifndef USED_FOR_TARGET
@@ -699,6 +751,8 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
 #define TARGET_ASM_UNIQUE_SECTION darwin_unique_section
 #undef  TARGET_ASM_FUNCTION_RODATA_SECTION
 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
+#undef  TARGET_ASM_RELOC_RW_MASK
+#define TARGET_ASM_RELOC_RW_MASK machopic_reloc_rw_mask
 
 
 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME)                    \
@@ -886,7 +940,9 @@ enum machopic_addr_class {
 
 #define DARWIN_REGISTER_TARGET_PRAGMAS()                       \
   do {                                                         \
-    c_register_pragma (0, "mark", darwin_pragma_ignore);       \
+    if (!flag_preprocess_only)                                 \
+      cpp_register_pragma (parse_in, NULL, "mark",             \
+                          darwin_pragma_ignore, false);        \
     c_register_pragma (0, "options", darwin_pragma_options);   \
     c_register_pragma (0, "segment", darwin_pragma_ignore);    \
     c_register_pragma (0, "unused", darwin_pragma_unused);     \
@@ -934,7 +990,7 @@ void add_framework_path (char *);
 #endif
 
 /* Attempt to turn on execute permission for the stack.  This may be
-    used by INITIALIZE_TRAMPOLINE of the target needs it (that is,
+    used by TARGET_TRAMPOLINE_INIT if the target needs it (that is,
     if the target machine can change execute permissions on a page).
 
     There is no way to query the execute permission of the stack, so
@@ -978,4 +1034,16 @@ extern int flag_mkernel;
 extern int flag_apple_kext;
 #define TARGET_KEXTABI flag_apple_kext
 
+#define TARGET_HAS_TARGETCM 1
+
+#ifndef CROSS_DIRECTORY_STRUCTURE
+extern void darwin_default_min_version (int * argc, char *** argv);
+#define GCC_DRIVER_HOST_INITIALIZATION \
+  darwin_default_min_version (&argc, &argv)
+#endif /* CROSS_DIRECTORY_STRUCTURE */
+
+/* The Apple assembler and linker do not support constructor priorities.  */
+#undef SUPPORTS_INIT_PRIORITY
+#define SUPPORTS_INIT_PRIORITY 0
+
 #endif /* CONFIG_DARWIN_H */