public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Language-specific libraries and `gcc' driver
@ 2000-01-27  4:27 Richard Kenner
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Kenner @ 2000-01-27  4:27 UTC (permalink / raw)
  To: Theodore.Papadopoulo; +Cc: gcc

    The compiler currently always emits a gcc2_compiled. symbol in the .o
    file for gdb's use. I always wondered why this idea cannot be extended
    to add a new symbol (or modify this one, but gdb might not appreciate
    that) in such a way that gcc used in link mode can automatically
    detect which library to use.  The idea would be to always scan each .o
    .a or .so file to find this marker add the necessary libraries to the
    list of required librairies. This is what collect2 is doing anyhow so
    I think that this pass can be integrated in the current collect2. This
    new collect2 would then proceed as required by the langage specified
    in the .o (right now scanning for static constructors for c++ files).

I like this idea very much.

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

* Re: Language-specific libraries and `gcc' driver
  2000-04-21  7:15         ` Theodore Papadopoulo
@ 2000-04-22  9:16           ` Jamie Lokier
  0 siblings, 0 replies; 13+ messages in thread
From: Jamie Lokier @ 2000-04-22  9:16 UTC (permalink / raw)
  To: Theodore Papadopoulo; +Cc: Peter Gerwinski, gcc

Theodore Papadopoulo wrote:
> Mumit also suggested directly emitting the libraries names in the 
> object file instead of identifying the compiler. I must admit that I 
> have trouble estimating the advantages and drawbacks of such a choice.
> My preference would go towards marking the language but then collect2 
> has to be aware of all languages. In the other case, each frontend is 
> responsible for naming the libraries it uses and collect2 just adds 
> these lines to the linker parameters but there will remain problems 
> of compiler versions, library versions and orders ...
> 
> Yes that would mandate that collect2 is used for all ports (but I 
> also thought that collect2 was not used with i686-pc-linux-gnu and it 
> seems to be (well it is compiled (and I think called) at least)).

Eventually, the mechanism can be added to the GNU linker.  It was done
with .gnu.linkonce.* sections after all.  When that is done, collect2
does not need to run.

Emitting the library names has the advantage that the linker can just
use those -- it doesn't need to know about languages.  However, it
doesn't make much difference if the mapping from language to library is
specifed by GCC on the linker command line.

E.g., to avoid collect2, GCC must test at build time if it's build on a
system where the linker supports the language->library feature.  In that
case, GCC can invoke the linker with `-ifdef gcc2_java_language -lgcj -endif'
or some equivalent functionality.

It might be good to emit both library and language names, for diagnostic
and tracking purposes -- as well as compiler options that affect library
compatibility since we're here.

-- Jamie

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

* Re: Language-specific libraries and `gcc' driver
  2000-04-20 18:55       ` Peter Gerwinski
@ 2000-04-21  7:15         ` Theodore Papadopoulo
  2000-04-22  9:16           ` Jamie Lokier
  0 siblings, 1 reply; 13+ messages in thread
From: Theodore Papadopoulo @ 2000-04-21  7:15 UTC (permalink / raw)
  To: Peter Gerwinski; +Cc: gcc

peter@gerwinski.de said:
> Or, one can use the more elaborate automatism by Theodore Papadopoulo.
>  (But wouldn't that approach require `collect2' being run on all
> systems?) 

Well proposed... and had very few reactions (but positive) from Mumit 
Khan and Richard Kenner.

Two remarks were done:

- In some cases, gcc can already put a language identifier to help 
gdb. But very few ports use that.... So one track is to generalize 
this (which is slightly redundant with the symbol gcc_compiled (see 
ASM_IDENTIFY_LANGUAGE).

Mumit also suggested directly emitting the libraries names in the 
object file instead of identifying the compiler. I must admit that I 
have trouble estimating the advantages and drawbacks of such a choice.
My preference would go towards marking the language but then collect2 
has to be aware of all languages. In the other case, each frontend is 
responsible for naming the libraries it uses and collect2 just adds 
these lines to the linker parameters but there will remain problems 
of compiler versions, library versions and orders ...

Yes that would mandate that collect2 is used for all ports (but I 
also thought that collect2 was not used with i686-pc-linux-gnu and it 
seems to be (well it is compiled (and I think called) at least)).

> Anyone working towards this?

Well, I tried a little experimentation but have not gone very far because I 
did not had much free time recently and because I felt that this was 
not a priority.

If there is more interest, I can go further but definitely need some 
advice from more knoledgeable people than me (I know too little about 
binary file formats and their compatibility): what to put in the object
(language def or library list or ...), in what form (ident string seems
to be the simplest way but then a whole scanning pass has to be done in
collect2 as far as I can tell, symbol seems to be too restrictive in terms
of allowed character set).

	Theo.

--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
 --------------------------------------------------------------------


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

* Re: Language-specific libraries and `gcc' driver
  2000-01-21  4:44     ` Jamie Lokier
@ 2000-04-20 18:55       ` Peter Gerwinski
  2000-04-21  7:15         ` Theodore Papadopoulo
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Gerwinski @ 2000-04-20 18:55 UTC (permalink / raw)
  To: gcc

Hello,

Jamie Lokier wrote:
> Peter Gerwinski wrote:
> > Mike Stump wrote:
> > > It would be nice to add support to gcc to let it know about the
> > > runtime libraries.  One problem is gcc foo.o style compiling doesn't
> > > otherwise indicate which possible language was in use.  One could nm
> > > the file, and then make guesses, or just add in all the runtimes for
> > > all languages, but...
> > 
> > IMHO it would be acceptable if one had to specify libraries
> > explicitly when linking `.o' files, while libraries are added
> > automatically when the source languages are known.
> 
> Deducing the libraries from an `-x language' option might be ok too.
> Doesn't handle the case of multiple languages linked together though.

One could introduce another option to `gcc' with the meaning
"please link with the libraries for this and that language".

Or, one can use the more elaborate automatism by Theodore
Papadopoulo.  (But wouldn't that approach require `collect2'
being run on all systems?)

Anyone working towards this?

    Peter

-- 
http://home.pages.de/~Peter.Gerwinski/ - G-N-U GmbH: http://www.g-n-u.de
Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - gpc-19990118
GnuPG key fingerprint: 9E7C 0FC4 8A62 5536 1730 A932 9834 65DB 2143 9422
keys: ftp://ftp.gerwinski.de/pub/keys/ - AntiSpam: http://spam.abuse.net

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

* Re: Language-specific libraries and `gcc' driver
  2000-01-20 12:05 Mike Stump
  2000-01-20 13:00 ` Theodore Papadopoulo
@ 2000-01-21 10:15 ` Tom Tromey
  1 sibling, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2000-01-21 10:15 UTC (permalink / raw)
  To: gcc

>>>>> "Mike" == Mike Stump <mrs@windriver.com> writes:

Mike> It would be nice to add support to gcc to let it know about the
Mike> runtime libraries.  One problem is gcc foo.o style compiling
Mike> doesn't otherwise indicate which possible language was in use.
Mike> One could nm the file, and then make guesses, or just add in all
Mike> the runtimes for all languages, but...

It's worse than you think.  The main Java runtime library (libgcj)
depends on several other libraries, but we don't know which one until
libgcj itself has been configured.

Currently we solve this by creating a spec file when we build libgcj,
and then we have gcj read this spec file when appropriate.

Tom

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

* Re: Language-specific libraries and `gcc' driver
  2000-01-21  3:52   ` Peter Gerwinski
@ 2000-01-21  4:44     ` Jamie Lokier
  2000-04-20 18:55       ` Peter Gerwinski
  0 siblings, 1 reply; 13+ messages in thread
From: Jamie Lokier @ 2000-01-21  4:44 UTC (permalink / raw)
  To: Peter Gerwinski; +Cc: gcc

Peter Gerwinski wrote:
> Mike Stump wrote:
> > It would be nice to add support to gcc to let it know about the
> > runtime libraries.  One problem is gcc foo.o style compiling doesn't
> > otherwise indicate which possible language was in use.  One could nm
> > the file, and then make guesses, or just add in all the runtimes for
> > all languages, but...
> 
> IMHO it would be acceptable if one had to specify libraries
> explicitly when linking `.o' files, while libraries are added
> automatically when the source languages are known.

Deducing the libraries from an `-x language' option might be ok too.
Doesn't handle the case of multiple languages linked together though.

-- Jamie

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

* Re: Language-specific libraries and `gcc' driver
  2000-01-20 10:13 ` Richard Henderson
@ 2000-01-21  3:52   ` Peter Gerwinski
  2000-01-21  4:44     ` Jamie Lokier
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Gerwinski @ 2000-01-21  3:52 UTC (permalink / raw)
  To: gcc

Richard Henderson wrote:
> On Thu, Jan 20, 2000 at 06:01:07PM +0100, Peter Gerwinski wrote:
> > How can I tell the driver about my language-specific libraries?
> 
> Examine either cp/g++spec.c or f/g77spec.c.  Both add libraries
> to the link line.

I now copied this method (by modifying f/g77spec.c) for GPC, but
I still think that a somewhat simpler method would be desirable.

Mike Stump wrote:
> It would be nice to add support to gcc to let it know about the
> runtime libraries.  One problem is gcc foo.o style compiling doesn't
> otherwise indicate which possible language was in use.  One could nm
> the file, and then make guesses, or just add in all the runtimes for
> all languages, but...

IMHO it would be acceptable if one had to specify libraries
explicitly when linking `.o' files, while libraries are added
automatically when the source languages are known.  Of course,
a more elaborate solution (as suggested in this thread) would
be much nicer ...

Thanks,

    Peter

-- 
http://home.pages.de/~Peter.Gerwinski/ - G-N-U GmbH: http://www.g-n-u.de
Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - gpc-19990118
GnuPG key fingerprint: 9E7C 0FC4 8A62 5536 1730 A932 9834 65DB 2143 9422
keys: ftp://ftp.gerwinski.de/pub/keys/ - AntiSpam: http://spam.abuse.net

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

* Re: Language-specific libraries and `gcc' driver
  2000-01-20 13:00 ` Theodore Papadopoulo
@ 2000-01-20 20:47   ` Mumit Khan
  0 siblings, 0 replies; 13+ messages in thread
From: Mumit Khan @ 2000-01-20 20:47 UTC (permalink / raw)
  To: Theodore Papadopoulo; +Cc: Mike Stump, gcc, peter

On Thu, 20 Jan 2000, Theodore Papadopoulo wrote:

> The compiler currently always emits a gcc2_compiled. symbol in the .o 
> file for gdb's use. I always wondered why this idea cannot be extended
> to add a new symbol (or modify this one, but gdb might not appreciate 
> that) in such a way that gcc used in link mode can automatically detect
> which library to use.

I actually played with this idea a while ago for the x86-win32 ports --
emit the needed libraries and some linker flags in .drectve section,
and then ld would read it and hopefully do the right thing. Never 
finished it however, but it's quite doable. Whether it's desirable or 
not is a different question. FYI, this is how MSVC manages the humongous 
mess of different libraries, thanks to the split universe with all the 
combinations of debug/non-debug/dll/static libraries, on windows boxes.

Collect2 also implements something similar, albeit for different purpose,
in the .rpo files.

Regards,
Mumit


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

* Re: Language-specific libraries and `gcc' driver
  2000-01-20 12:05 Mike Stump
@ 2000-01-20 13:00 ` Theodore Papadopoulo
  2000-01-20 20:47   ` Mumit Khan
  2000-01-21 10:15 ` Tom Tromey
  1 sibling, 1 reply; 13+ messages in thread
From: Theodore Papadopoulo @ 2000-01-20 13:00 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc, peter

mrs@windriver.com said:
> It would be nice to add support to gcc to let it know about the
> runtime libraries.  One problem is gcc foo.o style compiling doesn't
> otherwise indicate which possible language was in use.  One could nm
> the file, and then make guesses, or just add in all the runtimes for
> all languages, but...

I always wondered why the following approach cannot be used:

The compiler currently always emits a gcc2_compiled. symbol in the .o 
file for gdb's use. I always wondered why this idea cannot be extended
to add a new symbol (or modify this one, but gdb might not appreciate 
that) in such a way that gcc used in link mode can automatically detect
which library to use.
The idea would be to always scan each .o .a or .so file to find this marker
add the necessary libraries to the list of required librairies. This 
is what collect2 is doing anyhow so I think that this pass 
can be integrated in the current collect2. This new collect2 would 
then proceed as required by the langage specified in the .o
(right now scanning for static constructors for c++ files).

If you are mixing g++ and g77 code then you always have to 
specify at least one gcc library by hand. If the above is not totally 
bogus, it should allow to link objects generated by different 
frontends with any of the gcc/g77/g++/gcj drivers....
The only tricky thing would be where to find the library specs for the 
specific langages...

	Is all this sensible ???


	Theo.


--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
 --------------------------------------------------------------------


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

* Re: Language-specific libraries and `gcc' driver
@ 2000-01-20 12:05 Mike Stump
  2000-01-20 13:00 ` Theodore Papadopoulo
  2000-01-21 10:15 ` Tom Tromey
  0 siblings, 2 replies; 13+ messages in thread
From: Mike Stump @ 2000-01-20 12:05 UTC (permalink / raw)
  To: gcc, peter

> Date: Thu, 20 Jan 2000 18:01:07 +0100
> From: Peter Gerwinski <peter@gerwinski.de>
> To: gcc@gcc.gnu.org

> when implementing a frontend to GCC, I place the specs for the
> compiler in the `lang-specs.h' file, so the `gcc' driver program
> knows how to compile source files for my language.

> However, `gcc' does not know about the language-specific run
> time library but only links against libc (and perhaps libgcc).

> How can I tell the driver about my language-specific libraries?

Currently, there isn't a good way.  :-(

It would be nice to add support to gcc to let it know about the
runtime libraries.  One problem is gcc foo.o style compiling doesn't
otherwise indicate which possible language was in use.  One could nm
the file, and then make guesses, or just add in all the runtimes for
all languages, but...

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

* Re: Language-specific libraries and `gcc' driver
  2000-01-20  9:01 Peter Gerwinski
  2000-01-20 10:13 ` Richard Henderson
@ 2000-01-20 10:14 ` Joe Buck
  1 sibling, 0 replies; 13+ messages in thread
From: Joe Buck @ 2000-01-20 10:14 UTC (permalink / raw)
  To: Peter Gerwinski; +Cc: gcc

> Hello,
> 
> when implementing a frontend to GCC, I place the specs for the
> compiler in the `lang-specs.h' file, so the `gcc' driver program
> knows how to compile source files for my language.
> 
> However, `gcc' does not know about the language-specific run
> time library but only links against libc (and perhaps libgcc).
> 
> How can I tell the driver about my language-specific libraries?

We have the same issue with C++ and Fortran: if you link by specifying
gcc, the language-specific libraries won't be included by default.
The solution is to provide separate driver programs, named g++ and
g77, that in essence invoke gcc with additional flags to cause the
libraries to be included.

I think that Pascal should work the same way.


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

* Re: Language-specific libraries and `gcc' driver
  2000-01-20  9:01 Peter Gerwinski
@ 2000-01-20 10:13 ` Richard Henderson
  2000-01-21  3:52   ` Peter Gerwinski
  2000-01-20 10:14 ` Joe Buck
  1 sibling, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2000-01-20 10:13 UTC (permalink / raw)
  To: Peter Gerwinski; +Cc: gcc

On Thu, Jan 20, 2000 at 06:01:07PM +0100, Peter Gerwinski wrote:
> How can I tell the driver about my language-specific libraries?

Examine either cp/g++spec.c or f/g77spec.c.  Both add libraries
to the link line.


r~

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

* Language-specific libraries and `gcc' driver
@ 2000-01-20  9:01 Peter Gerwinski
  2000-01-20 10:13 ` Richard Henderson
  2000-01-20 10:14 ` Joe Buck
  0 siblings, 2 replies; 13+ messages in thread
From: Peter Gerwinski @ 2000-01-20  9:01 UTC (permalink / raw)
  To: gcc

Hello,

when implementing a frontend to GCC, I place the specs for the
compiler in the `lang-specs.h' file, so the `gcc' driver program
knows how to compile source files for my language.

However, `gcc' does not know about the language-specific run
time library but only links against libc (and perhaps libgcc).

How can I tell the driver about my language-specific libraries?

Thanks for your help,

    Peter

-- 
http://home.pages.de/~Peter.Gerwinski/ - G-N-U GmbH: http://www.g-n-u.de
Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - gpc-19990118
GnuPG key fingerprint: 9E7C 0FC4 8A62 5536 1730 A932 9834 65DB 2143 9422
keys: ftp://ftp.gerwinski.de/pub/keys/ - AntiSpam: http://spam.abuse.net

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

end of thread, other threads:[~2000-04-22  9:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-27  4:27 Language-specific libraries and `gcc' driver Richard Kenner
  -- strict thread matches above, loose matches on Subject: below --
2000-01-20 12:05 Mike Stump
2000-01-20 13:00 ` Theodore Papadopoulo
2000-01-20 20:47   ` Mumit Khan
2000-01-21 10:15 ` Tom Tromey
2000-01-20  9:01 Peter Gerwinski
2000-01-20 10:13 ` Richard Henderson
2000-01-21  3:52   ` Peter Gerwinski
2000-01-21  4:44     ` Jamie Lokier
2000-04-20 18:55       ` Peter Gerwinski
2000-04-21  7:15         ` Theodore Papadopoulo
2000-04-22  9:16           ` Jamie Lokier
2000-01-20 10:14 ` Joe Buck

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