This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Pre Compiled Headers


On Feb 13, 2007, at 1:34 PM, Brendon Costa wrote:
Sorry for the long email

Complex questions are better long, as that allows for better answers, which should be more useful to you.


This was based on an idea from Mike in Nov 2006 when i needed to ensure that the FUNCTION_DECL nodes were not collected by the garbage collector while i was still using them. You mentioned that i could do the above to get the garbage collector to think that the nodes are still being used. I also assumed that it could be used for working around the PCH engine.

To be clear, I said:


Actually, no, it won't work, precompiled headers will fail to work because you'd need to modify the PCH writer to write your data, because you didn't mark your data structures with GTY and didn't use gc to allocate them.

back then. I did mean for you to take that as a direct statement that while you could defeat collection, it still would not work for pch.


I should just re-write my code to use the garbage collector to manage my data structures,

Yup.


though it is a big job

Your code will be cleaner after you fix it up.


Now i think i have resolved myself to the fact that if i want to support
PCH files, then I will need to modify my code to use the GTY markers and
GCC garbage collector.

Yup.


* Does GCC use the PCH feature to speed up compilation of its standard libraries?

libstdcxx is the only one that I know of that does.


* If so is there a simple way of disabling this at configure time etc?

From configure help:


  --enable-libstdcxx-pch  build pre-compiled libstdc++ headers
                          [default=$is_hosted]

* Is it possible to use the GTY(()) flags inside macros?

Only copy preexisting styles. You won't go wrong. In short, most things you can dream up, won't work. 5 of the most trivial and basic things work. In general, no, sorry.


#define DECLARE_ARRAY(DataTypeName, DataType) \
struct DataTypeName##ArrayStruct \
{ \

You can see vec.[ch] for an example that most closely matches this.


* Is it possible to explicitly free garbage collected memory if i know i
will not be needing it any more

Yes, ggc_free.[1]


1 - Some people think that all the savings you'd get from this aren't work the pain of doing it, if you have to track down any over zealous ggc_free calls.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]