public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jack Howarth <howarth@bromo.med.uc.edu>
To: gcc-patches@gcc.gnu.org
Cc: rth@redhat.com
Subject: Re: [PATCH][Revisedx2] Add remove-outfile and use on darwin
Date: Sun, 15 Aug 2010 20:46:00 -0000	[thread overview]
Message-ID: <20100815202942.GA8313@bromo.med.uc.edu> (raw)
In-Reply-To: <20100812130403.GA24186@bromo.med.uc.edu>

On Thu, Aug 12, 2010 at 09:04:03AM -0400, Jack Howarth wrote:
>    Currently on darwin, passing -ldl, -lm or -lpthread (which are
> all aliases for -lSystem) results in the libSystem being promoted
> earlier into the order of linkage. This interferes with the logic
> behind libgcc_ext which expects libSystem to be linked last. The
> attached patch adds the missing remove-outfile spec function and
> uses it from LINK_SPEC to remove any instances of -ldl, -lm or 
> Bootstrapped and regression tested on x86_64-apple-darwin10.
> Okay for gcc trunk and gcc 4.5.2?
>                 Jack
> 

Richard,
     We never got an explicit approval on this change (although the original
concept and implentation was entirely Andrew Pinksi's idea). It would be
very helpful to get this into gcc trunk and 4.5.2 so that there is coherency
to how libSystem is linked on darwin). Thanks in advance.
              Jack
ps I have corrected all of the documentation flaws in the second revision.


> 2010-08-12  Jack Howarth <howarth@bromo.med.uc.edu>
> 
> 	* gcc.c (spec_function): Add remove-outfile.
> 	(remove_outfile_spec_function): New function.
> 	* config/darwin.h (LINK_SPEC): Add removal of
> 	-ldl, -lm and -lpthread.
> 	* invoke.texi (replace-outfile): Document.
> 
> Index: gcc/doc/invoke.texi
> ===================================================================
> --- gcc/doc/invoke.texi	(revision 163182)
> +++ gcc/doc/invoke.texi	(working copy)
> @@ -9613,6 +9613,15 @@
>  %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
>  @end smallexample
>  
> +@item @code{remove-outfile}
> +The @code{remove-outfile} spec function takes one argument.  It removes
> +all occurrences of its argument from the outfiles array.  Here is a small
> +example of its usage:
> +
> +@smallexample
> +%:remove-outfile(-lm)
> +@end smallexample
> +
>  @item @code{print-asm-header}
>  The @code{print-asm-header} function takes no arguments and simply
>  prints a banner like:
> Index: gcc/gcc.c
> ===================================================================
> --- gcc/gcc.c	(revision 163182)
> +++ gcc/gcc.c	(working copy)
> @@ -379,6 +379,7 @@
>  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 **);
> +static const char *remove_outfile_spec_function (int, const char **);
>  static const char *version_compare_spec_function (int, const char **);
>  static const char *include_spec_function (int, const char **);
>  static const char *find_file_spec_function (int, const char **);
> @@ -1677,6 +1678,7 @@
>    { "if-exists",		if_exists_spec_function },
>    { "if-exists-else",		if_exists_else_spec_function },
>    { "replace-outfile",		replace_outfile_spec_function },
> +  { "remove-outfile",		remove_outfile_spec_function },
>    { "version-compare",		version_compare_spec_function },
>    { "include",			include_spec_function },
>    { "find-file",		find_file_spec_function },
> @@ -8357,6 +8359,27 @@
>    return NULL;
>  }
>  
> +/* remove-outfile built-in spec function.
> + *
> + *    This looks for the first argument in the outfiles array's name and
> + *       removes it.  */
> +
> +static const char *
> +remove_outfile_spec_function (int argc, const char **argv)
> +{
> +  int i;
> +  /* Must have exactly one argument.  */
> +  if (argc != 1)
> +    abort ();
> +
> +  for (i = 0; i < n_infiles; i++)
> +    {
> +      if (outfiles[i] && !strcmp (outfiles[i], argv[0]))
> +        outfiles[i] = NULL;
> +    }
> +  return NULL;
> +}
> +
>  /* Given two version numbers, compares the two numbers.
>     A version number must match the regular expression
>     ([1-9][0-9]*|0)(\.([1-9][0-9]*|0))*
> Index: gcc/config/darwin.h
> ===================================================================
> --- gcc/config/darwin.h	(revision 163182)
> +++ gcc/config/darwin.h	(working copy)
> @@ -303,6 +303,9 @@
>     so put a * after their names so all of them get passed.  */
>  #define LINK_SPEC  \
>    "%{static}%{!static:-dynamic} \
> +   %:remove-outfile(-ldl) \
> +   %:remove-outfile(-lm) \
> +   %:remove-outfile(-lpthread) \
>     %{fgnu-runtime: %{static|static-libgcc: \
>                       %:replace-outfile(-lobjc libobjc-gnu.a%s); \
>                      :%:replace-outfile(-lobjc -lobjc-gnu ) } }\

  reply	other threads:[~2010-08-15 20:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12 13:17 Jack Howarth
2010-08-15 20:46 ` Jack Howarth [this message]
2010-08-16 15:13   ` Richard Henderson
2010-08-17 13:31     ` IainS

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100815202942.GA8313@bromo.med.uc.edu \
    --to=howarth@bromo.med.uc.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).