If a directory in PATH contains a subdirectory gcc/ (with executable access), gcc fails to find its subprograms: $ PATH=/tmp:$PATH $ mkdir /tmp/gcc $ gcc hello.c gcc: error trying to exec 'cc1': execvp: No such file or directory $ rmdir /tmp/gcc $ gcc hello.c $ If this behavior is explained or implicit in the documentation, sorry; I couldn't find it. It happens in at least gcc 4.5.x and 4.6.0. I'm sure it wasn't always this way.
Works for me. How did you configure/install GCC? What does -v output say for the compile command?
For both gcc 4.5.2 and 4.6.0, I configured it from the original source on ftp.gnu.org, using --prefix=/usr/local/gnu --enable-languages=c,c++, no other arguments. "make install" to install. Here is the gcc -v output. I note that cpp is not even being executed. $ gcc -v hello.c Using built-in specs. COLLECT_GCC=gcc Target: i686-pc-linux-gnu Configured with: ../gcc-4.6.0/configure --prefix=/usr/local/gnu --enable-langua\ ges=c,c++ Thread model: posix gcc version 4.6.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=pentiumpro' cc1 -quiet -v -iprefix /tmp/../lib/gcc/i686-pc-linux-gnu/4.6.0/ hello.c -quiet\ -dumpbase hello.c -mtune=generic -march=pentiumpro -auxbase hello -version -o \ /dev/shm/cc34H39x.s gcc: error trying to exec 'cc1': execvp: No such file or directory The /tmp/../lib seems like a clear indication it is finding the empty /tmp/gcc directory. I thought it might be something in my environment causing the failure, but even running with env -i, I get the same error. It is puzzling that you do not see it. I can't think of what else would be specific to my installation. $ mkdir /tmp/gcc $ env -i PATH=/tmp:/usr/local/gnu/bin gcc hello.c gcc: error trying to exec 'cc1': execvp: No such file or directory (the gcc -v output from this env -i run is the same as above.) Thanks, karl
Ok, I can reproduce it with ~> env -i PATH=/tmp:/space/rguenther/install/gcc-4.6.0/bin gcc t.c gcc: error trying to exec 'cc1': execvp: No such file or directory but not with ~> env -i PATH=/tmp:$PATH gcc-4.6 t.c t.c: In function 'main': t.c:10:3: warning: 'used' attribute ignored [-Wattributes] weird ;) Note that we try to search for the GCC install dir, it is not statically compiled in (so that install with DESTDIR works).
Fails since 4.3.0, works with 4.2.4.
4.3 branch is being closed, moving to 4.4.7 target.
Created attachment 26146 [details] gcc47-pr48306.patch Not sure if this case is something we need to slow the driver down for, but if yes, this completely untested patch should do that. I've also fixed a problem where we IMHO can overflow the alloca returned buffer on cygwin or wherever HOST_EXECUTABLE_SUFFIX is used, though have no access to such a system to test that.
I hope you will decide that robustness against the execution environment is more important than a few milliseconds of runtime. I wouldn't have reported it if I hadn't actually run into it in the course of working with the new gcc and been surprised. It's not like I read the code and observed a theoretical bug :).
Author: jakub Date: Mon Jan 2 22:18:21 2012 New Revision: 182820 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182820 Log: * make-relative-prefix.c (make_relative_prefix_1): Avoid stack overflow if PATH contains just a single entry and HOST_EXECUTABLE_SUFFIX needs to be used. PR driver/48306 * make-relative-prefix.c: Include sys/stat.h. (make_relative_prefix_1): If access succeeds, check also stat if nstore is a regular file. Modified: trunk/libiberty/ChangeLog trunk/libiberty/make-relative-prefix.c
Fixed on the trunk so far.
Author: jakub Date: Thu Feb 9 17:16:19 2012 New Revision: 184050 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184050 Log: Backported from mainline 2012-01-26 Jakub Jelinek <jakub@redhat.com> * make-relative-prefix.c (make_relative_prefix_1): Avoid warning about using preprocessor directives inside of macro arguments. 2012-01-02 Jakub Jelinek <jakub@redhat.com> * make-relative-prefix.c (make_relative_prefix_1): Avoid stack overflow if PATH contains just a single entry and HOST_EXECUTABLE_SUFFIX needs to be used. PR driver/48306 * make-relative-prefix.c: Include sys/stat.h. (make_relative_prefix_1): If access succeeds, check also stat if nstore is a regular file. Modified: branches/gcc-4_6-branch/libiberty/ChangeLog branches/gcc-4_6-branch/libiberty/make-relative-prefix.c
Author: jakub Date: Thu Feb 9 21:33:11 2012 New Revision: 184069 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184069 Log: Backported from mainline 2012-01-26 Jakub Jelinek <jakub@redhat.com> * make-relative-prefix.c (make_relative_prefix_1): Avoid warning about using preprocessor directives inside of macro arguments. 2012-01-02 Jakub Jelinek <jakub@redhat.com> * make-relative-prefix.c (make_relative_prefix_1): Avoid stack overflow if PATH contains just a single entry and HOST_EXECUTABLE_SUFFIX needs to be used. PR driver/48306 * make-relative-prefix.c: Include sys/stat.h. (make_relative_prefix_1): If access succeeds, check also stat if nstore is a regular file. Modified: branches/gcc-4_5-branch/libiberty/ChangeLog branches/gcc-4_5-branch/libiberty/make-relative-prefix.c
Fixed in 4.5+, 4.4 is no longer supported.
*** Bug 38966 has been marked as a duplicate of this bug. ***