OSDN Git Service

Add framework support for darwin.
[pf3gnuchains/gcc-fork.git] / gcc / config / darwin.h
index 4f9b487..b5dae39 100644 (file)
@@ -1,25 +1,28 @@
 /* Target definitions for Darwin (Mac OS X) systems.
-   Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002, 2003
+   Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
    Contributed by Apple Computer Inc.
 
-This file is part of GNU CC.
+This file is part of GCC.
 
-GNU CC is free software; you can redistribute it and/or modify
+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)
 any later version.
 
-GNU CC is distributed in the hope that it will be useful,
+GCC is distributed in the hope that it will be useful,
 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 GNU CC; see the file COPYING.  If not, write to
+along with GCC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#ifndef CONFIG_DARWIN_H
+#define CONFIG_DARWIN_H
+
 /* The definitions in this file are common to all processor types
    running Darwin, which is the kernel for Mac OS X.  Darwin is
    basically a BSD user layer laid over a Mach kernel, then evolved
@@ -30,11 +33,6 @@ Boston, MA 02111-1307, USA.  */
 /* Although NeXT ran on many different architectures, as of Jan 2001
    the only supported Darwin targets are PowerPC and x86.  */
 
-/* Technically, STANDARD_EXEC_PREFIX should be /usr/libexec/, but in
-   practice this makes it hard to install new compilers elsewhere, so
-   leave it undefined and expect system builders to set configure args
-   correctly.  */
-
 /* One of Darwin's NeXT legacies is the Mach-O format, which is partly
    like a.out and partly like COFF, with additional features like
    multi-architecture binary support.  */
@@ -99,7 +97,13 @@ Boston, MA 02111-1307, USA.  */
    Note that an option name with a prefix that matches another option
    name, that also takes an argument, needs to be modified so the
    prefix is different, otherwise a '*' after the shorter option will
-   match with the longer one.  */
+   match with the longer one.
+   
+   The SUBTARGET_OPTION_TRANSLATE_TABLE macro, which _must_ be defined
+   in gcc/config/{i386,rs6000}/darwin.h, should contain any additional
+   command-line option translations specific to the particular target
+   architecture.  */
+   
 #define TARGET_OPTION_TRANSLATE_TABLE \
   { "-all_load", "-Zall_load" },  \
   { "-allowable_client", "-Zallowable_client" },  \
@@ -115,6 +119,7 @@ Boston, MA 02111-1307, USA.  */
   { "-exported_symbols_list", "-Zexported_symbols_list" },  \
   { "-seg_addr_table_filename", "-Zseg_addr_table_filename" }, \
   { "-filelist", "-Xlinker -filelist -Xlinker" },  \
+  { "-framework", "-Xlinker -framework -Xlinker" },  \
   { "-flat_namespace", "-Zflat_namespace" },  \
   { "-force_cpusubtype_ALL", "-Zforce_cpusubtype_ALL" },  \
   { "-force_flat_namespace", "-Zforce_flat_namespace" },  \
@@ -126,8 +131,9 @@ Boston, MA 02111-1307, USA.  */
   { "-multi_module", "-Zmulti_module" },  \
   { "-static", "-static -Wa,-static" },  \
   { "-single_module", "-Zsingle_module" },  \
-  { "-unexported_symbols_list", "-Zunexported_symbols_list" }
-
+  { "-unexported_symbols_list", "-Zunexported_symbols_list" }, \
+  SUBTARGET_OPTION_TRANSLATE_TABLE
+  
 /* These compiler options take n arguments.  */
 
 #undef  WORD_SWITCH_TAKES_ARG
@@ -170,10 +176,13 @@ Boston, MA 02111-1307, USA.  */
    !strcmp (STR, "dylinker_install_name") ? 1 : \
    0)
 
-/* Machine dependent cpp options.  */
+/* Machine dependent cpp options.  __APPLE_CC__ is defined as the
+   Apple include files expect it to be defined and won't work if it
+   isn't.  */
 
 #undef CPP_SPEC
-#define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}"
+#define CPP_SPEC "%{static:%{!dynamic:-D__STATIC__}}%{!static:-D__DYNAMIC__}\
+    -D__APPLE_CC__=1"
 
 /* This is mostly a clone of the standard LINK_COMMAND_SPEC, plus
    precomp, libtool, and fat build additions.  Also we
@@ -186,11 +195,13 @@ Boston, MA 02111-1307, USA.  */
 #define LINK_COMMAND_SPEC "\
 %{!fdump=*:%{!fsyntax-only:%{!precomp:%{!c:%{!M:%{!MM:%{!E:%{!S:\
     %{!Zdynamiclib:%(linker)}%{Zdynamiclib:/usr/bin/libtool} \
+    %{!Zdynamiclib:-arch %(darwin_arch)} \
+    %{Zdynamiclib:-arch_only %(darwin_arch)} \
     %l %X %{d} %{s} %{t} %{Z} \
     %{!Zdynamiclib:%{A} %{e*} %{m} %{N} %{n} %{r} %{u*} %{x} %{z}} \
     %{@:-o %f%u.out}%{!@:%{o*}%{!o:-o a.out}} \
     %{!Zdynamiclib:%{!A:%{!nostdlib:%{!nostartfiles:%S}}}} \
-    %{L*} %(link_libgcc) %o %{fprofile-arcs:-lgcov} \
+    %{L*} %(link_libgcc) %o %{fprofile-arcs|fprofile-generate:-lgcov} \
     %{!nostdlib:%{!nodefaultlibs:%G %L}} \
     %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} \
     %{!--help:%{!no-c++filt|c++filt:| c++filt3 }} }}}}}}}}"
@@ -244,7 +255,7 @@ Boston, MA 02111-1307, USA.  */
    %{Zmulti_module:-multi_module} %{Zsingle_module:-single_module} \
    %{Zmultiply_defined*:-multiply_defined %*} \
    %{Zmultiplydefinedunused*:-multiply_defined_unused %*} \
-   %{prebind} %{noprebind} %{prebind_all_twolevel_modules} \
+   %{prebind} %{noprebind} %{nofixprebinding} %{prebind_all_twolevel_modules} \
    %{read_only_relocs} \
    %{sectcreate*} %{sectorder*} %{seg1addr*} %{segprot*} %{seg_addr_table*} \
    %{Zseg_addr_table_filename*:-seg_addr_table_filename %*} \
@@ -356,18 +367,22 @@ do { text_section ();                                                     \
 #undef ASM_DECLARE_OBJECT_NAME
 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                      \
   do {                                                                 \
-    const char *xname = NAME;                                           \
-    if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)             \
-      xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                    \
-    if ((TREE_STATIC (DECL)                                             \
-        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
-        || DECL_INITIAL (DECL))                                         \
-      machopic_define_name (xname);                                     \
-    if ((TREE_STATIC (DECL)                                             \
-        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
-        || DECL_INITIAL (DECL))                                         \
+    const char *xname = NAME;                                          \
+    if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF)            \
+      xname = IDENTIFIER_POINTER (DECL_NAME (DECL));                   \
+    if ((TREE_STATIC (DECL)                                            \
+        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
+        || DECL_INITIAL (DECL))                                                \
+      machopic_define_name (xname);                                    \
+    if ((TREE_STATIC (DECL)                                            \
+        && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL)))               \
+        || DECL_INITIAL (DECL))                                                \
       (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);  \
-    ASM_OUTPUT_LABEL (FILE, xname);                                     \
+    ASM_OUTPUT_LABEL (FILE, xname);                                    \
+    /* Darwin doesn't support zero-size objects, so give them a        \
+       byte.  */                                                       \
+    if (tree_low_cst (DECL_SIZE_UNIT (DECL), 1) == 0)                  \
+      assemble_zeros (1);                                              \
   } while (0)
 
 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
@@ -384,9 +399,15 @@ do { text_section ();                                                      \
         || DECL_INITIAL (DECL))                                         \
       (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false);  \
     ASM_OUTPUT_LABEL (FILE, xname);                                     \
-    /* Avoid generating stubs for functions we've just defined by      \
-       outputting any required stub name label now.  */                        \
-    machopic_output_possible_stub_label (FILE, xname);                 \
+  } while (0)
+
+#define ASM_DECLARE_CONSTANT_NAME(FILE, NAME, EXP, SIZE)       \
+  do {                                                         \
+    ASM_OUTPUT_LABEL (FILE, NAME);                             \
+    /* Darwin doesn't support zero-size objects, so give them a        \
+       byte.  */                                               \
+    if ((SIZE) == 0)                                           \
+      assemble_zeros (1);                                      \
   } while (0)
 
 /* Wrap new method names in quotes so the assembler doesn't gag.
@@ -465,9 +486,9 @@ do { text_section ();                                                       \
 
 #undef SECTION_FUNCTION
 #define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, OBJC)           \
-extern void FUNCTION PARAMS ((void));                                  \
+extern void FUNCTION (void);                                           \
 void                                                                   \
-FUNCTION ()                                                            \
+FUNCTION (void)                                                                \
 {                                                                      \
   if (in_section != SECTION)                                           \
     {                                                                  \
@@ -495,8 +516,9 @@ FUNCTION ()                                                         \
   in_objc_symbols, in_objc_module_info,                        \
   in_objc_protocol, in_objc_string_object,             \
   in_objc_constant_string_object,                      \
+  in_objc_image_info,                                  \
   in_objc_class_names, in_objc_meth_var_names,         \
-  in_objc_meth_var_types, in_objc_cls_refs,            \
+  in_objc_meth_var_types, in_objc_cls_refs,            \
   in_machopic_nl_symbol_ptr,                           \
   in_machopic_lazy_symbol_ptr,                         \
   in_machopic_symbol_stub,                             \
@@ -508,7 +530,7 @@ FUNCTION ()                                                         \
 
 #undef EXTRA_SECTION_FUNCTIONS
 #define EXTRA_SECTION_FUNCTIONS                        \
-static void objc_section_init PARAMS ((void)); \
+static void objc_section_init (void);          \
 SECTION_FUNCTION (const_section,               \
                   in_const,                    \
                   ".const", 0)                 \
@@ -584,6 +606,10 @@ SECTION_FUNCTION (objc_string_object_section,      \
 SECTION_FUNCTION (objc_constant_string_object_section, \
                  in_objc_constant_string_object,       \
                  ".section __OBJC, __cstring_object", 1)       \
+/* Fix-and-Continue image marker.  */          \
+SECTION_FUNCTION (objc_image_info_section,     \
+                  in_objc_image_info,          \
+                  ".section __OBJC, __image_info", 1)  \
 SECTION_FUNCTION (objc_class_names_section,    \
                in_objc_class_names,            \
                ".objc_class_names", 1) \
@@ -599,19 +625,19 @@ SECTION_FUNCTION (objc_cls_refs_section,  \
                                                \
 SECTION_FUNCTION (machopic_lazy_symbol_ptr_section,    \
                in_machopic_lazy_symbol_ptr,            \
-               ".lazy_symbol_pointer", 0)              \
+               ".lazy_symbol_pointer", 0)      \
 SECTION_FUNCTION (machopic_nl_symbol_ptr_section,      \
                in_machopic_nl_symbol_ptr,              \
-               ".non_lazy_symbol_pointer", 0)          \
+               ".non_lazy_symbol_pointer", 0)  \
 SECTION_FUNCTION (machopic_symbol_stub_section,                \
                in_machopic_symbol_stub,                \
-               ".symbol_stub", 0)                      \
+               ".symbol_stub", 0)              \
 SECTION_FUNCTION (machopic_symbol_stub1_section,       \
                in_machopic_symbol_stub1,               \
                ".section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16", 0)\
 SECTION_FUNCTION (machopic_picsymbol_stub_section,     \
                in_machopic_picsymbol_stub,             \
-               ".picsymbol_stub", 0)                   \
+               ".picsymbol_stub", 0)           \
 SECTION_FUNCTION (machopic_picsymbol_stub1_section,    \
                in_machopic_picsymbol_stub1,            \
                ".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32", 0)\
@@ -623,7 +649,7 @@ SECTION_FUNCTION (darwin_eh_frame_section,          \
                ".section __TEXT,__eh_frame", 0)        \
                                                        \
 static void                                    \
-objc_section_init ()                           \
+objc_section_init (void)                       \
 {                                              \
   static int been_here = 0;                    \
                                                \
@@ -640,7 +666,7 @@ objc_section_init ()                                \
       objc_cls_refs_section ();                        \
       objc_class_section ();                   \
       objc_meta_class_section ();              \
-          /* shared, hot -> cold */                    \
+          /* shared, hot -> cold */            \
       objc_cls_meth_section ();                        \
       objc_inst_meth_section ();               \
       objc_protocol_section ();                        \
@@ -663,7 +689,7 @@ objc_section_init ()                                \
 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
 
 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME)                    \
-    do {                                                               \
+    do {                                                               \
         if (FILE) {                                                    \
           if (MACHOPIC_INDIRECT)                                       \
             fprintf (FILE, "\t.lazy_reference ");                      \
@@ -678,7 +704,7 @@ objc_section_init ()                                \
     do {                                                               \
         if (FILE) {                                                    \
           fprintf (FILE, "\t");                                        \
-          assemble_name (FILE, NAME);                                  \
+          assemble_name (FILE, NAME);                                  \
           fprintf (FILE, "=0\n");                                      \
           (*targetm.asm_out.globalize_label) (FILE, NAME);             \
         }                                                              \
@@ -688,6 +714,13 @@ objc_section_init ()                               \
 #define GLOBAL_ASM_OP ".globl "
 #define TARGET_ASM_GLOBALIZE_LABEL darwin_globalize_label
 
+/* Emit an assembler directive to set visibility for a symbol.  Used
+   to support visibility attribute and Darwin's private extern
+   feature.  */
+#undef TARGET_ASM_ASSEMBLE_VISIBILITY
+#define TARGET_ASM_ASSEMBLE_VISIBILITY darwin_assemble_visibility
+
+
 #undef ASM_GENERATE_INTERNAL_LABEL
 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)  \
   sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM))
@@ -780,7 +813,7 @@ enum machopic_addr_class {
 #define TARGET_ASM_EXCEPTION_SECTION darwin_exception_section
 
 #define TARGET_ASM_EH_FRAME_SECTION darwin_eh_frame_section
-  
+
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
   (((CODE) == 2 && (GLOBAL) == 1) \
@@ -804,3 +837,13 @@ enum machopic_addr_class {
 #define ASM_APP_ON ""
 #undef ASM_APP_OFF
 #define ASM_APP_OFF ""
+
+void darwin_register_frameworks (int);
+#define TARGET_EXTRA_INCLUDES darwin_register_frameworks
+
+void add_framework_path (char *);
+#define TARGET_OPTF add_framework_path
+
+#define TARGET_HAS_F_SETLKW
+
+#endif /* CONFIG_DARWIN_H */