[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to "parse" gcc -v output

From: Joseph S. Myers
Subject: Re: how to "parse" gcc -v output
Date: Sun, 4 Apr 2010 19:08:49 +0000 (UTC)

On Sun, 4 Apr 2010, Ralf Wildenhues wrote:

> How would g++ know that part of the objects were from Fortran sources?

By looking for undefined symbols matching patterns for symbols from 

> Maybe from a different (non-GCC) Fortran compiler, that needs a
> different set of libraries at link time?  I don't see how this

I don't see how querying GCC is ever going to help with this case.

> Also, in order to actually be able to run programs, libtool needs to
> also be able to ask for paths missing in the run paths, so they can be
> added to the program *if the user so desires* and if they are not in the
> default run path.

(That is not a case mentioned in your original message so was not covered 
by my previous reply.)

The interface -print-search-dirs already exists; you can use it along with 
the multilib options to the compiler to get the list of directories it 
searches for the selected multilib.  That's better than parsing the 
commands by which the compiler runs the linker.  Both will involve a long 
list of paths, most of which are not relevant and involve ../ parts you'll 
want to resolve before embedding.

Embedding runpaths seems like a case for an ld option or options to 
specify which directories (in which shared libraries are found) do or do 
not get paths embedded and how those paths are remapped if they are 

I think extracting compiler/linker *internal commands* and trying to 
process or adapt them is inherently fragile and liable to break whenever 
new compiler/linker options (internal or otherwise) are added.  If 
possible the aim should be to work out user-friendly interfaces for direct 
GCC users and have libtool use the same interfaces while expecting how 
they are implemented to change over time.  Interfaces by which GCC does 
things (e.g. link a shared library for the multilib implied by the given 
options) seem safer than interfaces where it gives information (if you ask 
it for directories and lists of libraries, you might then find that 
interface inadequate for handling per-library choice of static or shared 
libraries, for example).  Linking is a complicated iterative process that 
can involve collect2 rerunning the compiler, making it hard for the driver 
ever to give an answer about how something would be linked and be sure 
that it would still be valid when libtool makes some unspecified change to 
the link process (and if it isn't making such a change, it could just let 
the driver do the linking instead of asking it questions).

Joseph S. Myers

reply via email to

[Prev in Thread] Current Thread [Next in Thread]