This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -remap: Should we remap before / after simplification?
- To: Joern Rennecke <amylaar at cambridge dot redhat dot com>
- Subject: Re: -remap: Should we remap before / after simplification?
- From: "Zack Weinberg" <zackw at Stanford dot EDU>
- Date: Thu, 15 Mar 2001 17:31:34 -0800
- Cc: Alexandre Oliva <aoliva at redhat dot com>, Neil Booth <neil at daikokuya dot demon dot co dot uk>, gcc at gcc dot gnu dot org
- References: <or4rwv4eor.fsf@guarana.lsd.ic.unicamp.br> <200103160050.f2G0oko10775@phal.cambridge.redhat.com>
On Fri, Mar 16, 2001 at 12:50:46AM +0000, Joern Rennecke wrote:
> > IMHO, you should only simplify a pathname when you can prove the
> > simplified path and the original one get you the same file.
>
> Or if you can use the OS to make the simplification for you.
> I.e. get the current working directory, cd to the basename of the
> file, get the current directory for the simplified basename of the
> file (might want to check if it's really simpler...), and cd back
> to the original directory.
If you're lucky, getcwd(3) just reads every directory between you and
the root, and stats (on average) half the entries in each. If you're
unlucky it forks off a child process which execs /bin/pwd, which then
does the same directory walk. If you're really unlucky it execs
/bin/sh -c pwd.
I will not support any change which is a performance improvement on
Linux and a lose on just about every other system in existence. (Do
recent BSDs have getcwd(2)?)
Note I'm willing to consider doing readlink("/dev/fd/%d") on Linux if
we can find a way to not gunk up the code with #ifdefs, and if it is
measured to be a genuine performance win there; that won't hurt anyone
else.
zw