diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 6be6bdf8dea5c..79714132b91ae 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3. If not see
. */
#include "config.h"
+#define INCLUDE_PTHREAD_H
#include "system.h"
#include "coretypes.h"
#include "target.h"
@@ -41,8 +42,6 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "stmt.h"
-#include
-
#include "jit-playback.h"
#include "jit-result.h"
#include "jit-builtins.h"
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index a31720f043e9c..5556b9c49056e 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -19,13 +19,13 @@ along with GCC; see the file COPYING3. If not see
. */
#include "config.h"
+#define INCLUDE_PTHREAD_H
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "pretty-print.h"
#include "toplev.h"
-#include
#include "jit-builtins.h"
#include "jit-recording.h"
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
index cc6486c9cadc2..4c991e5436bcf 100644
--- a/gcc/jit/libgccjit.cc
+++ b/gcc/jit/libgccjit.cc
@@ -19,12 +19,12 @@ along with GCC; see the file COPYING3. If not see
. */
#include "config.h"
+#define INCLUDE_PTHREAD_H
#include "system.h"
#include "coretypes.h"
#include "timevar.h"
#include "typed-splay-tree.h"
#include "cppbuiltin.h"
-#include
#include "libgccjit.h"
#include "jit-recording.h"
diff --git a/gcc/system.h b/gcc/system.h
index c5562cc49a305..e10c34f70eca4 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -750,6 +750,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list);
#endif
#endif
+#ifdef INCLUDE_PTHREAD_H
+#include
+#endif
+
#ifdef INCLUDE_ISL
#ifdef HAVE_isl
#include