summaryrefslogtreecommitdiff
path: root/gcc/lto-wrapper.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2020-05-05 16:11:33 +0200
committerMartin Liska <mliska@suse.cz>2020-05-05 16:11:33 +0200
commit0f62caf58b5d11f375f789385d6d49891ebd9a94 (patch)
tree61de0150b2fc3e95c0205c8ad6213049fb0c06b6 /gcc/lto-wrapper.c
parentaf2311abf8a13cdfe00bfa44453bb02c38b0b5d8 (diff)
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.
Diffstat (limited to 'gcc/lto-wrapper.c')
-rw-r--r--gcc/lto-wrapper.c39
1 files changed, 25 insertions, 14 deletions
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 "%<MAKEFLAGS%> 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 %<MAKEFLAGS%>";
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)