Topic: C++ pre-linker


Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: Tue, 8 Jan 2002 17:02:33 GMT
Raw View
remove.haberg@matematik.su.se (Hans Aberg) writes:

> My guess is that the C++ standard is in part dictated by the fact that
> often the linker is provided by the platform, and not the C++ compiler
> manufacturer.

That is not really the case. Many things in C++ cannot be done with
the "historical" linkers; and many linkers these days are aware of
C++.

> But has somebody thought of the approach that the C++ translation units
> provides a code for a C++ "pre-linker" with more information at hand, and
> which can do the global analysis before producing the code to the linker.

Several compilers use that approach. For example, g++ uses the
collect2 tool as the prelinker.

> For example, if this pre-linker has the capacity of computing the offsets
> of a template function when instantiated, then templates can be treated as
> ordinary functions.

Not sure what you are proposing. In what way could templates be
"ordinary functions"? In that they must not be defined at the point of
instantiation? You can do that by using the export keyword.

> If one such an approach might is feasible and could be required,
> then the C++ standard could be simplified in many points where it is
> not now possible.

This is the precise intention of the export keyword. It is not widely
implemented because of issues with the translation process, however, I
don't think it is necessary to extend C++ - just to get existing
compilers implement the standard in this respect.

Regards,
Martin

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: remove.haberg@matematik.su.se (Hans Aberg)
Date: Tue, 8 Jan 2002 20:08:42 GMT
Raw View
In article <j4bsg5rvjf.fsf@informatik.hu-berlin.de>, Martin von Loewis
<loewis@informatik.hu-berlin.de> wrote:
>> For example, if this pre-linker has the capacity of computing the offsets
>> of a template function when instantiated, then templates can be treated as
>> ordinary functions.
>
>Not sure what you are proposing. In what way could templates be
>"ordinary functions"? In that they must not be defined at the point of
>instantiation? You can do that by using the export keyword.

One just treats the template function as a closure and export the closure.
Then the pre-linker would know how to instantiate it, given the template
arguments.

  Hans Aberg      * Anti-spam: remove "remove." from email address.
                  * Email: Hans Aberg <remove.haberg@member.ams.org>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: remove.haberg@matematik.su.se (Hans Aberg)
Date: Mon, 7 Jan 2002 21:39:37 GMT
Raw View
My guess is that the C++ standard is in part dictated by the fact that
often the linker is provided by the platform, and not the C++ compiler
manufacturer. This makes it difficult do certain things, like for example
a global static analysis, as the information needed for that cannot be
exported to the linker, and the linker would not be able to understand it
anyway.

But has somebody thought of the approach that the C++ translation units
provides a code for a C++ "pre-linker" with more information at hand, and
which can do the global analysis before producing the code to the linker.

For example, if this pre-linker has the capacity of computing the offsets
of a template function when instantiated, then templates can be treated as
ordinary functions. (A DLL version might be that when requested, the
pre-linker knows how to dynamically expand and cache templates.)

If one such an approach might is feasible and could be required, then the
C++ standard could be simplified in many points where it is not now
possible.

The point of bringing this idea up at this point in time would be that C++
is such a complex language that it is in the need of every simplification
it can, plus the fact that compilers are becoming pretty fearsome in doing
static analysis optimizations:

So then one should introduce techniques that allows such optimization
techniques to develop as much as possible.

  Hans Aberg      * Anti-spam: remove "remove." from email address.
                  * Email: Hans Aberg <remove.haberg@member.ams.org>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]