]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libobjc/11572 (GNU libobjc no longer compiled on Darwin)
authorAndrew Pinski <pinskia@physics.uc.edu>
Thu, 16 Sep 2004 06:49:59 +0000 (06:49 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Thu, 16 Sep 2004 06:49:59 +0000 (23:49 -0700)
2004-09-15  Andrew Pinski  <pinskia@physics.uc.edu>

        PR target/11572
        * c-incpath.h (target_c_incpath_s): Add extra_pre_includes.
        Add two parameters to extra_includes.
        (C_INCPATH_INIT): Remove.
        * c-incpath.c (register_include_chains): Call extra_pre_includes
        before adding the standard include directory.
        Update call to extra_includes.
        (!defined TARGET_EXTRA_INCLUDES): Update
        hook_void_charptr_charptr_int and add !define
        TARGET_EXTRA_PRE_INCLUDES.
        (!define TARGET_EXTRA_INCLUDES): Define as
        hook_void_charptr_charptr_int.
        (!define TARGET_EXTRA_PRE_INCLUDES): Likewise.
        (target_c_incpath): Always declare.
        * fixinclude.c (defined TARGET_EXTRA_INCLUDES): Declare a
        empty function.
        (define TARGET_EXTRA_PRE_INCLUDES): Likewise.
        * config/darwin.h: (darwin_register_frameworks): Update for
        the two new parameters.
        (darwin_register_objc_includes): Add prototype.
        (TARGET_EXTRA_PRE_INCLUDES): Define.
        * config/darwin-c.c (darwin_register_objc_includes): New function.
        (darwin_register_frameworks): Update for the two new parameters.
        (target_c_incpath): Remove.
        * config/t-darwin (darwin-c.o): Add $(PREPROCESSOR_DEFINES) to
        the compile line.
        * doc/tm.texi (TARGET_EXTRA_INCLUDES): Document the two new
        parameters.
        (TARGET_EXTRA_PRE_INCLUDES): Document.

        * gcc.c (spec_function): Add replace-outfile.
        (replace_outfile_spec_function): New function.
        * config/darwin.h (LINK_SPEC): Add replace
        -lobjc with -lobjc-gnu if -fgnu-runtime is
        supplied.
        * invoke.texi (replace-outfile): Document.

From-SVN: r87588

gcc/ChangeLog
gcc/c-incpath.c
gcc/c-incpath.h
gcc/config/darwin-c.c
gcc/config/darwin.h
gcc/config/t-darwin
gcc/doc/invoke.texi
gcc/doc/tm.texi
gcc/fix-header.c
gcc/gcc.c

index 8649f2eb7c46a80b2ff84954f96f49088d6570f3..34f011a5b3cf31f2855f369ce30845364f0e7adc 100644 (file)
@@ -1,3 +1,42 @@
+2004-09-15  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR target/11572
+       * c-incpath.h (target_c_incpath_s): Add extra_pre_includes.
+       Add two parameters to extra_includes.
+       (C_INCPATH_INIT): Remove.
+       * c-incpath.c (register_include_chains): Call extra_pre_includes
+       before adding the standard include directory.
+       Update call to extra_includes.
+       (!defined TARGET_EXTRA_INCLUDES): Update
+       hook_void_charptr_charptr_int and add !define
+       TARGET_EXTRA_PRE_INCLUDES.
+       (!define TARGET_EXTRA_INCLUDES): Define as
+       hook_void_charptr_charptr_int.
+       (!define TARGET_EXTRA_PRE_INCLUDES): Likewise.
+       (target_c_incpath): Always declare.
+       * fixinclude.c (defined TARGET_EXTRA_INCLUDES): Declare a
+       empty function.
+       (define TARGET_EXTRA_PRE_INCLUDES): Likewise.
+       * config/darwin.h: (darwin_register_frameworks): Update for
+       the two new parameters.
+       (darwin_register_objc_includes): Add prototype.
+       (TARGET_EXTRA_PRE_INCLUDES): Define.
+       * config/darwin-c.c (darwin_register_objc_includes): New function.
+       (darwin_register_frameworks): Update for the two new parameters.
+       (target_c_incpath): Remove.
+       * config/t-darwin (darwin-c.o): Add $(PREPROCESSOR_DEFINES) to
+       the compile line.
+       * doc/tm.texi (TARGET_EXTRA_INCLUDES): Document the two new
+       parameters.
+       (TARGET_EXTRA_PRE_INCLUDES): Document.
+
+       * gcc.c (spec_function): Add replace-outfile.
+       (replace_outfile_spec_function): New function.
+       * config/darwin.h (LINK_SPEC): Add replace
+       -lobjc with -lobjc-gnu if -fgnu-runtime is
+       supplied.
+       * invoke.texi (replace-outfile): Document.
+
 2004-09-13  Jan Hubicka  <jh@suse.cz>
 
        * predict.c (expr_expected_value, strip_builtin_expect): New function.
index 1a985f9c9aa16c05f769ef2a8f2dcdf580a2b824..4fd1b131ed89e71c6ce430ef6c8b7f76a697fd3c 100644 (file)
@@ -372,21 +372,34 @@ register_include_chains (cpp_reader *pfile, const char *sysroot,
      include chain.  */
   add_env_var_paths ("CPATH", BRACKET);
   add_env_var_paths (lang_env_vars[idx], SYSTEM);
+  
+  target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
 
   /* Finally chain on the standard directories.  */
   if (stdinc)
     add_standard_paths (sysroot, iprefix, cxx_stdinc);
 
-  target_c_incpath.extra_includes (stdinc);
+  target_c_incpath.extra_includes (sysroot, iprefix, stdinc);
 
   merge_include_chains (pfile, verbose);
 
   cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
                          quote_ignores_source_dir);
 }
+#if !(defined TARGET_EXTRA_INCLUDES) || !(defined TARGET_EXTRA_PRE_INCLUDES)
+static void hook_void_charptr_charptr_int (const char *sysroot ATTRIBUTE_UNUSED,
+                                          const char *iprefix ATTRIBUTE_UNUSED,
+                                          int stdinc ATTRIBUTE_UNUSED)
+{
+}
+#endif
 
 #ifndef TARGET_EXTRA_INCLUDES
-static void hook_void_int(int u ATTRIBUTE_UNUSED) { }
-
-struct target_c_incpath_s target_c_incpath = { hook_void_int };
+#define TARGET_EXTRA_INCLUDES hook_void_charptr_charptr_int
 #endif
+#ifndef TARGET_EXTRA_PRE_INCLUDES
+#define TARGET_EXTRA_PRE_INCLUDES hook_void_charptr_charptr_int
+#endif
+
+struct target_c_incpath_s target_c_incpath = { TARGET_EXTRA_PRE_INCLUDES, TARGET_EXTRA_INCLUDES };
+
index 1096016784f06ec44a72440f2c0dfd74deeb6f95..cc261a6d88423c6754542c6a9fb36f823947b046 100644 (file)
@@ -23,11 +23,10 @@ extern void add_cpp_dir_path (struct cpp_dir *, int);
 
 struct target_c_incpath_s {
   /* Do extra includes processing.  STDINC is false iff -nostdinc was given.  */
-  void (*extra_includes) (int);
+  void (*extra_pre_includes) (const char *, const char *, int);
+  void (*extra_includes) (const char *, const char *, int);
 };
 
 extern struct target_c_incpath_s target_c_incpath;
 
-#define C_INCPATH_INIT { TARGET_EXTRA_INCLUDES }
-
 enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
index 9adf2498bcce147808a75bca7722fbe94ea76754..d7f3e01016f3504f284fdfd4e6e2163f2fda9d9c 100644 (file)
@@ -30,6 +30,8 @@ Boston, MA 02111-1307, USA.  */
 #include "c-incpath.h"
 #include "toplev.h"
 #include "tm_p.h"
+#include "cppdefault.h"
+#include "prefix.h"
 
 /* Pragmas.  */
 
@@ -419,13 +421,55 @@ static const char *framework_defaults [] =
     "/Library/Frameworks",
   };
 
+/* Register the GNU objective-C runtime include path if STDINC.  */
+
+void
+darwin_register_objc_includes (const char *sysroot, const char *iprefix,
+                              int stdinc)
+{
+  const char *fname;
+  size_t len;
+  /* We do not do anything if we do not want the standard includes. */
+  if (!stdinc)
+    return;
+  
+  fname = GCC_INCLUDE_DIR "-gnu-runtime";
+  
+  /* Register the GNU OBJC runtime include path if we are compiling  OBJC
+    with GNU-runtime.  */
+
+  if (c_dialect_objc () && !flag_next_runtime)
+    {
+      char *str;
+      /* See if our directory starts with the standard prefix.
+        "Translate" them, ie. replace /usr/local/lib/gcc... with
+        IPREFIX and search them first.  */
+      if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0 && !sysroot
+         && !strncmp (fname, cpp_GCC_INCLUDE_DIR, len))
+       {
+         str = concat (iprefix, fname + len, NULL);
+          /* FIXME: wrap the headers for C++awareness.  */
+         add_path (str, SYSTEM, /*c++aware=*/false, false);
+       }
+      
+      /* Should this directory start with the sysroot?  */
+      if (sysroot)
+       str = concat (sysroot, fname, NULL);
+      else
+       str = update_path (fname, "");
+      
+      add_path (str, SYSTEM, /*c++aware=*/false, false);
+    }
+}
+
 
 /* Register all the system framework paths if STDINC is true and setup
    the missing_header callback for subframework searching if any
    frameworks had been registered.  */
 
 void
-darwin_register_frameworks (int stdinc)
+darwin_register_frameworks (const char *sysroot ATTRIBUTE_UNUSED,
+                           const char *iprefix ATTRIBUTE_UNUSED, int stdinc)
 {
   if (stdinc)
     {
@@ -476,5 +520,3 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
 
   return 0;
 }
-
-struct target_c_incpath_s target_c_incpath = C_INCPATH_INIT;
index a89976e14e90a48d315261fee24ba28cf5bbecd7..0fd84739d08084f3a6ddd461ccfe0d727b2eb6f0 100644 (file)
@@ -238,6 +238,7 @@ extern const char *darwin_fix_and_continue_switch;
    their names so all of them get passed.  */
 #define LINK_SPEC  \
   "%{static}%{!static:-dynamic} \
+   %{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)}\
    %{!Zdynamiclib: \
      %{Zbundle:-bundle} \
      %{Zbundle_loader*:-bundle_loader %*} \
@@ -962,7 +963,9 @@ enum machopic_addr_class {
 #undef ASM_APP_OFF
 #define ASM_APP_OFF ""
 
-void darwin_register_frameworks (int);
+void darwin_register_frameworks (const char *, const char *, int);
+void darwin_register_objc_includes (const char *, const char *, int);
+#define TARGET_EXTRA_PRE_INCLUDES darwin_register_objc_includes
 #define TARGET_EXTRA_INCLUDES darwin_register_frameworks
 
 void add_framework_path (char *);
index fcc81edd14a71200b13b04cfcd5acf3561ad5153..ab2e6ae05c1414d5922332b05f3d2282c6112a08 100644 (file)
@@ -7,7 +7,7 @@ darwin.o: $(srcdir)/config/darwin.c $(CONFIG_H) $(SYSTEM_H) coretypes.h     \
 darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(TM_H) $(CPPLIB_H) tree.h c-pragma.h $(C_TREE_H) toplev.h $(TM_P_H) \
   c-incpath.h
-       $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/darwin-c.c
+       $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/darwin-c.c $(PREPROCESSOR_DEFINES)
 
 gt-darwin.h : s-gtype ; @true
 
index 7d473f6532dcc9e0da99981801c2506373b615d3..b172cd39166939457aacee7d3feb67f7d76cda16 100644 (file)
@@ -6361,6 +6361,16 @@ based on the existence of the first.  Here is a small example of its usage:
 crt0%O%s %:if-exists(crti%O%s) \
 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
 @end smallexample
+
+@item @code{replace-outfile}
+The @code{replace-outfile} spec function takes two arguments.  It looks for the
+first argument in the outfiles array and replaces it with the second argument.  Here
+is a small example of its usage:
+
+@smallexample
+%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
+@end smallexample
+
 @end table
 
 @item %@{@code{S}@}
index 1b3d466c1db939a18fc79838e6c0caae074a2380..f0132e01f540da6348514dd27d12a6896b8ba9b2 100644 (file)
@@ -9370,10 +9370,19 @@ system library's @code{pow}, @code{powf} or @code{powl} routines.
 The default value places no upper bound on the multiplication count.
 @end defmac
 
-@deftypefn Macro void TARGET_EXTRA_INCLUDES (int @var{stdinc})
+@deftypefn Macro void TARGET_EXTRA_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
 This target hook should register any extra include files for the
 target.  The parameter @var{stdinc} indicates if normal include files
-are present.
+are present.  The parameter @var{sysroot} is the system root directory.
+The parameter @var{iprefix} is the prefix for the gcc directory.
+@end deftypefn
+
+@deftypefn Macro void TARGET_EXTRA_PRE_INCLUDES (const char *@var{sysroot}, const char *@var{iprefix}, int @var{stdinc})
+This target hook should register any extra include files for the
+target before any standard headers.  The parameter @var{stdinc}
+indicates if normal include files are present.  The parameter
+@var{sysroot} is the system root directory.  The parameter
+@var{iprefix} is the prefix for the gcc directory.
 @end deftypefn
 
 @deftypefn Macro void TARGET_OPTF (char *@var{path})
index 9bd79d404ce77764098c195dfef186c4d529ccb9..4e4c8dc969248b1cec8ecbe538772999605403cb 100644 (file)
@@ -82,9 +82,19 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "errors.h"
 
 #ifdef TARGET_EXTRA_INCLUDES
-static void hook_void_int(int u ATTRIBUTE_UNUSED) { }
+void TARGET_EXTRA_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
+                           const char *iprefix ATTRIBUTE_UNUSED,
+                           int stdinc ATTRIBUTE_UNUSED)
+{
+}
+#endif
 
-struct target_c_incpath_s target_c_incpath = { hook_void_int };
+#ifdef TARGET_EXTRA_PRE_INCLUDES 
+void TARGET_EXTRA_PRE_INCLUDES (const char *sysroot ATTRIBUTE_UNUSED,
+                           const char *iprefix ATTRIBUTE_UNUSED,
+                           int stdinc ATTRIBUTE_UNUSED)
+{
+}
 #endif
 
 struct line_maps line_table;
index 45a9ab44b75453b1e4b587127e494d5b0d264a7f..6e7dec933ca246e5fc4303d832a19cdfab00fc1c 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -361,6 +361,7 @@ static const char *convert_filename (const char *, int, int);
 
 static const char *if_exists_spec_function (int, const char **);
 static const char *if_exists_else_spec_function (int, const char **);
+static const char *replace_outfile_spec_function (int, const char **);
 \f
 /* The Specs Language
 
@@ -1572,6 +1573,7 @@ static const struct spec_function static_spec_functions[] =
 {
   { "if-exists",               if_exists_spec_function },
   { "if-exists-else",          if_exists_else_spec_function },
+  { "replace-outfile",         replace_outfile_spec_function },
   { 0, 0 }
 };
 
@@ -7582,3 +7584,24 @@ if_exists_else_spec_function (int argc, const char **argv)
 
   return argv[1];
 }
+
+/* replace-outfile built-in spec function.
+   This looks for the first argument in the outfiles array's name and replaces it
+   with the second argument.  */
+
+static const char *
+replace_outfile_spec_function (int argc, const char **argv)
+{
+  int i;
+  /* Must have exactly two arguments.  */
+  if (argc != 2)
+    abort ();
+  
+  for (i = 0; i < n_infiles; i++)
+    {
+      if (outfiles[i] && !strcmp (outfiles[i], argv[0]))
+       outfiles[i] = xstrdup (argv[1]);
+    }
+  return NULL;
+}
+