This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/PATCH] step 3, linking in gnu libobjc instead of NeXT^wApple's libobjc


To make linking on Darwin as painless as linking on anyother target with GNU's libobjc,
I had to add a new spec builtin function which replaces the name of an outfile with a
different name, replace-outfile.  This allows for little changes to the driver and
little changes to the back-end header file.

OK? Bootstrapped on powerpc-apple-darwin with my previous patch applied with no regressions
and plus I ran the objc's testsuite with -fgnu-runtime option and there seemed like there
was no unexpected failures.


ChangeLog:
	* 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.


Patch:
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.468
diff -u -p -r1.468 invoke.texi
--- doc/invoke.texi	1 Jun 2004 07:13:51 -0000	1.468
+++ doc/invoke.texi	14 Jun 2004 05:07:35 -0000
@@ -6038,6 +6038,16 @@ based on the existence of the first.  He
 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: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.424
diff -u -p -r1.424 gcc.c
--- gcc.c	4 Jun 2004 20:13:14 -0000	1.424
+++ gcc.c	14 Jun 2004 05:07:42 -0000
@@ -361,6 +361,7 @@ static const char *convert_filename (con
 
 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 **);
 
 /* The Specs Language
 
@@ -1561,6 +1562,7 @@ static const struct spec_function static
 {
   { "if-exists",		if_exists_spec_function },
   { "if-exists-else",		if_exists_else_spec_function },
+  { "replace-outfile",		replace_outfile_spec_function },
   { 0, 0 }
 };
 
@@ -7561,3 +7563,24 @@ if_exists_else_spec_function (int argc, 
 
   return argv[1];
 }
+
+/* replace-outfile built-in spec function.
+   This looks for the first agrument 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;
+}
+
Index: config/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.h,v
retrieving revision 1.81
diff -u -p -r1.81 darwin.h
--- config/darwin.h	3 Jun 2004 23:15:00 -0000	1.81
+++ config/darwin.h	14 Jun 2004 05:07:43 -0000
@@ -217,6 +217,7 @@ Boston, MA 02111-1307, USA.  */
    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 %*} \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]