From: Martin Liska Date: Tue, 5 May 2020 14:11:33 +0000 (+0200) Subject: Provide warning for missing jobserver. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0f62caf58b5d11f375f789385d6d49891ebd9a94;p=gcc.git Provide warning for missing jobserver. PR driver/94330 * lto-wrapper.c (run_gcc): When using -flto=jobserver, report warning when the jobserver is not detected. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2cb6ea60eca..cbdc5504cad 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-05-05 Martin Liska + + PR driver/94330 + * lto-wrapper.c (run_gcc): When using -flto=jobserver, + report warning when the jobserver is not detected. + 2020-05-05 Martin Liska PR gcov-profile/94636 diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 46a88b233f6..19d0c224dad 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -1236,28 +1236,33 @@ init_num_threads (void) /* FIXME: once using -std=c++11, we can use std::thread::hardware_concurrency. */ -/* Return true when a jobserver is running and can accept a job. */ +/* Test and return reason why a jobserver cannot be detected. */ -static bool +static const char * jobserver_active_p (void) { + #define JS_PREFIX "jobserver is not available: " + #define JS_NEEDLE "--jobserver-auth=" + const char *makeflags = getenv ("MAKEFLAGS"); if (makeflags == NULL) - return false; + return JS_PREFIX "% environment variable is unset"; - const char *needle = "--jobserver-auth="; - const char *n = strstr (makeflags, needle); + const char *n = strstr (makeflags, JS_NEEDLE); if (n == NULL) - return false; + return JS_PREFIX "%<" JS_NEEDLE "%> is not present in %"; int rfd = -1; int wfd = -1; - return (sscanf (n + strlen (needle), "%d,%d", &rfd, &wfd) == 2 - && rfd > 0 - && wfd > 0 - && is_valid_fd (rfd) - && is_valid_fd (wfd)); + if (sscanf (n + strlen (JS_NEEDLE), "%d,%d", &rfd, &wfd) == 2 + && rfd > 0 + && wfd > 0 + && is_valid_fd (rfd) + && is_valid_fd (wfd)) + return NULL; + else + return JS_PREFIX "cannot access %<" JS_NEEDLE "%> file descriptors"; } /* Execute gcc. ARGC is the number of arguments. ARGV contains the arguments. */ @@ -1473,10 +1478,16 @@ run_gcc (unsigned argc, char *argv[]) auto_parallel = 0; parallel = 0; } - else if (!jobserver && jobserver_active_p ()) + else { - parallel = 1; - jobserver = 1; + const char *jobserver_error = jobserver_active_p (); + if (jobserver && jobserver_error != NULL) + warning (0, jobserver_error); + else if (!jobserver && jobserver_error == NULL) + { + parallel = 1; + jobserver = 1; + } } if (linker_output)