public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* how to "parse" gcc -v output
@ 2010-04-04  7:06 Ralf Wildenhues
  2010-04-04  9:40 ` Joseph S. Myers
  0 siblings, 1 reply; 5+ messages in thread
From: Ralf Wildenhues @ 2010-04-04  7:06 UTC (permalink / raw)
  To: gcc, libtool

Hello gcc and libtool lists,

Both Autoconf and Libtool have macros which "parse" output of 'gcc -v'
for some link commands.  Yes, I know, almost by definition this is not
"parseable" text, but GCC does not provide a stable API that allows to
find out
- which libraries it needs to link shared modules against, or
- which libraries are needed to let g++ link mixed C++/Fortran code,
so in practice there is no other choice (unless the user provides this
information).

In some situations, esp. when -flto is used, -v output consists of many
parts.  Libtool needs to know which parts it can drop, or needs to look
at.  Can we be fairly confident that, iff there is a line matching
  '^ [^ ].*collect'

it will pick the one line that contains the verbose driver invocation
that lets us pick up init/fini objects as well as compiler libs to link
against?  I.e., can we assume the leading space to be stable, and the
'collect2' name to be fairly stable across GCC versions and systems?
It seems to work with all versions starting from 2.95 on those systems
where collect2 is used (the 2.7.2.3 I can still find here matches
'^ [^ ].*ld ').  If we don't find such a line, then picking the first
line with a single leading space seems prudent.  That would e.g. match
linking with ld on FreeBSD.

If not, can you suggest a different approach?  Should we be using -###
instead?  Looking for the first line with leading space and containing
' -L' (I think Alexandre Oliva suggested that a while ago)?

I'm willing to add API to a future GCC if that's the only viable way
(that way at least we have a fixed set of past and present versions to
match).

Thanks,
Ralf

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-04-05 12:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-04  7:06 how to "parse" gcc -v output Ralf Wildenhues
2010-04-04  9:40 ` Joseph S. Myers
2010-04-04 10:16   ` Ralf Wildenhues
2010-04-04 19:09     ` Joseph S. Myers
2010-04-05 12:23       ` Dave Korn

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).