This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: #import, #pragma once yadda yadda mumble grumble
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Neil Booth <neil at daikokuya dot co dot uk>
- Cc: gcc-patches at gcc dot gnu dot org, Mike Stump <mrs at apple dot com>, Nicola Pero <nicola at brainstorm dot co dot uk>, gcc at gcc dot gnu dot org, Stan Shebs <shebs at apple dot com>, Zack Weinberg <zack at codesourcery dot com>, David Ayers <d dot ayers at inode dot at>
- Date: 03 Aug 2003 16:00:00 -0700
- Subject: Re: #import, #pragma once yadda yadda mumble grumble
- References: <20030729222547.GF14334@daikokuya.co.uk><DE889F08-C219-11D7-BF45-0030657EA24A@apple.com><20030803123009.GC26598@daikokuya.co.uk>
Neil Booth <neil@daikokuya.co.uk> writes:
> Geoffrey Keating wrote:-
>
> > Hi Neil,
> >
> > This is great! I want to make some improvements to it, but it's a much
> > easier base to do that from than the previous code. Thank you!
>
> What improvements do you want to make? The only worthwhile change
> I can think of is improving #import efficiency; I intend to do
> something trivial but effective here soon.
There are three general categories of changes that I want to make:
- Use readdir() on each (top-level) directory in the include path.
This is a big speed win when you have many (like, 100) entries in
the include path. It's actually a win even if you only have the
default path, because the overhead of reading a large /usr/include
is balanced by not having to search /usr/local/include. An
important sub-feature is that it should notice that, for instance,
/usr/local/include/sys doesn't exist, and so "sys/types.h" can't be
there, *without* doing readdir recursively (which wasn't a speed win
for us).
- Generalise the concept of a search path entry, to include:
- Apple's "framework" concept, basically <Carbon/Carbon.h> goes in
/System/Frameworks/Carbon.framework/Headers/Carbon.h
(but with a bunch of other wrinkles).
- Ask some other program how to find an item, over a pipe or
something, for distcc-style compilations without having to
transport preprocessed source (this would make many people happy,
especially if you integrate it with PCH).
I thought the easiest way to do this is to just have some kind of
'search path entry' abstraction, with function pointers. It seems like
people often want to do weird target-specific things with header file
searching (especially Apple, but there's stuff for Windows OSs too).
- Make #import work with PCH. Despite rumors to the contrary, it still
doesn't; there's just no code to save or restore the required data. Apple
has an implementation (that I wrote) that uses MD5 checksums, which seems
to work well enough for us. The only annoying feature is that when you
create a PCH, even if you don't use #import, you must checksum every
header file, because the PCH might have
#include "foo.h"
and the main file might have
#import "foo.h"
and you need to know that you've seen it already. Of course, when
you use the PCH, you don't have to look at the checksums unless
someone has used #import, but you do have to have them available.
--
- Geoffrey Keating <geoffk@geoffk.org>