Marc Waeckerlin wrote:
> Now I have a C++ compiler executable named "trace", which
> changes all classes by adding function trace to all member
> functions.
>
> If I compile with
> trace -I /path/to/fntrace -d-include -dfntrace.hxx \
> -- -o x x.cpp
> instead of
> g++ -o x x.cpp
>
> Then my classes in x.cpp print a very verbose function
> trace.
>
> Now I have created a huge project with GNU Autotools, so to
> build it, simply call:
> ./configure && make
>
> Question:
>
> Can I exchange the GNU g++ by my own "trace" without
> changing a single line in my project?
>
> Approach:
>
> The first approach is:
> CXX="trace -I <path> -d-include -dfntrace.hxx --" \
> ./configure && make
>
> But unfortunately configure fails because link options are
> not passed to the linker, i.e. The following does not work:
> trace <as-above> -- -o x x.cpp -liberty
>
> But I get the error message:
> [MetaclassRegistration...]
> EXECUTING g++ g++ -I <path> -include fntrace.hxx \
> -liberty -D__opencxx -E -o conftest.occ \
> -x c++ conftest.cc
> g++: -liberty: linker input file unused because \
> linking not done
> EXECUTING g++ g++ -o conftest -g -O2 conftest.ii
>
> -> Link errors, because the second, not the first call,
> must be with -liberty, but the second call is missing
> the link option. Why?
>
> Is this a bug or missing feature in OpenC++? I think so.
This is missing feature of Autoconf that does not recognize compilers
generated by OpenC++ :-)
Seriously, AFAIK OpenC++ was not designed with a goal of being a drop-in
replacement for any particular compiler.
However, one of goals of OpenC++Core project is to make OpenC++ more
modular, so that you can seamlesly reuse parts you need (lexer, parser,
analyzer, translator, metaobject protocol, driver), but replace the one
that does not suit you (command-line options interpretter).
You may also want to have a look at occ2 script, which duplicates
funcionality of driver and command-line line options interpretter in
Python. It should be easier to modify this script than C++ driver to
obtain drop-in replacement.
Yet another solution is to ./configure with genuine compiler, but later
use "make CXX='trace ...'".
> Other question:
> How do I split my homebrew enhanced compiler "trace" into
> the three common steps: Preprocessing, compiling, linking?
> I suppose, I only need my own compiler for preprocessing,
> i.e. to generate x.ii, then for compiling and linking, I
> can use the normal g++?
Right. Use '-E' command-line option to generated compiler. 'occ2' works
like this --- the generated compiler is used only for translation, all
other tasks are run from occ2 script using genuine preproc, genuing
compiler and genuine linker.
BR
Grzegorz
>
> Thank you
> Regards
> Marc
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
> Use IT products in your business? Tell us what you think of them. Give us
> Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
> http://productguide.itmanagersjournal.com/guidepromo.tmpl
> _______________________________________________
> Opencxx-users mailing list
> Ope...@li...
> https://lists.sourceforge.net/lists/listinfo/opencxx-users
|