[Top][All Lists]

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

Re: Complex compiler/linker tests

From: Liviu Nicoara
Subject: Re: Complex compiler/linker tests
Date: Wed, 29 Jun 2005 10:12:36 -0600
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050317)


One trivial example would be a test to detect whether or not a compiler collapses static locals in inline functions occurring in both library and user program. It would require a library and a program, e.g.:

// lib.cpp
inline int foo ()
    static int i = 0;
    return ++i;

int bar ()
    return foo ();

// prog.cpp
inline int foo ()
    static int i = 0;
    return ++i;

extern int bar ();

int main ()
    int i = foo();
    int j = bar ();
    return !(i != j);

The program returns 0 is the linker correctly collapses the two "static int i".

Anyhoo, I started already looking into autoconf internal macros (e.g. _AC_COMPILE_IFELSE) and it looks pretty straightforward if I take that as a model and don't make unrealistic assumptions about what goes where.

So, the functionality I am going to need would be:
1. macro to compile and link an arbitrary number of source files into a
   library or program
2. macro to compile arbitrary number of source files and link them with
   specified libraries

Any input is appreciated as to the usefulness of this set of macros, esp. from autoconf developers.

Thank you.


Ralf Wildenhues wrote:
Hi Liviu,

* Liviu Nicoara wrote on Tue, Jun 28, 2005 at 01:59:55AM CEST:

There are situations where a C++ comptest needs to have multiple translation units. These need to be compiled and the object files linked together, and posibbly, the resulting program needs to be run.

Could you describe an example where this is necessary?

I could not find a way of doing this in an easy way using the "public interface" of autoconf. Is it at all possible?

I'd say it's probably at least quite cumbersome.  Much of Autoconf
assumes only one source file, named `conftest.*'.  You'd either have to
munge unpublished internal variables or you'd have to give up quite a
bit of Autoconf functionality.

Would I need to roll my own macros for this?

Hmm, I'd say if it turns out to be useful to have such functionality,
then Autoconf should probably provide it.  Just my .02 cents, I'm not an
Autoconf developer.


reply via email to

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