> and see that in some cases jobserver is 0 and in other cases jobserver is 1. > Examples of both: > 0 kw -j2 --jobserver-auth=3,6 -- > total 0 > lrwx------. 1 jakub jakub 64 Jul 31 10:41 0 -> /dev/pts/4 > l-wx------. 1 jakub jakub 64 Jul 31 10:41 1 -> pipe:[75026106] > lr-x------. 1 jakub jakub 64 Jul 31 10:41 10 -> > /usr/src/gcc/obj/gcc/libgcc_s.so > lr-x------. 1 jakub jakub 64 Jul 31 10:41 13 -> /usr/lib64/libc.so > lr-x------. 1 jakub jakub 64 Jul 31 10:41 18 -> > /usr/src/gcc/obj/gcc/libgcc_s.so > l-wx------. 1 jakub jakub 64 Jul 31 10:41 2 -> /tmp/ccX4y4r3.le > l-wx------. 1 jakub jakub 64 Jul 31 10:41 9 -> pipe:[46167136] > 1 kw -j2 --jobserver-auth=3,6 -- > total 0 > lrwx------. 1 jakub jakub 64 Jul 31 10:41 0 -> /dev/pts/4 > l-wx------. 1 jakub jakub 64 Jul 31 10:41 1 -> /tmp/cchSvmBt > lr-x------. 1 jakub jakub 64 Jul 31 10:41 10 -> /usr/lib64/crtn.o > lrwx------. 1 jakub jakub 64 Jul 31 10:41 2 -> /dev/pts/4 > lr-x------. 1 jakub jakub 64 Jul 31 10:41 3 -> /usr/lib64/crt1.o > lr-x------. 1 jakub jakub 64 Jul 31 10:41 4 -> /usr/lib64/crti.o > lr-x------. 1 jakub jakub 64 Jul 31 10:41 5 -> /usr/src/gcc/obj/gcc/crtbegin.o > lr-x------. 1 jakub jakub 64 Jul 31 10:41 6 -> > /usr/src/gcc/obj/gcc/testsuite/gcc/c_lto_20081125_0.o > lr-x------. 1 jakub jakub 64 Jul 31 10:41 7 -> > /usr/src/gcc/obj/gcc/testsuite/gcc/c_lto_20081125_1.o > lr-x------. 1 jakub jakub 64 Jul 31 10:41 8 -> /usr/src/gcc/obj/gcc/crtend.o > l-wx------. 1 jakub jakub 64 Jul 31 10:41 9 -> pipe:[46167136] > > so, if one is lucky enough and at least one of the two file descriptors in > MAKEFLAGS --jobserver-auth= is closed, it will work fine, but if they are > open, even when they have nothing to do with make, it will fail miserably.
I see, so the problem is that lto-wrapper is executed via plugin from gold which already used the file descriptors for something else? This seems a bit of problem since gold opens it before we get to lto-plugin (most probably) so i do not see how to reliably detect presence of make server. I think the gcc binary can look for jobserv environment, detect jobserv and if it is not available remove jobserver option from it prior going to ld. I think this works since I think link-time gcc can only be executed via gcc/g++/gfortran... wrappers. (unlike lto plugin invoked implicitly for ar/nm etc). Honza > > As a partial workaround, I wonder if jobserver_active_p couldn't check (with > fstat/fstat64) if the file descriptors are pipes. It will still not be 100% > reliable, as when you are unlucky the file descriptor could be some > completely unrelated pipe, but at least better than the current state. > > Jakub