This is the mail archive of the gcc-help@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: GCC Behaves Differently for Different User?


On Tue, 2011-12-06 at 13:56 -0800, Ian Lance Taylor wrote:
> John Graham <johngavingraham@googlemail.com> writes:
> 
> > However, I think I've found the cause of the problem, even if I have
> > no idea why it would cause this - when the new user runs "export", no
> > PATH shows up. If I run "echo $PATH" it shows up as I'd expect, and
> > when I do "export PATH" suddenly gcc can #include <stddef.h> just
> > fine. There must be some subtlety I'm not aware of... I don't suppose
> > you could shed any light on what's going on here?
> 
> No, you've got me there.  I have no idea what is going on.  I would be
> interested to hear if you figure out why PATH matters.

The gcc front-end has processing to look through $PATH to find itself.
If it comes up with the wrong pathname then you get VERY odd results.  I
don't know if this is the problem here or not, but it seems plausible if
you don't have PATH exported (the shell would find gcc and invoke it,
but gcc won't have PATH set).

In our environment we've been bit by this as well, in a slightly
different way because there's a bug in this algorithm: it doesn't ignore
_directories_ named "gcc" (or whatever) that are on your $PATH; it only
checks for the execute bit.  When the shell looks up <program> in $PATH
it ignores directories named <program>.

So for example if you "mkdir $HOME/bin/gcc" and you have $HOME/bin on
your PATH before /usr/bin (where gcc lives) then gcc gets very confused.
I haven't checked more recent versions of gcc to see if this behavior
persists though; maybe it's fixed.


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