gccgnu-makepermission-denied

make gives gcc: Permission denied - Error 127


I am executing make. At some point it enters src and from there it tries compiling sources in several subdirectories. It gives

gcc -x c++ -ggdb -ansi -pedantic -iquote/home/user1/code -Wall -Wcast-align -Wcast-qual -Wnested-externs -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wshadow -fno-common -Dinline=  -Wvariadic-macros  -iprefix /home/user1/code/src/ -iwithprefix . -iwithprefix DataSet -iwithprefix Outputs -iwithprefix Solver -iwithprefix Tools -iwithprefix Models -iwithprefix Modules -iwithprefix Help -iwithprefix Common   -iwithprefix Main -fPIC -fpermissive -c Common/Buffer.c -o Common/Buffer.o
make[1]: gcc: Permission denied
make[1]: *** [Makefile:140: Common/Buffer.o] Error 127

But if execute (copy-pasting the echoed command)

$ cd src
$ gcc -x c++ -ggdb -ansi -pedantic -iquote/home/user1/code -Wall -Wcast-align -Wcast-qual -Wnested-externs -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wshadow -fno-common -Dinline=  -Wvariadic-macros  -iprefix /home/user1/code/src/ -iwithprefix . -iwithprefix DataSet -iwithprefix Outputs -iwithprefix Solver -iwithprefix Tools -iwithprefix Models -iwithprefix Modules -iwithprefix Help -iwithprefix Common   -iwithprefix Main -fPIC -fpermissive -c Common/Buffer.c -o Common/Buffer.o

it compiles fine.

What could the cause and solution be?


Solution

  • This is almost certainly an instance of this bug in gnulib (which GNU Make relies on): https://savannah.gnu.org/bugs/?57962

    You don't say what version of GNU Make you're using, but I bet it's GNU Make 4.3.

    You can either upgrade your version of GNU Make, or fix your PATH so it doesn't contain any directories which have gcc as a subdirectory, or change your compiler path in your Makefile to be fully-qualified (to avoid PATH search), or add a semicolon to the end of your compile recipe (to force GNU Make to use a shell and not use its "fast path" capability).