]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
jobserver: detect properly O_NONBLOCK
authorMartin Liska <mliska@suse.cz>
Thu, 18 Aug 2022 11:03:42 +0000 (13:03 +0200)
committerMartin Liska <mliska@suse.cz>
Mon, 22 Aug 2022 14:05:52 +0000 (16:05 +0200)
PR lto/106700

gcc/ChangeLog:

* configure.ac: Detect O_NONBLOCK flag for open.
* config.in: Regenerate.
* configure: Regenerate.
* opts-common.cc (jobserver_info::connect): Set is_connected
  properly based on O_NONBLOCK.
* opts-jobserver.h (struct jobserver_info): Add is_connected
  member variable.

gcc/lto/ChangeLog:

* lto.cc (wait_for_child): Ask if we are connected to jobserver.
(stream_out_partitions): Likewise.

gcc/config.in
gcc/configure
gcc/configure.ac
gcc/lto/lto.cc
gcc/opts-common.cc
gcc/opts-jobserver.h

index 413b2bd36cb3b349d729f88a5208007758805f46..abab9bf5024e726392eb7be812ee129913569f9a 100644 (file)
 #endif
 
 
+/* Define if O_NONBLOCK supported by fcntl. */
+#ifndef USED_FOR_TARGET
+#undef HOST_HAS_O_NONBLOCK
+#endif
+
+
 /* Define which stat syscall is able to handle 64bit indodes. */
 #ifndef USED_FOR_TARGET
 #undef HOST_STAT_FOR_64BIT_INODES
index da7a45066b5ce7a90a301b5670c8c734b5bdc4b5..80498e68e36c7bd501d85990e1b180260183c50d 100755 (executable)
@@ -12460,6 +12460,31 @@ $as_echo "#define HOST_HAS_O_CLOEXEC 1" >>confdefs.h
 
 fi
 
+# Check if O_NONBLOCK is defined by fcntl
+for ac_header in fcntl.h
+do :
+  ac_fn_cxx_check_header_preproc "$LINENO" "fcntl.h" "ac_cv_header_fcntl_h"
+if test "x$ac_cv_header_fcntl_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_FCNTL_H 1
+_ACEOF
+
+fi
+done
+
+ac_fn_cxx_check_decl "$LINENO" "O_NONBLOCK" "ac_cv_have_decl_O_NONBLOCK" "#include <fcntl.h>
+"
+if test "x$ac_cv_have_decl_O_NONBLOCK" = xyes; then :
+
+fi
+
+if test $ac_cv_have_decl_O_NONBLOCK = yes; then
+
+$as_echo "#define HOST_HAS_O_NONBLOCK 1" >>confdefs.h
+
+fi
+
+
 # C++ Modules would like some networking features to provide the mapping
 # server.  You can still use modules without them though.
 # The following network-related checks could probably do with some
@@ -19678,7 +19703,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19681 "configure"
+#line 19706 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19784,7 +19809,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 19787 "configure"
+#line 19812 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
index f70b6c24fda7e002f64e74982edd2111e1d63142..819b490d1b643189cf5f795ba090b7219369a0e0 100644 (file)
@@ -1707,6 +1707,15 @@ if test $ac_cv_o_cloexec = yes; then
   [Define if O_CLOEXEC supported by fcntl.])
 fi
 
+# Check if O_NONBLOCK is defined by fcntl
+AC_CHECK_HEADERS([fcntl.h])
+AC_CHECK_DECL(O_NONBLOCK,,,[#include <fcntl.h>])
+if test $ac_cv_have_decl_O_NONBLOCK = yes; then
+  AC_DEFINE(HOST_HAS_O_NONBLOCK, 1,
+  [Define if O_NONBLOCK supported by fcntl.])
+fi
+
+
 # C++ Modules would like some networking features to provide the mapping
 # server.  You can still use modules without them though.
 # The following network-related checks could probably do with some
index c82307f4f7e696bed64adc2787193c7f1bfeb9a4..3a9147b01b54c8596df2bf4f22d0f52ac6eb30be 100644 (file)
@@ -213,11 +213,11 @@ wait_for_child ()
     }
   while (!WIFEXITED (status) && !WIFSIGNALED (status));
 
-    --nruns;
+  --nruns;
 
-    /* Return token to the jobserver if active.  */
-    if (jinfo != NULL && jinfo->is_active)
-      jinfo->return_token ();
+  /* Return token to the jobserver if active.  */
+  if (jinfo != NULL && jinfo->is_connected)
+    jinfo->return_token ();
 }
 #endif
 
@@ -254,7 +254,7 @@ stream_out_partitions (char *temp_filename, int blen, int min, int max,
      streaming process.  */
   if (!last)
     {
-      if (jinfo != NULL && jinfo->is_active)
+      if (jinfo != NULL && jinfo->is_connected)
        while (true)
          {
            if (jinfo->get_token ())
@@ -291,7 +291,7 @@ stream_out_partitions (char *temp_filename, int blen, int min, int max,
       while (nruns > 0)
        wait_for_child ();
 
-      if (jinfo != NULL && jinfo->is_active)
+      if (jinfo != NULL && jinfo->is_connected)
        jinfo->disconnect ();
     }
   asm_nodes_output = true;
index 4dec9f94447f4e4fd66406d1e1e43af149a4cacd..bff2be02d38bebcecaaca26eda1fb36e64f65a06 100644 (file)
@@ -2064,7 +2064,16 @@ void
 jobserver_info::connect ()
 {
   if (!pipe_path.empty ())
-    pipefd = open (pipe_path.c_str (), O_RDWR | O_NONBLOCK);
+    {
+#if HOST_HAS_O_NONBLOCK
+      pipefd = open (pipe_path.c_str (), O_RDWR | O_NONBLOCK);
+      is_connected = true;
+#else
+      is_connected = false;
+#endif
+    }
+  else
+    is_connected = true;
 }
 
 void
index 76c1d9b2882165c52eda444979960638e5388a0f..284b2417837c98db3763234a09f48d0fbf59c032 100644 (file)
@@ -55,6 +55,8 @@ struct jobserver_info
   int pipefd = -1;
   /* Return true if jobserver is active.  */
   bool is_active = false;
+  /* Return true if communication with jobserver is working.  */
+  bool is_connected = false;
 };
 
 #endif /* GCC_JOBSERVER_H */