aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-08-18 13:03:42 +0200
committerMartin Liska <mliska@suse.cz>2022-08-22 16:05:52 +0200
commit827f64135957ce21617cd0345508077439fa29d8 (patch)
treea9945021eb1bd08ec7a4900d94462a9d4e3cb7d0
parent21e7d87a901d45f0cb5e5510d22bfbdb0d0ac6a1 (diff)
downloadgcc-827f64135957ce21617cd0345508077439fa29d8.zip
gcc-827f64135957ce21617cd0345508077439fa29d8.tar.gz
gcc-827f64135957ce21617cd0345508077439fa29d8.tar.bz2
jobserver: detect properly O_NONBLOCK
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.
-rw-r--r--gcc/config.in6
-rwxr-xr-xgcc/configure29
-rw-r--r--gcc/configure.ac9
-rw-r--r--gcc/lto/lto.cc12
-rw-r--r--gcc/opts-common.cc11
-rw-r--r--gcc/opts-jobserver.h2
6 files changed, 60 insertions, 9 deletions
diff --git a/gcc/config.in b/gcc/config.in
index 413b2bd..abab9bf 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2148,6 +2148,12 @@
#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
diff --git a/gcc/configure b/gcc/configure
index da7a450..80498e6 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -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
diff --git a/gcc/configure.ac b/gcc/configure.ac
index f70b6c2..819b490 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -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
diff --git a/gcc/lto/lto.cc b/gcc/lto/lto.cc
index c82307f..3a9147b 100644
--- a/gcc/lto/lto.cc
+++ b/gcc/lto/lto.cc
@@ -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;
diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index 4dec9f9..bff2be0 100644
--- a/gcc/opts-common.cc
+++ b/gcc/opts-common.cc
@@ -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
diff --git a/gcc/opts-jobserver.h b/gcc/opts-jobserver.h
index 76c1d9b..284b241 100644
--- a/gcc/opts-jobserver.h
+++ b/gcc/opts-jobserver.h
@@ -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 */