Bug 12829 - include search bug -- gid related
Summary: include search bug -- gid related
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 3.2.3
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-29 18:08 UTC by Ed Hynan
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i486-slackware-linux
Target: i486-slackware-linux
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Hynan 2003-10-29 18:08:36 UTC
Slackware 9.1, stock gcc installation.

Odd problem with include search path, -iprefix, when in
supplementary group via sg -- discovered compiling Linux
kernel, but reproduced with simple example.

<example>
% uname -a
Linux stella 2.4.22 #6 Tue Sep 2 17:43:01 PDT 2003 i586 unknown unknown GNU/Linux

% gcc -v
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared
--enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld
--verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.2.3

% cat t.c
#include <stdarg.h>
int main() { return 0; }

% id
uid=502(evh) gid=502(evh)
groups=502(evh),14(uucp),100(users),66(www),230(pppusers),233(postgres),666(cvsuser)

% gcc -v -I/usr/include -nostdinc -iwithprefix include -o t t.c
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared
--enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld
--verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.2.3
 /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/cc1 -lang-c -nostdinc -v
-I/usr/include -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3
-D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__
-D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix
-D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386
-D__i386__ -D__tune_i486__ -iwithprefix include t.c -quiet -dumpbase t.c
-version -o /tmp/ccRol6I2.s
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
GNU C version 3.2.3 (i486-slackware-linux)
	compiled by GNU C version 3.2.3.
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/include
End of search list.
 /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../../i486-slackware-linux/bin/as -V -Qy -o /tmp/ccSBOi6Z.o /tmp/ccRol6I2.s
GNU assembler version 2.14.90.0.6 (i486-slackware-linux) using BFD version
2.14.90.0.6 20030820
 /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 -o t
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crt1.o
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crti.o
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/crtbegin.o
-L/usr/lib/gcc-lib/i486-slackware-linux/3.2.3
-L/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../../i486-slackware-linux/lib
-L/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../.. /tmp/ccSBOi6Z.o -lgcc
-lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/crtend.o
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/../../../crtn.o

% echo $?
0

% sg users
% id
uid=502(evh) gid=100(users)
groups=502(evh),14(uucp),100(users),66(www),230(pppusers),233(postgres),666(cvsuser)

% gcc -v -I/usr/include -nostdinc -iwithprefix include -o t t.c
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr --enable-shared
--enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld
--verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.2.3
 /usr/lib/gcc-lib/i486-slackware-linux/3.2.3/cc1 -lang-c -nostdinc -v
-I/usr/include -iprefix ../lib/gcc-lib/i486-slackware-linux/3.2.3/ -D__GNUC__=3
-D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__
-Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__
-D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386
-Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i486__ -iwithprefix include
t.c -quiet -dumpbase t.c -version -o /tmp/cci76Ylh.s
ignoring nonexistent directory "../lib/gcc-lib/i486-slackware-linux/3.2.3/include"
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
GNU C version 3.2.3 (i486-slackware-linux)
        compiled by GNU C version 3.2.3.
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
End of search list.
t.c:1:20: stdarg.h: No such file or directory

% echo $?
1

</example>

Note the difference in the cc1 command line.  The command
under the sg shell has:
	-iprefix ../lib/gcc-lib/i486-slackware-linux/3.2.3/
The relative directory is clearly a problem, and apparently
the presence of -iprefix is a bug.  There was no -iprefix
in the command line generated with the default gid.

Why should {r,e}gid affect this aspect of gcc operation
in any way?  (I have no problems in the ownership/group
and permissions in the working directory or in the gcc
installation.)

- Ed Hynan
Comment 1 Andrew Pinski 2003-10-30 04:45:10 UTC
Can you try with 3.3.2, as 3.2.x is no longer being updated?
Comment 2 Ed Hynan 2003-10-30 20:18:46 UTC
Andrew,

> Can you try with 3.3.2, as 3.2.x is no longer being updated?

OK, done.  Same thing with 3.3.2.

<example>

% sg users
% PATH=/usr/local/gcc/gcc-3.3.2/bin; hash -r
% which gcc
/usr/local/gcc/gcc-3.3.2/bin/gcc

% id
uid=502(evh) gid=100(users) [...]

% gcc -v -I/usr/include -nostdinc -iwithprefix include -o t t.c
Reading specs from
/usr/local/gcc/gcc-3.3.2/lib/gcc-lib/i586-pc-linux-gnu/3.3.2/specs
Configured with:
/mnt/hde2/src-storage/gcc-3.3.2/build.local/../gcc-3.3.2/configure
--prefix=/usr/local/gcc/gcc-3.3.2 --enable-shared --with-gnu-as --with-gnu-ld
--with-system-zlib --enable-threads=posix --with-cpu=k6-3
Thread model: posix
gcc version 3.3.2
 /usr/local/gcc/gcc-3.3.2/lib/gcc-lib/i586-pc-linux-gnu/3.3.2/cc1 -quiet
-nostdinc -v -I/usr/include -iprefix ../lib/gcc-lib/i586-pc-linux-gnu/3.3.2/
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 -iwithprefix include t.c
-quiet -dumpbase t.c -auxbase t -version -o /tmp/cc18hkQY.s
ignoring nonexistent directory "../lib/gcc-lib/i586-pc-linux-gnu/3.3.2/include"
GNU C version 3.3.2 (i586-pc-linux-gnu)
        compiled by GNU C version 3.3.2.
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32053
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
End of search list.
t.c:1:20: stdarg.h: No such file or directory

% echo $?
1

</example>
Comment 3 Andrew Pinski 2003-12-01 00:44:28 UTC
The problem is not in the preprocessor at all, the problem is that installation of the header has the 
wrong file ownership so this is a dup of bug 8121.

*** This bug has been marked as a duplicate of 8121 ***
Comment 4 Ed Hynan 2003-12-01 13:34:25 UTC
(In reply to comment #3)
> The problem is not in the preprocessor at all, the problem is that
installation of the header has the 
> wrong file ownership so this is a dup of bug 8121.
> 
> *** This bug has been marked as a duplicate of 8121 ***

No, it's not a duplicate of 8121.  It exist even with correct, consistent
ownership thoughout an installation.
Comment 5 Andrew Pinski 2003-12-01 15:41:48 UTC
Okay maybe this is not a dup but can you show what "ls -l" show on the stdarg.h header file?
Comment 6 Ed Hynan 2003-12-01 17:15:04 UTC
(In reply to comment #5)
> Okay maybe this is not a dup but can you show what "ls -l" show on the
stdarg.h header file?

Well, my gcc 3.3.2 installation did have the bug 8121 problem, i.e.
the fixed includes had had the owner and group of the account I
compiled in.  So, I chowned the whole installation root:root and
checked again, and this bug (12829) is still present.  Furthermore,
I first noticed the bug with the Slackware stock gcc 3.2.3, and
that had no ownership/group problems at all.

To answer your question, for the 3.3.2 installation:

% find /usr/local/gcc -name stdarg.h -ls 
540403    8 -rw-r--r--   1 root     root         4325 Oct 30 10:13
/usr/local/gcc/gcc-3.3.2/lib/gcc-lib/i586-pc-linux-gnu/3.3.2/include/stdarg.h
752285    8 -rw-r--r--   1 root     root         4325 Oct 30 14:44
/usr/local/gcc/gcc-3.3.2/lib/gcc-lib/i586-pc-linux-gnu/3.3.2/install-tools/include/stdarg.h

and for the Slackware gcc 3.2.3:

%find /usr/lib/gcc-lib -name stdarg.h -ls 
544491    8 -rw-r--r--   1 root     root         4481 Aug 28 20:26
/usr/lib/gcc-lib/i486-slackware-linux/3.2.3/include/stdarg.h

Comment 7 Andrew Pinski 2003-12-09 07:05:14 UTC
I cannot reproduce it on 3.2.3 or the mainline.

3.2.3:
tin:~/src/gnu/gcctest>~/ia32_linux_gcc3_2/bin/gcc -v -I/usr/include -nostdinc -iwithprefix 
include -o t t.c
Reading specs from /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-
gnu/3.2.3/specs
Configured with: ../configure --enable-__cxa_atexit --prefix=/home/gates/pinskia/
ia32_linux_gcc3_2 --enable-threads=posix --enable-shared
Thread model: posix
gcc version 3.2.3
 /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/cc1 -lang-c -
nostdinc -v -I/usr/include -D__GNUC__=3 -D__GNUC_MINOR__=2 -
D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -
D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -
D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -
Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -
D__tune_pentiumpro__ -iwithprefix include t.c -quiet -dumpbase t.c -version -o /tmp/
ccSzneFs.s
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
GNU C version 3.2.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4 20030528 (experimental).
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/include
End of search list.
 as -V -Qy -o /tmp/ccecdexN.o /tmp/ccSzneFs.s
GNU assembler version 2.14.90 (i686-pc-linux-gnu) using BFD version 2.14.90 
20031208
 /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/collect2 -m 
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o t /usr/lib/crt1.o /usr/lib/crti.o /home/gates/
pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/crtbegin.o -L/home/gates/
pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3 -L/home/gates/pinskia/
ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../.. /tmp/ccecdexN.o -lgcc -
lgcc_eh -lc -lgcc -lgcc_eh /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-
linux-gnu/3.2.3/crtend.o /usr/lib/crtn.o
tin:~/src/gnu/gcctest>sg developer
tin:~/src/gnu/gcctest>~/ia32_linux_gcc3_2/bin/gcc -v -I/usr/include -nostdinc -iwithprefix 
include -o t t.c
Reading specs from /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-
gnu/3.2.3/specs
Configured with: ../configure --enable-__cxa_atexit --prefix=/home/gates/pinskia/
ia32_linux_gcc3_2 --enable-threads=posix --enable-shared
Thread model: posix
gcc version 3.2.3
 /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/cc1 -lang-c -
nostdinc -v -I/usr/include -D__GNUC__=3 -D__GNUC_MINOR__=2 -
D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -
D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -
D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -
Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -
D__tune_pentiumpro__ -iwithprefix include t.c -quiet -dumpbase t.c -version -o /tmp/
ccId9HtK.s
GNU CPP version 3.2.3 (cpplib) (i386 Linux/ELF)
GNU C version 3.2.3 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4 20030528 (experimental).
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/include
End of search list.
 as -V -Qy -o /tmp/cccfyBHj.o /tmp/ccId9HtK.s
GNU assembler version 2.14.90 (i686-pc-linux-gnu) using BFD version 2.14.90 
20031208
 /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/collect2 -m 
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o t /usr/lib/crt1.o /usr/lib/crti.o /home/gates/
pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/crtbegin.o -L/home/gates/
pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3 -L/home/gates/pinskia/
ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../.. /tmp/cccfyBHj.o -lgcc -lgcc_eh 
-lc -lgcc -lgcc_eh /home/gates/pinskia/ia32_linux_gcc3_2/lib/gcc-lib/i686-pc-linux-gnu/
3.2.3/crtend.o /usr/lib/crtn.o

the mainline:
tin:~/src/gnu/gcctest>cat t.c

#include <stdarg.h>
int main() { return 0; }
tin:~/src/gnu/gcctest>id
uid=1061(pinskia) gid=150(tension) groups=150(tension),600(cdwrite),700(developer)
tin:~/src/gnu/gcctest>gcc -v -I/usr/include -nostdinc -iwithprefix include -o t t.c
Reading specs from /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/specs
Configured with: /home/gates/pinskia/src/gnu/gcc/src/configure --target=i686-pc-linux-
gnu --host=i686-pc-linux-gnu --enable-__cxa_atexit --enable-languages=java,objc,f77 --
prefix=/home/gates/pinskia/linux --enable-threads=posix --enable-shared
Thread model: posix
gcc version 3.4 20031125 (experimental)
 /home/gates/pinskia/linux/libexec/gcc/i686-pc-linux-gnu/3.4/cc1 -quiet -nostdinc -v -I/usr/
include -iwithprefix include t.c -quiet -dumpbase t.c -mtune=pentiumpro -auxbase t -
version -o /tmp/ccyeX8Cd.s
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/include
End of search list.
GNU C version 3.4 20031125 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.4 20031125 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../../../i686-pc-linux-gnu/bin/as -
V -Qy -o /tmp/ccq6hmZl.o /tmp/ccyeX8Cd.s
GNU assembler version 2.14.90 (i686-pc-linux-gnu) using BFD version 2.14.90 
20031208
 /home/gates/pinskia/linux/libexec/gcc/i686-pc-linux-gnu/3.4/collect2 --eh-frame-hdr -m 
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o t /usr/lib/crt1.o /usr/lib/crti.o /home/gates/
pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/crtbegin.o -L/home/gates/pinskia/linux/lib/gcc/
i686-pc-linux-gnu/3.4 -L/home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../../../
i686-pc-linux-gnu/lib -L/home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../.. /tmp/
ccq6hmZl.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /home/gates/pinskia/linux/lib/gcc/i686-pc-
linux-gnu/3.4/crtend.o /usr/lib/crtn.o
tin:~/src/gnu/gcctest>sg developer
tin:~/src/gnu/gcctest>gcc -v -I/usr/include -nostdinc -iwithprefix include -o t t.c
Reading specs from /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/specs
Configured with: /home/gates/pinskia/src/gnu/gcc/src/configure --target=i686-pc-linux-
gnu --host=i686-pc-linux-gnu --enable-__cxa_atexit --enable-languages=java,objc,f77 --
prefix=/home/gates/pinskia/linux --enable-threads=posix --enable-shared
Thread model: posix
gcc version 3.4 20031125 (experimental)
 /home/gates/pinskia/linux/libexec/gcc/i686-pc-linux-gnu/3.4/cc1 -quiet -nostdinc -v -I/usr/
include -iwithprefix include t.c -quiet -dumpbase t.c -mtune=pentiumpro -auxbase t -
version -o /tmp/ccbFfWgH.s
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/include
End of search list.
GNU C version 3.4 20031125 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.4 20031125 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../../../i686-pc-linux-gnu/bin/as -
V -Qy -o /tmp/ccCRkO8g.o /tmp/ccbFfWgH.s
GNU assembler version 2.14.90 (i686-pc-linux-gnu) using BFD version 2.14.90 
20031208
 /home/gates/pinskia/linux/libexec/gcc/i686-pc-linux-gnu/3.4/collect2 --eh-frame-hdr -m 
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o t /usr/lib/crt1.o /usr/lib/crti.o /home/gates/
pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/crtbegin.o -L/home/gates/pinskia/linux/lib/gcc/
i686-pc-linux-gnu/3.4 -L/home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../../../
i686-pc-linux-gnu/lib -L/home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../.. /tmp/
ccCRkO8g.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /home/gates/pinskia/linux/lib/gcc/i686-pc-
linux-gnu/3.4/crtend.o /usr/lib/crtn.o
Comment 8 Andrew Pinski 2003-12-09 07:14:53 UTC
What version of glibc do you have?

I have:
tin:~/src/gnu/gcctest>/lib/libc.so.6
GNU C Library stable release version 2.2.5, by Roland McGrath et al.
Copyright (C) 1992-2001, 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 2.96 20000731 (Red Hat Linux 7.2 2.96-109).
Compiled on a Linux 2.4.9-9 system on 2002-03-27.
Available extensions:
        GNU libio by Per Bothner
        crypt add-on version 2.1 by Michael Glad and others
        The C stubs add-on version 2.1.2.
        linuxthreads-0.9 by Xavier Leroy
        BIND-8.2.3-T5B
        NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
        Glibc-2.0 compatibility add-on by Cristian Gafton 
        libthread_db work sponsored by Alpha Processor Inc
Report bugs using the `glibcbug' script to <bugs@gnu.org>.
Comment 9 Ed Hynan 2003-12-09 13:03:21 UTC
(In reply to comment #7)
> I cannot reproduce it on 3.2.3 or the mainline.

Sh*t.  I just found that my sg command removes a few environment
variables: $HOME, $MAIL, $OLDPWD, $PATH.  (BTW, this is not documented
in my sg manpage.)  So, the shell uses the default PATH for its searches,
but its children don't inherit PATH in their environment.  Apparently gcc
wants to use $PATH, and without it will generate a cc1 command with
`-iprefix ../[whatever]'.  The relative path argument to -iprefix is a
bad guess, but this is clearly _not_ an egid problem as I had thought.
Sorry I didn't spot this before, but I never would have guessed that sg
would remove PATH.

If you couldn't reproduce this, maybe your sg behaves differently.  If
you're still interested in this (doubtful), try
% sg whatever -c printenv | egrep '\<PATH\>'
and if you _do_ have PATH, than try again with PATH unset.  It might not
be worth your time now, but I am curious.  The question remains why gcc
would generate the bad cc1 command if PATH is unset.
Comment 10 Ed Hynan 2003-12-09 13:51:59 UTC
[replying to my own message ...]

(In reply to comment #9)
> [...]  Apparently gcc
> wants to use $PATH, and without it will generate a cc1 command with
> `-iprefix ../[whatever]'.  The relative path argument to -iprefix is a
> bad guess, but this is clearly _not_ an egid problem as I had thought.

Additional note: if gcc finds a useful path in argv[0], it will use that,
and the bug will not be manifest.  Unsetting PATH to see the bug probably
won't work, because then it will be necessary to invoke gcc from a full
path.  A workaround is to ln -s /path/to/gcc . and then invoke ./gcc (with
PATH unset).
Comment 11 Andrew Pinski 2003-12-09 16:14:56 UTC
unsetting PATH env still works on the mainline:
tin:~/src/gnu/gcctest>./gcc -v -I/usr/include -nostdinc -iwithprefix include -o t t.c
Reading specs from /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/specs
Configured with: /home/gates/pinskia/src/gnu/gcc/src/configure --target=i686-pc-linux-gnu --
host=i686-pc-linux-gnu --enable-__cxa_atexit --enable-languages=java,objc,f77 --prefix=/
home/gates/pinskia/linux --enable-threads=posix --enable-shared
Thread model: posix
gcc version 3.4 20031209 (experimental)
 /home/gates/pinskia/linux/libexec/gcc/i686-pc-linux-gnu/3.4/cc1 -quiet -nostdinc -v -I/usr/
include -iwithprefix include t.c -quiet -dumpbase t.c -mtune=pentiumpro -auxbase t -version -o 
/tmp/cc3IRkaI.s
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/include
End of search list.
GNU C version 3.4 20031209 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 3.4 20031209 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 /home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../../../i686-pc-linux-gnu/bin/as 
-V -Qy -o /tmp/ccPOfazD.o /tmp/cc3IRkaI.s
GNU assembler version 2.14.90 (i686-pc-linux-gnu) using BFD version 2.14.90 20031208
 /home/gates/pinskia/linux/libexec/gcc/i686-pc-linux-gnu/3.4/collect2 --eh-frame-hdr -m 
elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o t /usr/lib/crt1.o /usr/lib/crti.o /home/gates/
pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/crtbegin.o -L/home/gates/pinskia/linux/lib/gcc/
i686-pc-linux-gnu/3.4 -L/home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../../../
i686-pc-linux-gnu/lib -L/home/gates/pinskia/linux/lib/gcc/i686-pc-linux-gnu/3.4/../../.. /
tmp/ccPOfazD.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /home/gates/pinskia/linux/lib/gcc/i686-pc-
linux-gnu/3.4/crtend.o /usr/lib/crtn.o
tin:~/src/gnu/gcctest>echo $PATH
PATH: Undefined variable.

But I can reproduce this in 3.3.1, so it was fixed for 3.4:
tin:~/src/gnu/gcctest>./gcc -v -I/usr/include -nostdinc -iwithprefix include -o t t.c
Reading specs from /home/gates/pinskia/ia32_linux_gcc3_3/lib/gcc-lib/i686-pc-linux-gnu/
3.3.1/specs
Configured with: ../configure --enable-__cxa_atexit --prefix=/home/gates/pinskia/
ia32_linux_gcc3_3 --enable-threads=posix --enable-shared
Thread model: posix
gcc version 3.3.1 20030707 (prerelease)
 /home/gates/pinskia/ia32_linux_gcc3_3/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/cc1 -quiet 
-nostdinc -v -I/usr/include -iprefix ./../lib/gcc-lib/i686-pc-linux-gnu/3.3.1/ -D__GNUC__=3 
-D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=1 -iwithprefix include t.c -quiet -dumpbase t.c 
-auxbase t -version -o /tmp/ccfkPnXy.s
ignoring nonexistent directory "../lib/gcc-lib/i686-pc-linux-gnu/3.3.1/include"
GNU C version 3.3.1 20030707 (prerelease) (i686-pc-linux-gnu)
        compiled by GNU C version 3.4 20030707 (experimental).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128866
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
End of search list.
t.c:2:20: stdarg.h: No such file or directory
Comment 12 Ed Hynan 2003-12-09 16:47:11 UTC
(In reply to comment #11)
> But I can reproduce this in 3.3.1, so it was fixed for 3.4:

OK (with charming crunchy sound).